Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1a7b1a

Browse filesBrowse files
Write test cases for Subtraction operation
1 parent 1131bae commit a1a7b1a
Copy full SHA for a1a7b1a

File tree

2 files changed

+17
-2
lines changed
Filter options

2 files changed

+17
-2
lines changed

‎operations/operations.js

Copy file name to clipboardExpand all lines: operations/operations.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ const addAll = function() {
1717
return total;
1818
};
1919

20-
//console.log(addAll(11, false, 3, 4, 5, 6, 7, 8, 8, 9, 10));
2120

2221
module.exports = { add, addAll };

‎operations/operations.test.js

Copy file name to clipboardExpand all lines: operations/operations.test.js
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { add, addAll } = require("./operations");
1+
const { add, addAll, subtract } = require("./operations");
22

33
//Testing Add implementation
44
describe("Testing Add implementation", () => {
@@ -28,3 +28,19 @@ describe("Add operation for Infinite numbers", () => {
2828
expect(logError).toThrowError(Error);
2929
});
3030
});
31+
32+
//Testing Subbtaction implementation
33+
describe("Testing Subbtaction implementation", () => {
34+
it("Subtraction of 1 and 1", () => {
35+
expect(subtract(1, 1)).toBe(0);
36+
});
37+
it("Subtraction of 23 and 50", () => {
38+
expect(subtract(23, 50)).toBe(-27);
39+
});
40+
it("Subtraction of 21 and 111", () => {
41+
expect(subtract(111, 21)).toBe(90);
42+
});
43+
it("Parameter should only be Numbers", () => {
44+
expect(subtract(3, "4")).toBeFalsy();
45+
});
46+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.