diff --git a/src/core/public/application/application_service.test.ts b/src/core/public/application/application_service.test.ts index e7100edd88086..50e47bdf71772 100644 --- a/src/core/public/application/application_service.test.ts +++ b/src/core/public/application/application_service.test.ts @@ -482,9 +482,6 @@ describe('#setup()', () => { describe('#start()', () => { beforeEach(() => { - MockHistory.push.mockReset(); - parseAppUrlMock.mockReset(); - const http = httpServiceMock.createSetupContract({ basePath: '/base-path' }); setupDeps = { http, @@ -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."` @@ -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', () => {