diff options
author | Eric Guzman | 2012-08-20 14:54:44 -0700 |
---|---|---|
committer | Eric Guzman | 2012-08-20 14:54:44 -0700 |
commit | 1e9d019867ff90840735ec531af5ebec9c7962e6 (patch) | |
tree | 887d28987a3113e84c771e264767c9462e9a8844 /tests/unit-tests/color-model-test.js | |
parent | a34663e154af834176b758b6da368f634cd2a6bd (diff) | |
parent | 36d692a9fb216f2785a570d13c1beb27360c7305 (diff) | |
download | ninja-1e9d019867ff90840735ec531af5ebec9c7962e6.tar.gz |
Merge branch 'refs/heads/master' into minorFixes_7.1
Diffstat (limited to 'tests/unit-tests/color-model-test.js')
-rw-r--r-- | tests/unit-tests/color-model-test.js | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/tests/unit-tests/color-model-test.js b/tests/unit-tests/color-model-test.js new file mode 100644 index 00000000..d596445b --- /dev/null +++ b/tests/unit-tests/color-model-test.js | |||
@@ -0,0 +1,130 @@ | |||
1 | var Montage = require("montage/core/core").Montage; | ||
2 | |||
3 | var cmObject = require("ninjaapp/js/models/color-model"), | ||
4 | cm = cmObject.ColorModel; | ||
5 | |||
6 | console.log(cm); | ||
7 | |||
8 | describe('ColorManager', function() { | ||
9 | /** **************** alpha tests **************** */ | ||
10 | describe('alpha', function() { | ||
11 | it('default is 1', function() { | ||
12 | expect(cm.alpha).toEqual(1); | ||
13 | }); | ||
14 | it('can be set/get', function() { | ||
15 | cm.alpha = 0.2; | ||
16 | expect(cm.alpha).toEqual(0.2); | ||
17 | }); | ||
18 | }); | ||
19 | |||
20 | |||
21 | /** **************** rgbToHex() tests **************** */ | ||
22 | describe('rgbToHex()', function() { | ||
23 | it('rgbToHex(0,0,0) is 000000/black', function() { | ||
24 | var hex = cm.rgbToHex(0,0,0); | ||
25 | expect(hex).toEqual("000000"); | ||
26 | }); | ||
27 | it('rgbToHex(255,255,255) is FFFFFF/white', function() { | ||
28 | var hex = cm.rgbToHex(255,255,255); | ||
29 | expect(hex).toEqual("FFFFFF"); | ||
30 | }); | ||
31 | it('rgbToHex(255,0,0) is FF0000/red', function() { | ||
32 | var hex = cm.rgbToHex(255,0,0); | ||
33 | expect(hex).toEqual("FF0000"); | ||
34 | }); | ||
35 | it('rgbToHex(0,255,0) is 00FF00/green', function() { | ||
36 | var hex = cm.rgbToHex(0,255,0); | ||
37 | expect(hex).toEqual("00FF00"); | ||
38 | }); | ||
39 | it('rgbToHex(0,0,255) is 0000FF/blue', function() { | ||
40 | var hex = cm.rgbToHex(0,0,255); | ||
41 | expect(hex).toEqual("0000FF"); | ||
42 | }); | ||
43 | it('rgbToHex(255,160,122) is FFA07A/salmon', function() { | ||
44 | var hex = cm.rgbToHex(255,160,122); | ||
45 | expect(hex).toEqual("FFA07A"); | ||
46 | }); | ||
47 | }); | ||
48 | |||
49 | |||
50 | /** **************** rgbToHsl() tests **************** */ | ||
51 | describe('rgbToHsl()', function() { | ||
52 | it('rgbToHsl(0,0,0) is {h:0, s:0, l:0}/black', function() { | ||
53 | var value = cm.rgbToHsl(0,0,0); | ||
54 | expect(value.h).toEqual(0); | ||
55 | expect(value.s).toEqual(0); | ||
56 | expect(value.l).toEqual(0); | ||
57 | }); | ||
58 | it('rgbToHsl(255,255,255) is {h:0, s:0, l:100}/white', function() { | ||
59 | var value = cm.rgbToHsl(255,255,255); | ||
60 | expect(value.h).toEqual(0); | ||
61 | expect(value.s).toEqual(0); | ||
62 | expect(value.l).toEqual(100); | ||
63 | }); | ||
64 | it('rgbToHsl(255,0,0) is {h:0, s:100, l:50}/red', function() { | ||
65 | var value = cm.rgbToHsl(255,0,0); | ||
66 | expect(value.h).toEqual(0); | ||
67 | expect(value.s).toEqual(100); | ||
68 | expect(value.l).toEqual(50); | ||
69 | }); | ||
70 | it('rgbToHsl(0,255,0) is {h:120, s:100, l:50}/green', function() { | ||
71 | var value = cm.rgbToHsl(0,255,0); | ||
72 | expect(value.h).toEqual(120); | ||
73 | expect(value.s).toEqual(100); | ||
74 | expect(value.l).toEqual(50); | ||
75 | }); | ||
76 | it('rgbToHsl(0,0,255) is {h:240, s:100, l:50}/blue', function() { | ||
77 | var value = cm.rgbToHsl(0,0,255); | ||
78 | expect(value.h).toEqual(240); | ||
79 | expect(value.s).toEqual(100); | ||
80 | expect(value.l).toEqual(50); | ||
81 | }); | ||
82 | it('rgbToHsl(255,160,122) is {h:17.14, s:100, l:73.92}/salmon', function() { | ||
83 | var value = cm.rgbToHsl(255,160,122); | ||
84 | expect(value.h).toEqual(17.142857142857142); | ||
85 | expect(value.s).toEqual(100); | ||
86 | expect(value.l).toEqual(73.92156862745098); | ||
87 | }); | ||
88 | }); | ||
89 | |||
90 | |||
91 | /** **************** hexToRgb() tests **************** */ | ||
92 | describe('hexToRgb()', function() { | ||
93 | it('hexToRgb(000000) is {r:0, g:0, b:0}', function() { | ||
94 | var value = cm.hexToRgb("000000"); | ||
95 | expect(value.r).toEqual(0); // red channel | ||
96 | expect(value.g).toEqual(0); // green channel | ||
97 | expect(value.b).toEqual(0); // blue channel | ||
98 | }); | ||
99 | it('hexToRgb(FFFFFF) is {r:255, g:255, b:255}', function() { | ||
100 | var value = cm.hexToRgb("FFFFFF"); | ||
101 | expect(value.r).toEqual(255); // red channel | ||
102 | expect(value.g).toEqual(255); // green channel | ||
103 | expect(value.b).toEqual(255); // blue channel | ||
104 | }); | ||
105 | it('hexToRgb(FF0000) is {r:255, g:0, b:0}', function() { | ||
106 | var value = cm.hexToRgb("FF0000"); | ||
107 | expect(value.r).toEqual(255); // red channel | ||
108 | expect(value.g).toEqual(0); // green channel | ||
109 | expect(value.b).toEqual(0); // blue channel | ||
110 | }); | ||
111 | it('hexToRgb(00FF00) is {r:0, g:255, b:0}', function() { | ||
112 | var value = cm.hexToRgb("00FF00"); | ||
113 | expect(value.r).toEqual(0); // red channel | ||
114 | expect(value.g).toEqual(255); // green channel | ||
115 | expect(value.b).toEqual(0); // blue channel | ||
116 | }); | ||
117 | it('hexToRgb(0000FF) is {r:0, g:0, b:255}', function() { | ||
118 | var value = cm.hexToRgb("0000FF"); | ||
119 | expect(value.r).toEqual(0); // red channel | ||
120 | expect(value.g).toEqual(0); // green channel | ||
121 | expect(value.b).toEqual(255); // blue channel | ||
122 | }); | ||
123 | it('hexToRgb(FFA07A) is {r:255, g:160, b:122}', function() { | ||
124 | var value = cm.hexToRgb("FFA07A"); | ||
125 | expect(value.r).toEqual(255); // red channel | ||
126 | expect(value.g).toEqual(160); // green channel | ||
127 | expect(value.b).toEqual(122); // blue channel | ||
128 | }); | ||
129 | }); | ||
130 | }); \ No newline at end of file | ||