Skip to content

Commit

Permalink
add test when replace is false
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Jun 11, 2020
1 parent 3a23cdf commit 6382608
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/core/public/application/application_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,6 @@ describe('#setup()', () => {

describe('#start()', () => {
beforeEach(() => {
MockHistory.push.mockReset();
parseAppUrlMock.mockReset();

const http = httpServiceMock.createSetupContract({ basePath: '/base-path' });
setupDeps = {
http,
Expand All @@ -497,6 +494,12 @@ describe('#start()', () => {
service = new ApplicationService();
});

afterEach(() => {
MockHistory.push.mockReset();
MockHistory.replace.mockReset();
parseAppUrlMock.mockReset();
});

it('rejects if called prior to #setup()', async () => {
await expect(service.start(startDeps)).rejects.toThrowErrorMatchingInlineSnapshot(
`"ApplicationService#setup() must be invoked before start."`
Expand Down Expand Up @@ -981,6 +984,22 @@ describe('#start()', () => {
expect(setupDeps.redirectTo).toHaveBeenCalledWith('/test/app/alpha');
});
});

describe('when `replace` option is false', () => {
it('behave as when the option is unspecified', async () => {
service.setup(setupDeps);

const { navigateToApp } = await service.start(startDeps);

await navigateToApp('myTestApp', { replace: false });
expect(MockHistory.push).toHaveBeenCalledWith('/app/myTestApp', undefined);

await navigateToApp('myOtherApp', { replace: false });
expect(MockHistory.push).toHaveBeenCalledWith('/app/myOtherApp', undefined);

expect(MockHistory.replace).not.toHaveBeenCalled();
});
});
});

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

0 comments on commit 6382608

Please sign in to comment.