mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
77fafd887a
commit
9c6b86958c
@ -1,3 +1,5 @@
|
|||||||
|
import { waitFor } from '@testing-library/react';
|
||||||
|
|
||||||
import { DataFrameView } from '@grafana/data';
|
import { DataFrameView } from '@grafana/data';
|
||||||
import { locationService } from '@grafana/runtime';
|
import { locationService } from '@grafana/runtime';
|
||||||
|
|
||||||
@ -33,6 +35,14 @@ describe('SearchStateManager', () => {
|
|||||||
view: new DataFrameView<DashboardQueryResult>({ fields: [], length: 0 }),
|
view: new DataFrameView<DashboardQueryResult>({ fields: [], length: 0 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
it('Can get search state manager with initial state', async () => {
|
it('Can get search state manager with initial state', async () => {
|
||||||
const stm = getSearchStateManager();
|
const stm = getSearchStateManager();
|
||||||
expect(stm.state.layout).toBe(SearchLayout.Folders);
|
expect(stm.state.layout).toBe(SearchLayout.Folders);
|
||||||
@ -115,9 +125,9 @@ describe('SearchStateManager', () => {
|
|||||||
|
|
||||||
stm.onQueryChange('debugging');
|
stm.onQueryChange('debugging');
|
||||||
|
|
||||||
await wait(150);
|
jest.advanceTimersByTime(150);
|
||||||
|
|
||||||
expect(stm.state.result?.totalRows).toEqual(10);
|
await waitFor(() => expect(stm.state.result?.totalRows).toEqual(10));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user