debut td
This commit is contained in:
parent
c58e016374
commit
62b7182133
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,2 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
.idea/inspectionProfiles/
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
5268
package-lock.json
generated
5268
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
src/exercises/divide/index.test.ts
Normal file
17
src/exercises/divide/index.test.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
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 }) => {
|
||||||
|
// arrange
|
||||||
|
// act
|
||||||
|
const result = divide(a,b);
|
||||||
|
// assert
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
13
src/exercises/divide/index.ts
Normal file
13
src/exercises/divide/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
async function start() {
|
||||||
|
console.log("Application starts...");
|
||||||
|
|
||||||
|
console.log("Application ends...");
|
||||||
|
}
|
||||||
|
|
||||||
|
start();
|
||||||
|
export function divide (a : number, b : number) : number {
|
||||||
|
if (b === 0) {
|
||||||
|
throw new Error('Division by zero');
|
||||||
|
}
|
||||||
|
return a/b;
|
||||||
|
}
|
17
src/exercises/multiply/index.test.ts
Normal file
17
src/exercises/multiply/index.test.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import {multiply} from "./index";
|
||||||
|
|
||||||
|
describe("Test multiply", () => {
|
||||||
|
it.each([
|
||||||
|
{ a: 1, b : 2, expected: 2 },
|
||||||
|
])(
|
||||||
|
"should return multiplication of A by B",
|
||||||
|
({ a, b, expected }) => {
|
||||||
|
// arrange
|
||||||
|
// act
|
||||||
|
const result = multiply(a,b);
|
||||||
|
// assert
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
11
src/exercises/multiply/index.ts
Normal file
11
src/exercises/multiply/index.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
async function start() {
|
||||||
|
console.log("Application starts...");
|
||||||
|
|
||||||
|
console.log("Application ends...");
|
||||||
|
}
|
||||||
|
|
||||||
|
start();
|
||||||
|
|
||||||
|
export function multiply (a : number, b : number) : number {
|
||||||
|
return a*b;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user