summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-06-28 18:39:23 +1200
committerFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-06-28 18:39:23 +1200
commit24441e19868c5bb9f8efd404f23c3ae02267e5ce (patch)
treed972b10069d404b5cf7ff6385c22842f9b9792c0
parent1ff81edeef89954d1cb97cbe4e63356b6506dac9 (diff)
downloadmanaportal-24441e19868c5bb9f8efd404f23c3ae02267e5ce.tar.gz
manaportal-24441e19868c5bb9f8efd404f23c3ae02267e5ce.tar.bz2
manaportal-24441e19868c5bb9f8efd404f23c3ae02267e5ce.tar.xz
manaportal-24441e19868c5bb9f8efd404f23c3ae02267e5ce.zip
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?
-rw-r--r--test/mp/dye.js31
-rw-r--r--test/mp/future.js12
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", {