|
1 | | -import { decimalToOctal } from '../DecimalToOctal' |
| 1 | +import { decimalToOctal } from '../DecimalToOctal.js' |
2 | 2 |
|
3 | | -test('The Octal representation of 8 is 10', () => { |
4 | | - const res = decimalToOctal(8) |
5 | | - expect(res).toBe(10) |
6 | | -}) |
| 3 | +describe('decimalToOctal', () => { |
| 4 | + test("decimalToOctal(0) returns '0'", () => { |
| 5 | + expect(decimalToOctal(0)).toBe('0') |
| 6 | + }) |
7 | 7 |
|
8 | | -test('The Octal representation of 1 is 1', () => { |
9 | | - const res = decimalToOctal(1) |
10 | | - expect(res).toBe(1) |
11 | | -}) |
| 8 | + test("decimalToOctal(1) returns '1'", () => { |
| 9 | + expect(decimalToOctal(1)).toBe('1') |
| 10 | + }) |
12 | 11 |
|
13 | | -test('The Octal representation of 0 is 0', () => { |
14 | | - const res = decimalToOctal(0) |
15 | | - expect(res).toBe(0) |
16 | | -}) |
| 12 | + test("decimalToOctal(7) returns '7'", () => { |
| 13 | + expect(decimalToOctal(7)).toBe('7') |
| 14 | + }) |
17 | 15 |
|
18 | | -test('The Octal representation of 100 is 144', () => { |
19 | | - const res = decimalToOctal(100) |
20 | | - expect(res).toBe(144) |
21 | | -}) |
| 16 | + test("decimalToOctal(8) returns '10'", () => { |
| 17 | + expect(decimalToOctal(8)).toBe('10') |
| 18 | + }) |
| 19 | + |
| 20 | + test("decimalToOctal(64) returns '100'", () => { |
| 21 | + expect(decimalToOctal(64)).toBe('100') |
| 22 | + }) |
| 23 | + |
| 24 | + test("decimalToOctal(255) returns '377'", () => { |
| 25 | + expect(decimalToOctal(255)).toBe('377') |
| 26 | + }) |
| 27 | + |
| 28 | + test("decimalToOctal(512) returns '1000'", () => { |
| 29 | + expect(decimalToOctal(512)).toBe('1000') |
| 30 | + }) |
| 31 | + |
| 32 | + test('throws TypeError for negative input', () => { |
| 33 | + expect(() => decimalToOctal(-1)).toThrow(TypeError) |
| 34 | + }) |
| 35 | + |
| 36 | + test('throws TypeError for float input', () => { |
| 37 | + expect(() => decimalToOctal(1.5)).toThrow(TypeError) |
| 38 | + }) |
22 | 39 |
|
23 | | -test('The Octal representation of 111 is 157', () => { |
24 | | - const res = decimalToOctal(111) |
25 | | - expect(res).toBe(157) |
| 40 | + test('throws TypeError for non-number input', () => { |
| 41 | + expect(() => decimalToOctal('8')).toThrow(TypeError) |
| 42 | + }) |
26 | 43 | }) |
0 commit comments