Last active
August 29, 2015 14:00
-
-
Save MichaelSitter/11385043 to your computer and use it in GitHub Desktop.
Suggested jasmine style
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
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