mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dependencies: Jest 27 (#42681)
* Update jest monorepo * Update version of marked so it doesn't throw an error, set testEnvironment * Fix some unit tests * Remove all these tests that aren't actually working... * use spyOn instead of mocking the whole module * Fix linting Co-authored-by: Renovate Bot <bot@renovateapp.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { lastUsedDatasourceKeyForOrgId } from '../../../core/utils/explore';
|
||||
import store from '../../../core/store';
|
||||
|
||||
const dataSourceMock = {
|
||||
get: jest.fn(),
|
||||
@@ -7,11 +8,7 @@ jest.mock('app/features/plugins/datasource_srv', () => ({
|
||||
getDatasourceSrv: jest.fn(() => dataSourceMock),
|
||||
}));
|
||||
|
||||
const storeMock = {
|
||||
getObject: jest.fn().mockReturnValue([]),
|
||||
set: jest.fn(),
|
||||
};
|
||||
jest.mock('app/core/store', () => storeMock);
|
||||
jest.spyOn(store, 'set');
|
||||
|
||||
import { loadAndInitDatasource } from './utils';
|
||||
|
||||
@@ -33,7 +30,7 @@ describe('loadAndInitDatasource', () => {
|
||||
expect(dataSourceMock.get).toBeCalledWith('Unknown');
|
||||
expect(dataSourceMock.get).toBeCalledWith();
|
||||
expect(instance).toMatchObject(DEFAULT_DATASOURCE);
|
||||
expect(storeMock.set).toBeCalledWith(lastUsedDatasourceKeyForOrgId(1), DEFAULT_DATASOURCE.uid);
|
||||
expect(store.set).toBeCalledWith(lastUsedDatasourceKeyForOrgId(1), DEFAULT_DATASOURCE.uid);
|
||||
});
|
||||
|
||||
it('saves last loaded data source uid', async () => {
|
||||
@@ -44,6 +41,6 @@ describe('loadAndInitDatasource', () => {
|
||||
expect(dataSourceMock.get).toBeCalledTimes(1);
|
||||
expect(dataSourceMock.get).toBeCalledWith('Test');
|
||||
expect(instance).toMatchObject(TEST_DATASOURCE);
|
||||
expect(storeMock.set).toBeCalledWith(lastUsedDatasourceKeyForOrgId(1), TEST_DATASOURCE.uid);
|
||||
expect(store.set).toBeCalledWith(lastUsedDatasourceKeyForOrgId(1), TEST_DATASOURCE.uid);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user