A
A
Andrey Prozorov2019-09-20 15:41:59
Angular
Andrey Prozorov, 2019-09-20 15:41:59

How to test relative router.navigate?

there is this piece of code:

navigateTo() {
   this.router.navigate(['.', 'testUrl'], {
      relativeTo: this.activatedRoute,
    });
}

I test like this:
beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        RouterTestingModule.withRoutes([
          {
            path: 'testUrl',
            component: TestComponent
          },
        ]),
      ]
      })
     })

     it('', async( async () => {
        navigateTo();
        await fixture.whenStable();
        expect(location.path())
         .toBe('/testUrl');
    }))

The fact is that if I rewrite it like this:
this.router.navigate(['.', 'testUrl']);
Then my test will still pass. How to write a test that could be sure that it moved up one level (relatively) and went into urd

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question