From 599fda2f11c88b2c18d0cd0b57d4adeca20db2eb Mon Sep 17 00:00:00 2001 From: Saivan Date: Sun, 25 Nov 2018 16:23:35 +1300 Subject: Updated all of the color modules and old tests are passing again This commit updates the color modules, so that the old tests pass, we just need to modify the tests to test some of the new functionality (Since there was a lot of copy and paste work done haha) Changes ======= - Updated the color module to support a number of color spaces - Made sure all of the old tests are working again --- spec/SpecRunner.html | 8 ++--- spec/spec/color.js | 100 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 31 deletions(-) (limited to 'spec') diff --git a/spec/SpecRunner.html b/spec/SpecRunner.html index 9d84677..967f327 100644 --- a/spec/SpecRunner.html +++ b/spec/SpecRunner.html @@ -54,15 +54,15 @@ - + - + diff --git a/spec/spec/color.js b/spec/spec/color.js index 410577f..9710d69 100644 --- a/spec/spec/color.js +++ b/spec/spec/color.js @@ -1,3 +1,4 @@ + describe('Color', function() { var color @@ -5,42 +6,87 @@ describe('Color', function() { color = new SVG.Color({ r: 0, g: 102, b: 255 }) }) - it('correclty parses a rgb string', function() { - color = new SVG.Color('rgb(255,0,128)') - expect(color.r).toBe(255) - expect(color.g).toBe(0) - expect(color.b).toBe(128) - }) + describe ('construct: constructs a color in different formats', () => { - it('correclty parses a 3 digit hex string', function() { - color = new SVG.Color('#f06') - expect(color.r).toBe(255) - expect(color.g).toBe(0) - expect(color.b).toBe(102) - }) + it ('constructs a color from an object in the correct color space') - it('correclty parses a 6 digit hex string', function() { - color = new SVG.Color('#0066ff') - expect(color.r).toBe(0) - expect(color.g).toBe(102) - expect(color.b).toBe(255) - }) + it ('constructs a color from an array', () => { + let color = new SVG.Color([ 30, 24, 50 ]) + expect( color.r ).toBe( 30 ) + expect( color.g ).toBe( 24 ) + expect( color.b ).toBe( 50 ) - describe('toHex()', function() { - it('returns a hex color', function() { - expect(color.toHex()).toBe('#0066ff') }) + + it('correclty parses an rgb string', () => { + let color = new SVG.Color('rgb(255,0,128)') + expect(color.r).toBe(255) + expect(color.g).toBe(0) + expect(color.b).toBe(128) + }) + + it('correclty parses a 3 digit hex string', () => { + color = new SVG.Color('#f06') + expect(color.r).toBe(255) + expect(color.g).toBe(0) + expect(color.b).toBe(102) + }) + + it('correclty parses a 6 digit hex string', () => { + color = new SVG.Color('#0066ff') + expect(color.r).toBe(0) + expect(color.g).toBe(102) + expect(color.b).toBe(255) + }) + }) - describe('toRgb()', function() { - it('returns a rgb string color', function() { - expect(color.toRgb()).toBe('rgb(0,102,255)') + describe ('input and output: Importing and exporting colors', () => { + describe('hex()', function() { + it('returns a hex color', function() { + expect(color.hex()).toBe('#0066ff') + }) + }) + + describe('toRgb()', function() { + it('returns a rgb string color', function() { + expect(color.toRgb()).toBe('rgb(0,102,255)') + }) + }) + + describe('brightness()', function() { + it('returns the percieved brightness value of a color', function() { + expect(color.brightness()).toBe(0.346) + }) }) }) - describe('brightness()', function() { - it('returns the percieved brightness value of a color', function() { - expect(color.brightness()).toBe(0.346) + describe('color spaces: The color spaces supported by our library', () => { + + describe('lab()', () => { + it ('can convert rgb to lab') + it ('can convert from lab to rgb') + }) + + describe('lch()', () => { + it ('can convert rgb to lch') + it ('can convert from lch to rgb') + }) + + describe('hsl()', () => { + it ('can convert from rgb to hsl') + it ('can convert from hsl to rgb') + }) + + describe('xyz()', () => { + it ('can convert from rgb to xyz') + it ('can convert from xyz to rgb') + }) + + describe('cymk()', () => { + it ('can convert from rgb to cymk') + it ('can convert from cymk to rgb') }) }) + }) -- cgit v1.2.3