Jasmine cheat sheet - Matcher toBeTruthy
by lucassus
HTML
<link href="http://blog.bandzarewicz.com/stylesheets/jasmine/jasmine.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="http://blog.bandzarewicz.com/javascripts/jasmine/runner.js"></script>
<script src="http://blog.bandzarewicz.com/javascripts/jasmine/jasmine.js"></script>
<script src="http://blog.bandzarewicz.com/javascripts/jasmine/jasmine-html.js"></script>
JavaScript
describe('toBeTruthy', function() {
it('passes if subject is true', function() {
expect(true).toBeTruthy();
expect(false).not.toBeTruthy();
});
it('passes if subject is a non empty string', function() {
expect('Should pass').toBeTruthy();
});
it('passes if subject is a number not equal 0', function() {
expect(1).toBeTruthy();
});
it('fails if subject is an empty string', function() {
expect('').not.toBeTruthy();
});
it('fails if subject is false', function() {
expect(false).not.toBeTruthy();
});
it('fails if subject is 0', function() {
expect(0).not.toBeTruthy();
});
});
execJasmine();