UNPKG

@ginden/blinkstick-v2

Version:
27 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const morph_1 = require("./morph"); (0, vitest_1.describe)('morph', () => { (0, vitest_1.it)('throws if steps <= 0', () => { (0, vitest_1.expect)(() => Array.from((0, morph_1.morph)([0, 0, 0], [1, 1, 1], 100, 0))).toThrowError(); }); (0, vitest_1.it)('yields correct number of frames and colors for custom steps', () => { const frames = Array.from((0, morph_1.morph)([0, 0, 0], [30, 60, 90], 100, 2)); (0, vitest_1.expect)(frames).toHaveLength(2); (0, vitest_1.expect)(frames[0].rgb).toEqual([10, 20, 30]); (0, vitest_1.expect)(frames[1].rgb).toEqual([20, 40, 60]); }); (0, vitest_1.it)('yields reasonable number of frames', () => { const frames = Array.from((0, morph_1.morph)([0, 0, 0], [100, 100, 100], 600)); (0, vitest_1.expect)(frames.length).toBeLessThanOrEqual(40); // 15ms per frame, 600ms total (0, vitest_1.expect)(frames.length).toBeGreaterThanOrEqual(6); // 100ms per frame, 600ms total }); (0, vitest_1.it)('handles black => white transition', () => { const black = [0, 0, 0]; const white = [255, 255, 255]; const frames = Array.from((0, morph_1.morph)(black, white, 100, 5)); (0, vitest_1.expect)(frames).toHaveLength(5); }); }); //# sourceMappingURL=morph.spec.js.map