UNPKG

@ginden/blinkstick-v2

Version:
68 lines 3.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vitest_1 = require("vitest"); const convert_simple_frames_to_complex_frame_1 = require("./convert-simple-frames-to-complex-frame"); const simple_frame_1 = require("../frame/simple-frame"); const iterate_1 = require("./iterate"); (0, vitest_1.describe)('convertSimpleFramesToComplexFrame1', () => { (0, vitest_1.it)('converts simple frames to a single complex frame', async () => { const sf1 = [new simple_frame_1.SimpleFrame([1, 1, 1], 10)]; const sf2 = [new simple_frame_1.SimpleFrame([2, 2, 2], 10)]; const frames = await (0, iterate_1.asyncCollect)((0, convert_simple_frames_to_complex_frame_1.convertSimpleFramesToComplexFrame)([sf1, sf2])); (0, vitest_1.expect)(frames).toHaveLength(1); (0, vitest_1.expect)(frames[0].duration).toBe(10); (0, vitest_1.expect)(frames[0].colors).toEqual([ [1, 1, 1], [2, 2, 2], ]); }); (0, vitest_1.it)('converts few simple frames to a few complex frame', async () => { const sf1 = [new simple_frame_1.SimpleFrame([1, 1, 1], 10), new simple_frame_1.SimpleFrame([2, 2, 2], 10)]; const sf2 = [new simple_frame_1.SimpleFrame([3, 3, 3], 20)]; const frames = await (0, iterate_1.asyncCollect)((0, convert_simple_frames_to_complex_frame_1.convertSimpleFramesToComplexFrame)([sf1, sf2])); (0, vitest_1.expect)(frames).toHaveLength(2); const [firstFrame, secondFrame] = frames; (0, vitest_1.expect)(firstFrame.duration).toBe(10); (0, vitest_1.expect)(firstFrame.colors).toEqual([ [1, 1, 1], [3, 3, 3], ]); (0, vitest_1.expect)(secondFrame.duration).toBe(10); (0, vitest_1.expect)(secondFrame.colors).toEqual([ [2, 2, 2], [3, 3, 3], ]); }); vitest_1.it.fails('converts frames of unequal length', async () => { const sf1 = [ new simple_frame_1.SimpleFrame([1, 1, 1], 20), new simple_frame_1.SimpleFrame([2, 2, 2], 20), new simple_frame_1.SimpleFrame([3, 3, 3], 20), ]; const sf2 = [new simple_frame_1.SimpleFrame([4, 4, 4], 30), new simple_frame_1.SimpleFrame([5, 5, 5], 30)]; const frames = await (0, iterate_1.asyncCollect)((0, convert_simple_frames_to_complex_frame_1.convertSimpleFramesToComplexFrame)([sf1, sf2])); (0, vitest_1.expect)(frames).toHaveLength(4); const [firstFrame, secondFrame, thirdFrame, fourthFrame] = frames; (0, vitest_1.expect)(firstFrame.duration).toBe(20); (0, vitest_1.expect)(firstFrame.colors).toEqual([ [1, 1, 1], [4, 4, 4], ]); (0, vitest_1.expect)(secondFrame.duration).toBe(10); (0, vitest_1.expect)(secondFrame.colors).toEqual([ [2, 2, 2], [4, 4, 4], ]); (0, vitest_1.expect)(thirdFrame.duration).toBe(10); (0, vitest_1.expect)(thirdFrame.colors).toEqual([ [3, 3, 3], [5, 5, 5], ]); (0, vitest_1.expect)(fourthFrame.duration).toBe(20); (0, vitest_1.expect)(fourthFrame.colors).toEqual([ [3, 3, 3], [5, 5, 5], ]); }); }); //# sourceMappingURL=convert-simple-frames-to-complex-frame.spec.js.map