Jasmine Example
by ZenMaster
HTML
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine-html.js"></script>
JavaScript
//----------- Setup
var jasmineEnv = jasmine.getEnv();
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
var Component = function() {};
Component.prototype.isActive = function() {
return true;
};
//----------- Tests
describe('A component', function() {
it('can be instatiated via constructor', function() {
expect(function() {
new Component();
}).not.toThrow();
});
it('can be activated upon creation', function() {
var component = new Component();
expect(component.isActive()).toBe(true);
});
});
//----------- Invokation
jasmineEnv.execute();