summaryrefslogtreecommitdiff
path: root/test/mp/dye.js
blob: ac0d9b373600025ee63f3f3c02eb841931c7c072 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";
var vows = require("vows"),
    load = require("../load"),
    assert = require("../assert");

var suite = vows.describe("mp.dye");

suite.addBatch({
    "The manaportal dye": {
        topic: load("mp/dye").expression("mp.dye").document(),
        "getChannel": {
            topic: function(dye) { return dye.getChannel; },
            "returns null given pure black": function(f) {
                assert.equal(f([0,0,0]).channel, null);
            },
            "returns R given a pure red": function(f) {
                assert.equal(f([255,0,0]).channel, "R");
                assert.equal(f([12,0,0]).channel, "R");
            },
            "returns G given a pure green": function(f) {
                assert.equal(f([0,255,0]).channel, "G");
                assert.equal(f([0,50,0]).channel, "G");
            },
            "returns B given a pure blue": function (f) {
                assert.equal(f([0,0,255]).channel, "B");
                assert.equal(f([0,0,23]).channel, "B");
            },
            "returns C given a pure cyan": function (f) {
                assert.equal(f([0,255,255]).channel, "C");
                assert.equal(f([0,90,90]).channel, "C");
            },
            "returns M given a pure magenta": function (f) {
                assert.equal(f([255,0,255]).channel, "M");
                assert.equal(f([62,0,62]).channel, "M");
            },
            "returns Y given a pure yellow": function (f) {
                assert.equal(f([255,255,0]).channel, "Y");
                assert.equal(f([70,70,0]).channel, "Y");
            },
            "returns W given a pure white": function (f) {
                assert.equal(f([255,255,255]).channel, "W");
                assert.equal(f([100,100,100]).channel, "W");
            },
            "returns null given an impure color": function(f) {
                assert.equal(f([12,34,56]).channel, null);
                assert.equal(f([55,53,55]).channel, null);
                assert.equal(f([0,128,254]).channel, null);
            }
        }
    }
});

suite.export(module);