Created
June 24, 2022 07:40
-
-
Save timdeschryver/12bb46a866b1914db1dc6f1a7a7688f0 to your computer and use it in GitHub Desktop.
reproduction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fit('Then follow through navigation reproduction', async () => { | |
let isAuthenticated$ = new ReplaySubject<boolean>(1); | |
let mockedAuthStore = jasmine.createSpyObj<AuthStore>(AuthStore.name, [], { | |
isAuthenticated$ | |
}); | |
const router = await minimalRender( | |
[ | |
{ path: '', component: DummyHomeComponent }, | |
...routes | |
], | |
[{ provide: AuthStore, useValue: mockedAuthStore }] | |
); | |
// for some reason it's ok to invoke here | |
router.initialNavigation(); | |
isAuthenticated$.next(false); | |
let canNavigate = await router.navigate([testUrl]); | |
expect(canNavigate).toEqual(true); | |
}); | |
async function minimalRender(routes: any[], providers: any[]) { | |
await TestBed.configureTestingModule({ | |
imports: [ | |
RouterTestingModule.withRoutes(routes) | |
], | |
providers: [...providers] | |
}).compileComponents(); | |
TestBed.createComponent(DummyRootComponent); | |
const router = TestBed.inject(Router); | |
// uncomment and the test fails | |
// router.initialNavigation(); | |
return router; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment