Skip to content

Commit

Permalink
Failing jest mock tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Sep 24, 2020
1 parent 267931b commit 037ba98
Showing 1 changed file with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,32 @@

import { ElasticsearchAssetType, Installation, KibanaAssetType } from '../../../types';
import { SavedObject } from 'src/core/server';
import { getInstallType } from './install';
jest.mock('./install', () => ({
...(jest.requireActual('./install') as {}),
bulkInstallPackages: jest.fn(async () => {
return [
{
name: 'blah',
assets: [],
newVersion: '',
oldVersion: '',
statusCode: 200,
},
];
}),
}));

jest.mock('./get', () => ({
...(jest.requireActual('./get') as {}),
getInstallation: jest.fn(async () => {
return mockInstallation.attributes;
}),
}));
import { getInstallType, ensureInstalledDefaultPackages } from './install';

import { savedObjectsClientMock } from 'src/core/server/mocks';
import { appContextService } from '../../app_context';
import { createAppContextStartContractMock } from '../../../mocks';

const mockInstallation: SavedObject<Installation> = {
id: 'test-pkg',
Expand Down Expand Up @@ -42,7 +67,17 @@ const mockInstallationUpdateFail: SavedObject<Installation> = {
};
describe('install', () => {
describe('ensureInstalledDefaultPackages', () => {
it('should return an array of Installation objects when successful', async () => {});
beforeEach(async () => {
appContextService.start(createAppContextStartContractMock());
});
afterEach(async () => {
appContextService.stop();
});
it('should return an array of Installation objects when successful', async () => {
const soClient = savedObjectsClientMock.create();
const resp = await ensureInstalledDefaultPackages(soClient, jest.fn());
expect(resp).toEqual([mockInstallation.attributes]);
});
});
describe('getInstallType', () => {
it('should return correct type when installing and no other version is currently installed', () => {
Expand Down

0 comments on commit 037ba98

Please sign in to comment.