@gameroom/kit
Version:
Node kit for the Gameroom API
64 lines (60 loc) • 1.73 kB
JavaScript
/* eslint eqeqeq: 0 */
const chai = require('chai')
const {
lib: { Color }
} = require('../../')
const should = chai.should()
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)')
})
})
describe('color.toString()', () => {
it('should return string', () => {
const str1 = '#123456'
const str2 = new Color(str1).toString()
should.exist(str2)
str1.should.equal(str2)
})
})
})