carto/test/color.test.js

26 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-07-03 23:53:12 +08:00
var assert = require('assert');
var tree = require('../lib/carto/tree.js');
2014-07-04 00:00:40 +08:00
require('../lib/carto/functions');
2014-07-03 23:53:12 +08:00
require('../lib/carto/tree/color');
2014-07-04 00:00:40 +08:00
require('../lib/carto/tree/dimension');
2014-07-03 23:53:12 +08:00
describe('Color', function() {
describe('basic functionality', function() {
it('should be constructed', function() {
var f = new tree.Color([0, 0, 0], 1);
assert.deepEqual(f.toHSL(), {"h":0,"s":0,"l":0,"a":1});
assert.ok(f);
});
});
2014-07-04 00:00:40 +08:00
describe('functions', function() {
it('should be constructed', function() {
assert.deepEqual(tree.functions.rgb(0, 0, 0), new tree.Color([0, 0, 0], 1));
assert.deepEqual(tree.functions.hue(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0));
assert.deepEqual(tree.functions.saturation(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0, '%'));
assert.deepEqual(tree.functions.lightness(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0, '%'));
assert.deepEqual(tree.functions.alpha(new tree.Color([0, 0, 0], 1)), new tree.Dimension(1));
assert.deepEqual(tree.functions.greyscale(new tree.Color([0, 0, 0], 1)), new tree.Color([0, 0, 0], 1));
});
});
2014-07-03 23:53:12 +08:00
});