Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. describe('Router tests', () => {
  2. //setup
  3. beforeEach(() => {
  4. TestBed.configureTestingModule({
  5. imports: [
  6. RouterTestingModule.withRoutes(routes),
  7. AppModule
  8. ]
  9. });
  10. });
  11.  
  12. //specs
  13. it('can navigate to home (async)', async(() => {
  14. let fixture = TestBed.createComponent(TestComponent);
  15. TestBed.get(Router)
  16. .navigate(['/home'])
  17. .then(() => {
  18. expect(location.pathname.endsWith('/home')).toBe(true);
  19. }).catch(e => console.log(e));
  20. }));
  21.  
  22. it('can navigate to home (fakeAsync/tick)', fakeAsync(() => {
  23. let fixture = TestBed.createComponent(TestComponent);
  24. TestBed.get(Router).navigate(['/home']);
  25. fixture.detectChanges();
  26. //execute all pending asynchronous calls
  27. tick();
  28. expect(location.pathname.endsWith('/home')).toBe(true);
  29. }));
  30.  
  31. it('can navigate to home (done)', done => {
  32. let fixture = TestBed.createComponent(TestComponent);
  33. TestBed.get(Router)
  34. .navigate(['/home'])
  35. .then(() => {
  36. expect(location.pathname.endsWith('/home')).toBe(true);
  37. done();
  38. }).catch(e => console.log(e));
  39. });
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement