mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-28 11:03:35 +01:00
Add tests for utils.hex2rgb
This commit is contained in:
parent
46dd1a9853
commit
ac273b2409
28
src/utils.spec.js
Normal file
28
src/utils.spec.js
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
const utils = require('./utils');
|
||||
|
||||
describe('utils', () => {
|
||||
describe('hex2rgb', () => {
|
||||
test('#ff0000', () => {
|
||||
expect(utils.hex2rgb('#ff0000')).toEqual([255,0,0]);
|
||||
});
|
||||
test('#ffff00', () => {
|
||||
expect(utils.hex2rgb('#ffff00')).toEqual([255,255,0]);
|
||||
});
|
||||
test('#0000ff', () => {
|
||||
expect(utils.hex2rgb('#0000ff')).toEqual([0,0,255]);
|
||||
});
|
||||
test('#112233', () => {
|
||||
expect(utils.hex2rgb('#112233')).toEqual([17,34,51]);
|
||||
});
|
||||
test('#888', () => {
|
||||
expect(utils.hex2rgb('#888')).toEqual([136,136,136]);
|
||||
});
|
||||
test('33', () => {
|
||||
function wrapper() {
|
||||
utils.hex2rgb('33');
|
||||
}
|
||||
expect(wrapper).toThrowError('isn\'t a supported hex color');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user