Skip to content

Commit

Permalink
Merge pull request JS-Challenges#45 from mybrainishuge/master
Browse files Browse the repository at this point in the history
Add test cases for multiply prompt
  • Loading branch information
mybrainishuge authored Nov 4, 2016
2 parents e784608 + 3e2cf39 commit 8ebe636
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions spec/part1.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,40 @@
expect(multiply.toString()).to.not.contain('Math');
});

it('should return the product of two integers', function() {
expect(multiply(2, 1)).to.equal(2 * 1);
it('should return the product of two positive integers', function() {
expect(multiply(1, 2)).to.equal(1 * 2);
expect(multiply(2, 1)).to.equal(1 * 2);
expect(multiply(5, 17)).to.equal(5 * 17);
expect(multiply(17, 5)).to.equal(17 * 5);
expect(multiply(78, 453)).to.equal(78 * 453);
expect(multiply(-79, 82)).to.equal(-79 * 82);
expect(multiply(-275, -502)).to.equal(-275 * -502);
expect(multiply(453, 78)).to.equal(78 * 453);
expect(multiply(0, 32)).to.equal(0 * 32);
expect(multiply(32, 0)).to.equal(0 * 32);
expect(multiply(0, 0)).to.equal(0 * 0);
});

it('should return the product of two negative integers', function() {
expect(multiply(-79, -82)).to.equal(-79 * -82);
expect(multiply(-275, -502)).to.equal(-275 * -502);
expect(multiply(-2, -2)).to.equal(-2 * -2);
expect(multiply(-8, -3)).to.equal(-8 * -3);
expect(multiply(-12, -10)).to.equal(-12 * -10);
expect(multiply(-22, -3)).to.equal(-22 * -3);
expect(multiply(-5, -27)).to.equal(-5 * -27);
});

it('should return the product of mixed positive and negative integers', function() {
expect(multiply(-79, 82)).to.equal(-79 * 82);
expect(multiply(79, -82)).to.equal(79 * -82);
expect(multiply(-275, 502)).to.equal(-275 * 502);
expect(multiply(275, -502)).to.equal(275 * -502);
expect(multiply(2, -2)).to.equal(2 * -2);
expect(multiply(-8, 3)).to.equal(-8 * 3);
expect(multiply(12, -10)).to.equal(12 * -10);
expect(multiply(-22, 3)).to.equal(-22 * 3);
expect(multiply(5, -27)).to.equal(5 * -27);
});

it('should use recursion by calling self', function () {
var originalMultiply = multiply;
multiply = sinon.spy(multiply);
Expand Down

0 comments on commit 8ebe636

Please sign in to comment.