|
| 1 | +/* eslint-disable no-undef */ |
| 2 | +import { ArgumentConverter } from '@/ArgumentConverter'; |
| 3 | + |
| 4 | +// Tests that convertToPrimitive method returns the same string value and isHtml property is false when string argument is passed. |
| 5 | +it('converts to primitive with a string argument', () => { |
| 6 | + const str = 'test string'; |
| 7 | + const result = ArgumentConverter.convertToPrimitive(str); |
| 8 | + expect(result.value).toBe(str); |
| 9 | + expect(result.isHtml).toBe(false); |
| 10 | +}); |
| 11 | + |
| 12 | +// Tests that convertToPrimitive method returns the same number value and isHtml property is false when number argument is passed. |
| 13 | +it('converts to primitive with a number argument', () => { |
| 14 | + const num = 123; |
| 15 | + const result = ArgumentConverter.convertToPrimitive(num); |
| 16 | + expect(result.value).toBe(num); |
| 17 | + expect(result.isHtml).toBe(false); |
| 18 | +}); |
| 19 | + |
| 20 | +// Tests that convertToPrimitive method returns the same boolean value and isHtml property is false when boolean argument is passed. |
| 21 | +it('convert to primitive with a boolean argument', () => { |
| 22 | + const bool = true; |
| 23 | + const result = ArgumentConverter.convertToPrimitive(bool); |
| 24 | + expect(result.value).toBe(bool); |
| 25 | + expect(result.isHtml).toBe(false); |
| 26 | +}); |
| 27 | + |
| 28 | +// Tests that convertToPrimitive returns null value and isHtml=false when argument is null. |
| 29 | +it('convert to primitive with a null argument', () => { |
| 30 | + const arg = null; |
| 31 | + const result = ArgumentConverter.convertToPrimitive(arg); |
| 32 | + |
| 33 | + expect(result.value).toBeNull(); |
| 34 | + expect(result.isHtml).toBe(false); |
| 35 | +}); |
0 commit comments