Created
September 23, 2016 21:40
-
-
Save jepetko/2ddc88dd0a86728e01750ec4e6cb9e9f to your computer and use it in GitHub Desktop.
This file contains 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
describe('change detection', () => { | |
let failure = 'There should be the exception: Expression has changed after it was checked'; | |
let spy: any; | |
let myIt: any; | |
beforeEach(() => { | |
fixture.autoDetectChanges(true); | |
patchChangeDetection(); | |
let errHandler = (err: any) => { | |
myIt.result.failedExpectations = []; // clear the failed expectations. fail again ... | |
if (err.error.message.indexOf('Expression has changed after it was checked') === -1) { | |
fail(failure); | |
} | |
}; | |
spy = jasmine.createSpy('errHandler', errHandler).and.callThrough(); | |
}); | |
myIt = it(`throws a "change detection error" if the fruit price > 100 | |
and and the user does not provide a budget value`, () => { | |
fillValue('#budget', 100); | |
fillValue('#fruit0', 100); // apples | |
fixture.ngZone.onError.subscribe(spy); | |
clearBudgetAndLeave(); | |
expect(spy.calls.count()).toBe(1, failure); // error occurred => spec passed | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment