You can use jasmine as follows:
describe("Eating - Table like Tests", function () {
var testCasesTable = [[12, 5, 7], [20, 5, 15], [7, 3, 4]];
var eating = function (start, eat) {
return start - eat;
};
var eatingTest = function (start, eat, left) {
it('Given there are ' + start + ' cucumbers, When I eat ' + eat + ' cucumbers, Then I should have ' + left + ' cucumbers', function () {
expect(eating(start, eat)).toBe(left);
});
};
testCasesTable.forEach(function (testCase) {
eatingTest(testCase[0], testCase[1], testCase[2]);
}
);
});
source
share