Created
July 21, 2017 14:26
-
-
Save vsavkin/0a81482f7758d6829c49df96b8e538a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { MovieShowingsComponent } from './movie-showings.component'; | |
| import { cold, getTestScheduler } from 'jasmine-marbles'; | |
| describe('MovieShowingsComponent', () => { | |
| it('should not have a race condition', () => { | |
| const backend = jasmine.createSpyObj('backend', ['getShowings']); | |
| const cmp = new MovieShowingsComponent(backend); | |
| backend.getShowings.and.returnValue(cold('--x|', {x: ['10am']})); | |
| cmp.selectMovie('After the Storm'); | |
| backend.getShowings.and.returnValue(cold('-y|', {y: ['11am']})); | |
| cmp.selectMovie('Paterson'); | |
| // this will flush all observables | |
| getTestScheduler().flush(); | |
| expect(cmp.movieTitle).toEqual('Paterson'); | |
| expect(cmp.showings).toEqual(['11am']); // This will fail because showings is ['10am']. | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment