Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core/public] stop loadingCount, improve stop() tests #22937

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions src/core/public/core_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const MockLoadingCountService = jest.fn<LoadingCountService>(function _MockNotif
this: any
) {
this.start = jest.fn().mockReturnValue(mockLoadingCountContract);
this.stop = jest.fn();
});
jest.mock('./loading_count', () => ({
LoadingCountService: MockLoadingCountService,
Expand Down Expand Up @@ -197,17 +198,51 @@ describe('constructor', () => {
});

describe('#stop', () => {
it('call legacyPlatform.stop()', () => {
it('calls legacyPlatform.stop()', () => {
const coreSystem = new CoreSystem({
...defaultCoreSystemParams,
});

const legacyPlatformService = MockLegacyPlatformService.mock.instances[0];

const [legacyPlatformService] = MockLegacyPlatformService.mock.instances;
expect(legacyPlatformService.stop).not.toHaveBeenCalled();
coreSystem.stop();
expect(legacyPlatformService.stop).toHaveBeenCalled();
});

it('calls notifications.stop()', () => {
const coreSystem = new CoreSystem({
...defaultCoreSystemParams,
});

const [notificationsService] = MockNotificationsService.mock.instances;
expect(notificationsService.stop).not.toHaveBeenCalled();
coreSystem.stop();
expect(notificationsService.stop).toHaveBeenCalled();
});

it('calls loadingCount.stop()', () => {
const coreSystem = new CoreSystem({
...defaultCoreSystemParams,
});

const [loadingCountService] = MockLoadingCountService.mock.instances;
expect(loadingCountService.stop).not.toHaveBeenCalled();
coreSystem.stop();
expect(loadingCountService.stop).toHaveBeenCalled();
});

it('clears the rootDomElement', () => {
const rootDomElement = document.createElement('div');
const coreSystem = new CoreSystem({
...defaultCoreSystemParams,
rootDomElement,
});

coreSystem.start();
expect(rootDomElement.innerHTML).not.toBe('');
coreSystem.stop();
expect(rootDomElement.innerHTML).toBe('');
});
});

describe('#start()', () => {
Expand Down
1 change: 1 addition & 0 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class CoreSystem {
public stop() {
this.legacyPlatform.stop();
this.notifications.stop();
this.loadingCount.stop();
this.rootDomElement.textContent = '';
}
}