UNPKG

@gameroom/gameroom-kit

Version:

Node kit for the Gameroom API

53 lines (51 loc) 1.54 kB
const chai = require('chai'), should = chai.should(), faker = require('faker'), { lib } = require('../../'), { Color } = lib; describe('Color', () => { describe('new Color()', () => { it('should create a new random Color', () => { const color = new Color(); should.exist(color); }); }); describe('new Color(hex)', () => { it('should create a new Color with provided value', () => { const hex = '#a145fe'; const color = new Color(hex); should.exist(color); should.equal(color == hex, true); }); }); describe('new Color({ r, g, b })', () => { it('should create a new Color with provided value', () => { const object = { r: 100, g: 255, b: 10 }; const color = new Color(object); should.exist(color); }); }); describe('Color.random()', () => { it('should create a random new Color', () => { const color = Color.random(); should.exist(color); should.equal(color.length, 7); }); }); describe('color.toRGB()', () => { it('should return rgb object', () => { const object = { r: 100, g: 255, b: 10 }; const rgb = new Color(object).toRGB(); should.exist(rgb); rgb.should.deep.equal({ r: 100, g: 255, b: 10 }); }); }); describe('color.toRGBString()', () => { it('should return rgb string', () => { const object = { r: 100, g: 255, b: 10 }; const rgb = new Color(object).toRGBString(); should.exist(rgb); rgb.should.equal('rgb(100, 255, 10)'); }); }); });