Fix tests to wrap all calls changing the UI with act. (#12268)

This commit is contained in:
Jacob Richman
2025-10-30 11:50:26 -07:00
committed by GitHub
parent cc081337b7
commit 54fa26ef0e
69 changed files with 2002 additions and 1291 deletions

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { render } from 'ink-testing-library';
import { render } from '../../test-utils/render.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { Header } from './Header.js';
import * as useTerminalSize from '../hooks/useTerminalSize.js';
@@ -20,25 +20,35 @@ describe('<Header />', () => {
columns: 120,
rows: 20,
});
const { lastFrame } = render(<Header version="1.0.0" nightly={false} />);
const { lastFrame, unmount } = render(
<Header version="1.0.0" nightly={false} />,
);
expect(lastFrame()).toContain(longAsciiLogo);
unmount();
});
it('renders custom ASCII art when provided', () => {
const customArt = 'CUSTOM ART';
const { lastFrame } = render(
const { lastFrame, unmount } = render(
<Header version="1.0.0" nightly={false} customAsciiArt={customArt} />,
);
expect(lastFrame()).toContain(customArt);
unmount();
});
it('displays the version number when nightly is true', () => {
const { lastFrame } = render(<Header version="1.0.0" nightly={true} />);
const { lastFrame, unmount } = render(
<Header version="1.0.0" nightly={true} />,
);
expect(lastFrame()).toContain('v1.0.0');
unmount();
});
it('does not display the version number when nightly is false', () => {
const { lastFrame } = render(<Header version="1.0.0" nightly={false} />);
const { lastFrame, unmount } = render(
<Header version="1.0.0" nightly={false} />,
);
expect(lastFrame()).not.toContain('v1.0.0');
unmount();
});
});