|
1 | | -import binaryToDecimal from '../BinaryToDecimal' |
| 1 | +import { binaryToDecimal } from '../BinaryToDecimal.js' |
2 | 2 |
|
3 | | -describe('BinaryToDecimal', () => { |
4 | | - it('expects to return correct decimal value', () => { |
5 | | - expect(binaryToDecimal('1000')).toBe(8) |
| 3 | +describe('binaryToDecimal', () => { |
| 4 | + test("binaryToDecimal('0') returns 0", () => { |
| 5 | + expect(binaryToDecimal('0')).toBe(0) |
6 | 6 | }) |
7 | 7 |
|
8 | | - it('expects to return correct hexadecimal value for more than one hex digit', () => { |
9 | | - expect(binaryToDecimal('01101000')).toBe(104) |
| 8 | + test("binaryToDecimal('1') returns 1", () => { |
| 9 | + expect(binaryToDecimal('1')).toBe(1) |
10 | 10 | }) |
11 | 11 |
|
12 | | - it('expects to return correct hexadecimal value for padding-required binary', () => { |
13 | | - expect(binaryToDecimal('1000101')).toBe(69) |
| 12 | + test("binaryToDecimal('1010') returns 10", () => { |
| 13 | + expect(binaryToDecimal('1010')).toBe(10) |
| 14 | + }) |
| 15 | + |
| 16 | + test("binaryToDecimal('1111') returns 15", () => { |
| 17 | + expect(binaryToDecimal('1111')).toBe(15) |
| 18 | + }) |
| 19 | + |
| 20 | + test("binaryToDecimal('100000') returns 32", () => { |
| 21 | + expect(binaryToDecimal('100000')).toBe(32) |
| 22 | + }) |
| 23 | + |
| 24 | + test("binaryToDecimal('11111111') returns 255", () => { |
| 25 | + expect(binaryToDecimal('11111111')).toBe(255) |
| 26 | + }) |
| 27 | + |
| 28 | + test('throws TypeError for non-binary string', () => { |
| 29 | + expect(() => binaryToDecimal('1012')).toThrow(TypeError) |
| 30 | + }) |
| 31 | + |
| 32 | + test('throws TypeError for empty string', () => { |
| 33 | + expect(() => binaryToDecimal('')).toThrow(TypeError) |
| 34 | + }) |
| 35 | + |
| 36 | + test('throws TypeError for non-string input', () => { |
| 37 | + expect(() => binaryToDecimal(1010)).toThrow(TypeError) |
14 | 38 | }) |
15 | 39 | }) |
0 commit comments