Skip to content

Commit

Permalink
added test for gray
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Aisch committed Jun 2, 2015
1 parent 11bf38e commit 75feeda
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/cmyk-test.coffee
Expand Up @@ -3,12 +3,17 @@ vows = require 'vows'
assert = require 'assert'
chroma = require '../chroma'

round = (digits) ->
d = Math.pow 10,digits
return (v) ->
Math.round(v*d) / d

vows
.describe('Testing CMYK color conversions')
.addBatch

'export simple colors to CMYK':
topic: ['black','white','red','#0f0','blue','yellow','cyan','magenta']
topic: ['black','white','red','#0f0','blue','yellow','cyan','magenta','gray']
'black': (t) -> assert.deepEqual chroma(t[0]).cmyk(), [0,0,0,1]
'white': (t) -> assert.deepEqual chroma(t[1]).cmyk(), [0,0,0,0]
'red': (t) -> assert.deepEqual chroma(t[2]).cmyk(), [0,1,1,0]
Expand All @@ -17,6 +22,7 @@ vows
'yellow': (t) -> assert.deepEqual chroma(t[5]).cmyk(), [0,0,1,0]
'cyan': (t) -> assert.deepEqual chroma(t[6]).cmyk(), [1,0,0,0]
'magenta': (t) -> assert.deepEqual chroma(t[7]).cmyk(), [0,1,0,0]
'gray': (t) -> assert.deepEqual chroma(t[8]).cmyk().map(round(4)), [0,0,0,0.498]

'parse simple CMYK colors':
topic: [[0,0,0,1],[0,0,0,0],[0,1,1,0],[1,0,1,0],[1,1,0,0],[0,0,1,0],[1,0,0,0],[0,1,0,0]]
Expand Down

0 comments on commit 75feeda

Please sign in to comment.