Skip to content

Commit 74bf53c

Browse files
Write test case for addAll operation to sum infinite numbers
1 parent a4d8915 commit 74bf53c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

operations/operations.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const add = (a, b) => {
1+
const add = function (a, b){
22
return (typeof a === "number" && typeof b === "number") ?
33
a + b :
44
false;
55
}
66

7-
8-
module.exports = { add }

operations/operations.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { add } = require("./operations");
1+
const { add, addAll } = require("./operations");
22

33
//Testing Add implementation
44
describe("Testing Add implementation", () => {
@@ -11,4 +11,17 @@ describe("Testing Add implementation", () => {
1111
it("Parameter should only be Numbers", () => {
1212
expect(add(3, "4")).toBeFalsy();
1313
});
14+
});
15+
16+
//Testing for AddAll Operation
17+
describe("Add operation for Infinite numbers", () => {
18+
it("Addition of 1 and 1 equals 2", () => {
19+
expect(add([1, 1])).toBe(2);
20+
});
21+
it("Addition of multiple value", () => {
22+
expect(add([1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10])).toBe(385);
23+
});
24+
it("Parameter should only be Numbers", () => {
25+
expect(add([" ", 2, 3, 4, 5, 6, 7, 8, 8, 9, 10])).toBeFalsy();
26+
});
1427
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy