Created
September 13, 2011 19:01
-
-
Save nathanic/1214725 to your computer and use it in GitHub Desktop.
jasmine BDD example
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("Player", function() { | |
var player; | |
// hook before each test | |
beforeEach(function(){ | |
player = new Player(); | |
spyOn(loading,'show'); // intercept and record calls to loading.show | |
player.play(); | |
}); | |
// actual specifications/tests | |
it('shows a loading indicator',function(){ | |
expect(loading.show).toHaveBeenCalled(); | |
}); | |
it('plays',function(){ | |
expect(player.isPlaying).toBe(true); | |
}); | |
// specs may be nested recursively | |
describe('pausing',function(){ | |
beforeEach(function(){ | |
player.pause(); | |
}); | |
it('pauses',function() { | |
expect(player).not.toBePlaying(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note:
toBePlaying
is implemented as a custom expect hook in another file.