There must be something I'm not understanding about how to use Jasmine spies. I'm putting together curriculum to explain this to students, hence the dummy example.
source:
function addEmotion(str, emotion) {
if (emotion === "excitement") {
addExcitement(str);
} else {
addSadness(str);
}
}
function addExcitement(str) {
return str + "!!!";
}
spec:
describe("addEmotion function", function () {
var addExcitement;
beforeEach(function () {
addExcitement = jasmine.createSpy("addExcitement");
});
it("should call addExcitement when emotion is 'excitement'", function () {
var str = "Hey there";
addEmotion(str, "excitement");
expect(addExcitement).toHaveBeenCalled();
});
});
Sorry in advance if I'm missing something really obvious. I'm still pretty new to Jasmine.
Aucun commentaire:
Enregistrer un commentaire