Skip to content

Instantly share code, notes, and snippets.

@timdeschryver
Created June 24, 2022 07:40
Show Gist options
  • Save timdeschryver/12bb46a866b1914db1dc6f1a7a7688f0 to your computer and use it in GitHub Desktop.
Save timdeschryver/12bb46a866b1914db1dc6f1a7a7688f0 to your computer and use it in GitHub Desktop.
reproduction
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