diff --git a/src/exercises/divide/index.test.ts b/src/exercises/divide/index.test.ts index 62d160e..b748fd5 100644 --- a/src/exercises/divide/index.test.ts +++ b/src/exercises/divide/index.test.ts @@ -1,17 +1,26 @@ -import {divide} from "./index"; +import { divide } from "./index"; -describe("Test multiply", () => { - it.each([ - { a: 2, b : 1, expected: 2 }, - ])( - "should return multiplication of A by B", - ({ a, b, expected }) => { +describe("Test divide", () => { + it.each([ + { a: 2, b: 1, expected: 2 }, + { a: 10, b: 2, expected: 5 }, + { a: 50, b: 5, expected: 10 }, + ])( + "should return division of $b by $a", + ({ a, b, expected }) => { + // act + const result = divide(a, b); + // assert + expect(result).toEqual(expected); + console.log(`Test with a = ${a}, b = ${b}, expected = ${expected}, result = ${result}`); + } + ); + + it("should throw an exception when dividing by zero", () => { // arrange - // act - const result = divide(a,b); - // assert - expect(result).toEqual(expected); - } - ); -}); - + const a = 7; + const b = 0; + // act & assert + expect(() => divide(a, b)).toThrow("Division by zero"); + }); +}); \ No newline at end of file diff --git a/src/exercises/multiply/index.test.ts b/src/exercises/multiply/index.test.ts index 15db8df..387d404 100644 --- a/src/exercises/multiply/index.test.ts +++ b/src/exercises/multiply/index.test.ts @@ -2,15 +2,19 @@ import {multiply} from "./index"; describe("Test multiply", () => { it.each([ - { a: 1, b : 2, expected: 2 }, + { a: 1, b : 2, expected: 2 }, + { a: 6, b : 7, expected: 42 }, + { a: 10, b : 5, expected: 50 }, + { a: 0, b : 5, expected: 0}, ])( - "should return multiplication of A by B", + `should return multiplication of $a by $b`, ({ a, b, expected }) => { // arrange // act const result = multiply(a,b); // assert expect(result).toEqual(expected); + console.log(`Test with a = ${a}, b = ${b}, expected = ${expected}, result = ${result}`); } ); });