@@ -8,19 +8,15 @@ import { render } from '../../test-utils/render.js';
88import { describe , it , expect , vi , beforeEach , type Mock } from 'vitest' ;
99import { Header } from './Header.js' ;
1010import * as useTerminalSize from '../hooks/useTerminalSize.js' ;
11- import { longAsciiLogo , longAsciiLogoIde } from './AsciiArt.js' ;
11+ import { longAsciiLogo } from './AsciiArt.js' ;
1212import * as semanticColors from '../semantic-colors.js' ;
13- import * as terminalSetup from '../utils/terminalSetup.js' ;
1413import { Text } from 'ink' ;
1514import type React from 'react' ;
1615
1716vi . mock ( '../hooks/useTerminalSize.js' ) ;
1817vi . mock ( '../hooks/useSnowfall.js' , ( ) => ( {
1918 useSnowfall : vi . fn ( ( art ) => art ) ,
2019} ) ) ;
21- vi . mock ( '../utils/terminalSetup.js' , ( ) => ( {
22- getTerminalProgram : vi . fn ( ) ,
23- } ) ) ;
2420vi . mock ( 'ink-gradient' , ( ) => {
2521 const MockGradient = ( { children } : { children : React . ReactNode } ) => (
2622 < > { children } </ >
@@ -41,7 +37,6 @@ vi.mock('ink', async () => {
4137describe ( '<Header />' , ( ) => {
4238 beforeEach ( ( ) => {
4339 vi . clearAllMocks ( ) ;
44- vi . mocked ( terminalSetup . getTerminalProgram ) . mockReturnValue ( null ) ;
4540 } ) ;
4641
4742 it ( 'renders the long logo on a wide terminal' , ( ) => {
@@ -58,22 +53,6 @@ describe('<Header />', () => {
5853 ) ;
5954 } ) ;
6055
61- it ( 'uses the IDE logo when running in an IDE' , ( ) => {
62- vi . spyOn ( useTerminalSize , 'useTerminalSize' ) . mockReturnValue ( {
63- columns : 120 ,
64- rows : 20 ,
65- } ) ;
66- vi . mocked ( terminalSetup . getTerminalProgram ) . mockReturnValue ( 'vscode' ) ;
67-
68- render ( < Header version = "1.0.0" nightly = { false } /> ) ;
69- expect ( Text ) . toHaveBeenCalledWith (
70- expect . objectContaining ( {
71- children : longAsciiLogoIde ,
72- } ) ,
73- undefined ,
74- ) ;
75- } ) ;
76-
7756 it ( 'renders custom ASCII art when provided' , ( ) => {
7857 const customArt = 'CUSTOM ART' ;
7958 render (
@@ -87,24 +66,13 @@ describe('<Header />', () => {
8766 ) ;
8867 } ) ;
8968
90- it ( 'renders custom ASCII art as is when running in an IDE' , ( ) => {
91- const customArt = 'CUSTOM ART' ;
92- vi . mocked ( terminalSetup . getTerminalProgram ) . mockReturnValue ( 'vscode' ) ;
93- render (
94- < Header version = "1.0.0" nightly = { false } customAsciiArt = { customArt } /> ,
95- ) ;
96- expect ( Text ) . toHaveBeenCalledWith (
97- expect . objectContaining ( {
98- children : customArt ,
99- } ) ,
100- undefined ,
101- ) ;
102- } ) ;
103-
10469 it ( 'displays the version number when nightly is true' , ( ) => {
10570 render ( < Header version = "1.0.0" nightly = { true } /> ) ;
10671 const textCalls = ( Text as Mock ) . mock . calls ;
107- expect ( textCalls [ 1 ] [ 0 ] . children . join ( '' ) ) . toBe ( 'v1.0.0' ) ;
72+ const versionText = Array . isArray ( textCalls [ 1 ] [ 0 ] . children )
73+ ? textCalls [ 1 ] [ 0 ] . children . join ( '' )
74+ : textCalls [ 1 ] [ 0 ] . children ;
75+ expect ( versionText ) . toBe ( 'v1.0.0' ) ;
10876 } ) ;
10977
11078 it ( 'does not display the version number when nightly is false' , ( ) => {
0 commit comments