Skip to content

Instantly share code, notes, and snippets.

@rinatio
Created June 15, 2013 00:03
Show Gist options
  • Save rinatio/5786174 to your computer and use it in GitHub Desktop.
Save rinatio/5786174 to your computer and use it in GitHub Desktop.
Simple Jasmine Tests Reuse Example
define([
'jasmine'
], function() {
describe('Simple Test', function() {
var view, context = {};
beforeEach(function() {
view = 1;
context.view = view;
});
it("Should be 1", function() {
expect(view).toEqual(1);
});
attachBehavior(context);
});
describe('Simple Test 2', function() {
var view, context = {};
beforeEach(function() {
view = 2;
context.view = view;
});
it("Should be 2", function() {
expect(view).toEqual(2);
});
attachBehavior(context);
});
function attachBehavior(context) {
var view;
describe('Greater than zero behavior', function() {
beforeEach(function() {
view = context.view;
});
it("Should be greater than zero", function() {
expect(view).toBeGreaterThan(0);
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment