Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jasmine test multiple values with one spec asyncly
describe("A calculator", function() {
it("should square correctly", function(done) {
[
{ number: 2, answer: 4},
{ number: 3, answer: 9},
{ number: 4, answer: 16}
].forEach(function(problem, index, array){
// we will pretend to calculate with our fnc here
setTimeout(function(){
var calcAnswer = problem.number*problem.number;
expect(calcAnswer).toEqual(problem.answer);
// once we have finished checking the values, we can call done
if (index === (array.length-1)){
done();
}
},100);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.