Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import { MovieShowingsComponent } from './movie-showings.component';
  2. import { cold, getTestScheduler } from 'jasmine-marbles';
  3.  
  4. describe('MovieShowingsComponent', () => {
  5. it('should not have a race condition', () => {
  6. const backend = jasmine.createSpyObj('backend', ['getShowings']);
  7. const cmp = new MovieShowingsComponent(backend);
  8.  
  9. backend.getShowings.and.returnValue(cold('--x|', {x: ['10am']}));
  10. cmp.selectMovie('After the Storm');
  11.  
  12. backend.getShowings.and.returnValue(cold('-y|', {y: ['11am']}));
  13. cmp.selectMovie('Paterson');
  14.  
  15. // this will flush all observables
  16. getTestScheduler().flush();
  17.  
  18. expect(cmp.movieTitle).toEqual('Paterson');
  19. expect(cmp.showings).toEqual(['11am']); // This will fail because showings is ['10am'].
  20. });
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement