Skip to content

Instantly share code, notes, and snippets.

@themindfuldev
Created January 18, 2015 02:29
Show Gist options
  • Save themindfuldev/587553f71515682d81f7 to your computer and use it in GitHub Desktop.
Save themindfuldev/587553f71515682d81f7 to your computer and use it in GitHub Desktop.
jasmine-precondition
describe('the preCondition instruction', function () {
var counter1 = 0,
counter2 = 0,
interval;
beforeEach(function(done) {
interval = setInterval(function(){
counter1 += 100;
}, 100);
preCondition(function() {
return counter1 >= 500;
}, done, 100);
});
it('should only get executed when counter1 is 500', function (done) {
expect(counter1).toBe(500);
preCondition(function() {
counter2 += 200;
return counter2 === 1000;
}, done, 100);
});
it('should only get executed when counter2 is 1000', function () {
expect(counter2).toBe(1000);
});
afterEach(function(){
clearInterval(interval);
});
});
preCondition(condition, done, interval);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment