|
| 1 | +import { leastCommonMultiple } from '../LeastCommonMultiple.js' |
| 2 | + |
| 3 | +describe('leastCommonMultiple', () => { |
| 4 | + test('leastCommonMultiple(4, 6) returns 12', () => { |
| 5 | + expect(leastCommonMultiple(4, 6)).toBe(12) |
| 6 | + }) |
| 7 | + |
| 8 | + test('leastCommonMultiple(12, 15) returns 60', () => { |
| 9 | + expect(leastCommonMultiple(12, 15)).toBe(60) |
| 10 | + }) |
| 11 | + |
| 12 | + test('leastCommonMultiple(7, 5) returns 35', () => { |
| 13 | + expect(leastCommonMultiple(7, 5)).toBe(35) |
| 14 | + }) |
| 15 | + |
| 16 | + test('leastCommonMultiple(1, 1) returns 1', () => { |
| 17 | + expect(leastCommonMultiple(1, 1)).toBe(1) |
| 18 | + }) |
| 19 | + |
| 20 | + test('leastCommonMultiple of same numbers returns that number', () => { |
| 21 | + expect(leastCommonMultiple(5, 5)).toBe(5) |
| 22 | + }) |
| 23 | + |
| 24 | + test('leastCommonMultiple(3, 4) returns 12', () => { |
| 25 | + expect(leastCommonMultiple(3, 4)).toBe(12) |
| 26 | + }) |
| 27 | + |
| 28 | + test('leastCommonMultiple(100, 75) returns 300', () => { |
| 29 | + expect(leastCommonMultiple(100, 75)).toBe(300) |
| 30 | + }) |
| 31 | + |
| 32 | + test('throws TypeError for zero input', () => { |
| 33 | + expect(() => leastCommonMultiple(0, 5)).toThrow(TypeError) |
| 34 | + }) |
| 35 | + |
| 36 | + test('throws TypeError for negative input', () => { |
| 37 | + expect(() => leastCommonMultiple(-4, 6)).toThrow(TypeError) |
| 38 | + }) |
| 39 | + |
| 40 | + test('throws TypeError for float input', () => { |
| 41 | + expect(() => leastCommonMultiple(4.5, 6)).toThrow(TypeError) |
| 42 | + }) |
| 43 | +}) |
0 commit comments