UNPKG

@ginden/blinkstick-v2

Version:
42 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const combine_1 = require("./combine"); const simple_frame_1 = require("../frame/simple-frame"); (0, vitest_1.describe)('combine', () => { (0, vitest_1.it)('throws if no animations provided', () => { (0, vitest_1.expect)(() => (0, combine_1.combine)()).toThrowError('At least one animation is required'); }); (0, vitest_1.it)('combines two animations sequentially', async () => { async function* a() { yield new simple_frame_1.SimpleFrame([1, 2, 3], 10); yield new simple_frame_1.SimpleFrame([4, 5, 6], 20); } async function* b() { yield new simple_frame_1.SimpleFrame([7, 8, 9], 30); } const result = []; for await (const frame of (0, combine_1.combine)(a(), b())) { result.push(frame); } (0, vitest_1.expect)(result.map((f) => f.rgb)).toEqual([ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]); (0, vitest_1.expect)(result.map((f) => f.duration)).toEqual([10, 20, 30]); }); (0, vitest_1.it)('supports a single animation', async () => { async function* a() { yield new simple_frame_1.SimpleFrame([8, 8, 8], 5); } const result = []; for await (const frame of (0, combine_1.combine)(a())) { result.push(frame); } (0, vitest_1.expect)(result).toHaveLength(1); (0, vitest_1.expect)(result[0].rgb).toEqual([8, 8, 8]); (0, vitest_1.expect)(result[0].duration).toBe(5); }); }); //# sourceMappingURL=combine.spec.js.map