DecimalToHex

- Add test file DecimalToHex.test.js
- Add export to DecimalToHex.js
- Remove console.log from DecimalToHex.js
This commit is contained in:
TrasherDK
2021-10-03 12:11:34 +02:00
parent c0fa45cc19
commit c35b20a4ce
2 changed files with 18 additions and 5 deletions

View File

@@ -0,0 +1,15 @@
import { decimalToHex } from '../DecimalToHex'
describe('DecimalToHex', () => {
it('expects to return correct hexadecimal value', () => {
expect(decimalToHex(255)).toBe('FF')
})
it('expects to return correct hexadecimal value, matching (num).toString(16)', () => {
expect(decimalToHex(32768)).toBe((32768).toString(16).toUpperCase())
})
it('expects to not handle negative numbers', () => {
expect(decimalToHex(-32768)).not.toBe((-32768).toString(16).toUpperCase())
})
})