Skip to content

Instantly share code, notes, and snippets.

@MichaelSitter
Last active August 29, 2015 14:00
Show Gist options
  • Save MichaelSitter/11385043 to your computer and use it in GitHub Desktop.
Save MichaelSitter/11385043 to your computer and use it in GitHub Desktop.
Suggested jasmine style
require('yourModule', function (sut) {
var testValue, result;
describe('given testValue is 1', function () {
// ARRANGE
beforeEach(function () {
testValue = 1;
});
// ACT
describe('when doIt is called', function () {
beforeEach(function () {
result = sut.doIt(testValue);
});
// ASSERT
it('should return "foo"', function () {
expect(result).toBe('foo');
});
});
// ACT
describe('when doTheOtherThing is called', function () {
beforeEach(function() {
result = sut.doTheOtherThing(testValue);
});
// ASSERT
it('should return "bar"', function () {
expect(result).toBe('bar');
});
});
// ARRANGE
describe('and given some other option', function () {
var someOtherOption;
beforeEach(function () {
someOtherOption = true;
});
// ACT
describe('when doTheLastThing', function () {
beforeEach(function () {
result = sut.doTheLastThing(testValue, someOtherOption);
});
// ASSERT
it('result should be true', function () {
expect(result).toBeTrue();
});
});
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment