From 24441e19868c5bb9f8efd404f23c3ae02267e5ce Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Fri, 28 Jun 2013 18:39:23 +1200 Subject: Move tests for dyestring parse and reconstruct It all seems to be working now, and should be considered stable. Should parseColor really belong in the resource manager? --- test/mp/dye.js | 31 ++++++++++++++++++++++++++++--- test/mp/future.js | 12 ------------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/test/mp/dye.js b/test/mp/dye.js index ac0d9b3..b0f6175 100644 --- a/test/mp/dye.js +++ b/test/mp/dye.js @@ -5,11 +5,28 @@ var vows = require("vows"), var suite = vows.describe("mp.dye"); +var dyeString = "R:#ede5b2,fff7bf;G:#cccccc,ffffff"; +var dyeData = { + "R": [ + [0xed, 0xe5, 0xb2], + [0xff, 0xf7, 0xbf] + ], + "G": [ + [0xcc, 0xcc, 0xcc], + [0xff, 0xff, 0xff] + ] +}; + + +function testDyeParse(expected, input, mp) { + assert.dyeDataEqual(mp.dye.parseDyeString(input), expected); +} + suite.addBatch({ "The manaportal dye": { - topic: load("mp/dye").expression("mp.dye").document(), + topic: load("mp/dye", "mp/resource").expression("mp").document(), "getChannel": { - topic: function(dye) { return dye.getChannel; }, + topic: function(mp) { return mp.dye.getChannel; }, "returns null given pure black": function(f) { assert.equal(f([0,0,0]).channel, null); }, @@ -46,7 +63,15 @@ suite.addBatch({ assert.equal(f([55,53,55]).channel, null); assert.equal(f([0,128,254]).channel, null); } - } + }, + "parseDyeString": { + "extracts the dye channel data from the dyestring": testDyeParse.bind(null, dyeData, dyeString) + }, + "asDyeString": { + "reconstructs the dyestring from the dye channel data": function(mp) { + assert.equal(mp.dye.asDyeString(dyeData), dyeString); + } + }, } }); diff --git a/test/mp/future.js b/test/mp/future.js index 735342e..abcdffe 100644 --- a/test/mp/future.js +++ b/test/mp/future.js @@ -33,10 +33,6 @@ function unshiftLoadImageBind(url, tests) { return tests; } -function testDyeParse(expected, input, mp) { - assert.dyeDataEqual(mp.dye.parseDyeString(input), expected); -} - function testDye(err, dyed, dyeable, mp) { var input = dyeable.data; var expected = dyed.data; @@ -48,14 +44,6 @@ function testDye(err, dyed, dyeable, mp) { suite.addBatch({ "The manaportal dye": { topic: load("mp/dye", "mp/resource").expression("mp").document(), - "parseDyeString": { - "extracts the dye channel data from the dyestring": testDyeParse.bind(null, dyeData, dyeString) - }, - "asDyeString": { - "reconstructs the dyestring from the dye channel data": function(mp) { - assert.equal(mp.dye.asDyeString(dyeData), dyeString); - } - }, "dyeImage": { "with the big recolorable cake": unshiftLoadImageBind("test/data/bigcake.png", { "to the big white cake dyed by TMWW": unshiftLoadImageBind("test/data/whitecake.png", { -- cgit v1.2.3-60-g2f50