-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
016260f
commit a816096
Showing
11 changed files
with
6,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = class calculator { | ||
add(num1, num2) { | ||
return num1 + num2; | ||
} | ||
subtract(num1, num2) { | ||
return num1 - num2; | ||
} | ||
divide(num1, num2) { | ||
if (num2 === 0) { | ||
return undefined; | ||
} else { | ||
return num1 / num2; | ||
} | ||
} | ||
multiply(num1, num2) { | ||
return num1 * num2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const Calculator = require('./calculator'); | ||
|
||
const calc = new Calculator(); | ||
|
||
describe('addition', () => { | ||
test('Add numbers', () => { | ||
expect(calc.add(2, 3)).toBe(5); | ||
expect(calc.add(10, 20)).toBe(30); | ||
expect(calc.add(-10, 5)).toBe(-5); | ||
}); | ||
}); | ||
|
||
describe('substraction', () => { | ||
test('subtract numbers', () => { | ||
expect(calc.subtract(2, 3)).toBe(-1); | ||
expect(calc.subtract(20, 10)).toBe(10); | ||
expect(calc.subtract(-10, 5)).toBe(-15); | ||
}); | ||
}); | ||
|
||
describe('division', () => { | ||
test('division of numbers', () => { | ||
expect(calc.divide(2, 0)).toBeUndefined(); | ||
expect(calc.divide(10, 20)).toBe(0.5); | ||
expect(calc.divide(-10, 5)).toBe(-2); | ||
}); | ||
}); | ||
|
||
describe('multiolication', () => { | ||
test('Multiply numbers', () => { | ||
expect(calc.multiply(2, 3)).toBe(6); | ||
expect(calc.multiply(10, 20)).toBe(200); | ||
expect(calc.multiply(0, 5)).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function capitalize(str) { | ||
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const capitalize = require('./capital'); | ||
|
||
test('Capitalize First Letter', () => { | ||
expect(capitalize('pakistan')).toBe('Pakistan'); | ||
expect(capitalize('multan')).toBe('Multan'); | ||
expect(capitalize('tahseen')).toBe('Tahseen'); | ||
}); |
Oops, something went wrong.