UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

64 lines 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var color_1 = require("./color"); describe("Color", function () { it("Can create basic colors from rgb", function () { var c = new color_1.Color(10, 20, 30); expect(c.r).toEqual(10); expect(c.g).toEqual(20); expect(c.b).toEqual(30); }); it("Can compare colors", function () { var tests = [ [new color_1.Color(5, 10, 20), new color_1.Color(5, 10, 20), true], [new color_1.Color(0, 0, 0), new color_1.Color(0, 0, 0), true], [new color_1.Color(255, 255, 0), new color_1.Color(255, 255, 0), true], [new color_1.Color(255, 0, 255), new color_1.Color(255, 255, 0), false], [new color_1.Color(1, 2, 3), new color_1.Color(4, 5, 6), false], ]; for (var _i = 0, tests_1 = tests; _i < tests_1.length; _i++) { var _a = tests_1[_i], c1 = _a[0], c2 = _a[1], bool = _a[2]; expect(c1.isEqual(c2)).toEqual(bool); expect(c2.isEqual(c1)).toEqual(bool); expect(c1.isEqual(c1)).toEqual(true); expect(c2.isEqual(c2)).toEqual(true); } }); it("Can get a css color", function () { expect(new color_1.Color(10, 20, 30).cssColor()).toEqual("rgb(10,20,30)"); expect(new color_1.Color(100, 100, 255).cssColor()).toEqual("rgb(100,100,255)"); }); it("Can add another color", function () { var c = new color_1.Color(10, 20, 30); var n = c.add(new color_1.Color(10, 10, 10)); expect(n.r).toEqual(20); expect(n.g).toEqual(30); expect(n.b).toEqual(40); var n2 = c.add(new color_1.Color(10, 10, 10), 0.5); expect(n2.r).toEqual(15); expect(n2.g).toEqual(25); expect(n2.b).toEqual(35); }); it("Can blend another color", function () { var c = new color_1.Color(10, 20, 30); var n = c.blend(new color_1.Color(10, 10, 10)); expect(n.r).toEqual(10); expect(n.g).toEqual(15); expect(n.b).toEqual(20); }); it("Can blend a percent", function () { var c = new color_1.Color(10, 20, 30); var n = c.blendPercent(new color_1.Color(10, 10, 10), 50); expect(n.r).toEqual(10); expect(n.g).toEqual(15); expect(n.b).toEqual(20); }); it("Can get grayscale", function () { var c = new color_1.Color(10, 20, 30); var g = c.toGrayscale(); expect(g.r).toEqual(20); expect(g.g).toEqual(20); expect(g.b).toEqual(20); }); }); //# sourceMappingURL=color.spec.js.map