Created
September 22, 2014 08:28
-
-
Save gajus/d75de7f3fdbfd6486d6a to your computer and use it in GitHub Desktop.
"Example Factory" a factory method used to instantiate the SUT object with canonical values, overwriting only the properties relevant to the test case.
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
var SeminarFactory = { | |
create: function (overwrite) { | |
var defaultData, | |
objectData; | |
defaultData = { | |
name: 'JavaScript basics', | |
price: 100 | |
}; | |
objectData = Object.extend(defaultData, overwrite); | |
return Seminar.create(objectData.name, objectData.price); | |
} | |
}; | |
describe('Seminar', function () { | |
it('has a name', function () { | |
var seminar = SeminarFactory.create({name: 'JavaScript'}); | |
expect(seminar.getName()).toEqual('JavaScript'); | |
}); | |
it('has a price', function () { | |
var seminar = SeminarFactory.create({price: 10}); | |
expect(seminar.getPrice()).toEqual(10); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment