mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-11 13:51:10 -07:00
test(cli): refactor tests for async render utilities (#23252)
This commit is contained in:
committed by
GitHub
parent
86a3a913b5
commit
6c78eb7a39
@@ -54,12 +54,12 @@ const TestHarness = ({
|
||||
};
|
||||
|
||||
describe('SessionStatsContext', () => {
|
||||
it('should provide the correct initial state', () => {
|
||||
it('should provide the correct initial state', async () => {
|
||||
const contextRef: MutableRefObject<
|
||||
ReturnType<typeof useSessionStats> | undefined
|
||||
> = { current: undefined };
|
||||
|
||||
const { unmount } = render(
|
||||
const { unmount } = await render(
|
||||
<SessionStatsProvider>
|
||||
<TestHarness contextRef={contextRef} />
|
||||
</SessionStatsProvider>,
|
||||
@@ -73,12 +73,12 @@ describe('SessionStatsContext', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should update metrics when the uiTelemetryService emits an update', () => {
|
||||
it('should update metrics when the uiTelemetryService emits an update', async () => {
|
||||
const contextRef: MutableRefObject<
|
||||
ReturnType<typeof useSessionStats> | undefined
|
||||
> = { current: undefined };
|
||||
|
||||
const { unmount } = render(
|
||||
const { unmount } = await render(
|
||||
<SessionStatsProvider>
|
||||
<TestHarness contextRef={contextRef} />
|
||||
</SessionStatsProvider>,
|
||||
@@ -149,7 +149,7 @@ describe('SessionStatsContext', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should not update metrics if the data is the same', () => {
|
||||
it('should not update metrics if the data is the same', async () => {
|
||||
const contextRef: MutableRefObject<
|
||||
ReturnType<typeof useSessionStats> | undefined
|
||||
> = { current: undefined };
|
||||
@@ -161,7 +161,7 @@ describe('SessionStatsContext', () => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const { unmount } = render(
|
||||
const { unmount } = await render(
|
||||
<SessionStatsProvider>
|
||||
<CountingTestHarness />
|
||||
</SessionStatsProvider>,
|
||||
@@ -239,12 +239,12 @@ describe('SessionStatsContext', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should update session ID and reset stats when the uiTelemetryService emits a clear event', () => {
|
||||
it('should update session ID and reset stats when the uiTelemetryService emits a clear event', async () => {
|
||||
const contextRef: MutableRefObject<
|
||||
ReturnType<typeof useSessionStats> | undefined
|
||||
> = { current: undefined };
|
||||
|
||||
const { unmount } = render(
|
||||
const { unmount } = await render(
|
||||
<SessionStatsProvider>
|
||||
<TestHarness contextRef={contextRef} />
|
||||
</SessionStatsProvider>,
|
||||
@@ -267,12 +267,12 @@ describe('SessionStatsContext', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should throw an error when useSessionStats is used outside of a provider', () => {
|
||||
it('should throw an error when useSessionStats is used outside of a provider', async () => {
|
||||
const onError = vi.fn();
|
||||
// Suppress console.error from React for this test
|
||||
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
const { unmount } = render(
|
||||
const { unmount } = await render(
|
||||
<ErrorBoundary onError={onError}>
|
||||
<TestHarness contextRef={{ current: undefined }} />
|
||||
</ErrorBoundary>,
|
||||
|
||||
Reference in New Issue
Block a user