Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Aug 25, 2020
1 parent 002e1da commit a3765e7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,59 @@ describe('start', () => {
`);
});
});

describe('erase chrome fields', () => {
it('while switching an app', async () => {
const startDeps = defaultStartDeps([new FakeApp('alpha')]);
const { navigateToApp } = startDeps.application;
const { chrome, service } = await start({ startDeps });

const helpExtensionPromise = chrome.getHelpExtension$().pipe(toArray()).toPromise();
const breadcrumbsPromise = chrome.getBreadcrumbs$().pipe(toArray()).toPromise();
const badgePromise = chrome.getBadge$().pipe(toArray()).toPromise();
const docTitleResetSpy = jest.spyOn(chrome.docTitle, 'reset');

const promises = Promise.all([helpExtensionPromise, breadcrumbsPromise, badgePromise]);

chrome.setHelpExtension({ appName: 'App name' });
chrome.setBreadcrumbs([{ text: 'App breadcrumb' }]);
chrome.setBadge({ text: 'App badge', tooltip: 'App tooltip' });

navigateToApp('alpha');

service.stop();

expect(docTitleResetSpy).toBeCalledTimes(1);
await expect(promises).resolves.toMatchInlineSnapshot(`
Array [
Array [
undefined,
Object {
"appName": "App name",
},
undefined,
],
Array [
Array [],
Array [
Object {
"text": "App breadcrumb",
},
],
Array [],
],
Array [
undefined,
Object {
"text": "App badge",
"tooltip": "App tooltip",
},
undefined,
],
]
`);
});
});
});

describe('stop', () => {
Expand Down

0 comments on commit a3765e7

Please sign in to comment.