Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
96197e4
test calculator pr
Ayobamiu Aug 30, 2025
65079f9
Add division function to calculator utility
Ayobamiu Aug 30, 2025
34243ff
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
8951de0
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
d549c17
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
64fc268
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
b5e4e48
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
9afab3b
Merge b5e4e48931b54d3e58a7f3c010668641bbd7abfd into 5c8f0ffc1b1bb5169…
Ayobamiu Aug 30, 2025
3e2bc41
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 30, 2025
76221e1
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
12343d0
Merge 76221e1c4df375778db492f5bbf397772e384977 into c16a35c5dcff3d88a…
Ayobamiu Aug 30, 2025
ba3ba02
Add auto-generated tests for src/utils/__tests__/calculator.test.ts
github-actions[bot] Aug 30, 2025
3eb20a8
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 30, 2025
8fdea0a
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 30, 2025
0fb4503
Merge 8fdea0a67b5098ba508892395dbd6238369ce066 into 75c8d8f985b31a2da…
Ayobamiu Aug 30, 2025
b3566f4
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 30, 2025
e9c2ac0
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 31, 2025
33a1356
Merge e9c2ac00b1f35eebe09fcf518fe1ae33296971cc into 496b6b434ed0a9611…
Ayobamiu Aug 31, 2025
1c5b47f
Add auto-generated tests for src/utils/__tests__/calculator.test.ts
github-actions[bot] Aug 31, 2025
64f9ec7
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 31, 2025
638803d
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 31, 2025
0cd804d
Merge 638803d5593dfc77de2b23e2bc8c1936623e5f9c into d4963b2daeb11c248…
Ayobamiu Aug 31, 2025
b5884b4
Add auto-generated tests for src/utils/__tests__/calculator.test.ts
github-actions[bot] Aug 31, 2025
6c4c6e0
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 31, 2025
00c69d6
Merge remote-tracking branch 'origin/main' into test-pr-01
Ayobamiu Aug 31, 2025
17642e3
Update calculator utility with subtraction function and clean up test…
Ayobamiu Aug 31, 2025
ab941b3
Merge 17642e337a45d1a2c5d0c6981fe0e4309dae7e95 into a4339f4044cb7a5e2…
Ayobamiu Aug 31, 2025
5c899ab
Add auto-generated tests for src/utils/calculator.ts
github-actions[bot] Aug 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/utils/__tests__/calculator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { add, multiply, divide, subtract } from '../calculator';

describe('Calculator Functions', () => {
describe('add()', () => {
it('should return the sum of two positive numbers', () => {
expect(add(1, 2)).toBe(3);
});

it('should return the sum of a positive and a negative number', () => {
expect(add(1, -2)).toBe(-1);
});

it('should return the sum of two negative numbers', () => {
expect(add(-1, -2)).toBe(-3);
});
});

describe('multiply()', () => {
it('should return the product of two positive numbers', () => {
expect(multiply(2, 3)).toBe(6);
});

it('should return the product of a positive and a negative number', () => {
expect(multiply(2, -3)).toBe(-6);
});

it('should return the product of two negative numbers', () => {
expect(multiply(-2, -3)).toBe(6);
});
});

describe('divide()', () => {
it('should return the quotient of two positive numbers', () => {
expect(divide(6, 3)).toBe(2);
});

it('should return the quotient of a positive and a negative number', () => {
expect(divide(6, -3)).toBe(-2);
});

it('should handle division by zero', () => {
expect(() => divide(6, 0)).toThrowError('Cannot divide by zero');
});
});

describe('subtract()', () => {
it('should return the difference of two positive numbers', () => {
expect(subtract(5, 3)).toBe(2);
});

it('should return the difference of a positive and a negative number', () => {
expect(subtract(5, -3)).toBe(8);
});

it('should return the difference of two negative numbers', () => {
expect(subtract(-5, -3)).toBe(-2);
});
});
});
16 changes: 16 additions & 0 deletions src/utils/calculator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// src/utils/calculator.ts
export function add(a: number, b: number): number {
return a + b;
}

export function multiply(a: number, b: number): number {
return a * b;
}

export function divide(a: number, b: number): number {
return a / b;
}

export function subtract(a: number, b: number): number {
return a - b;
}