@ginden/blinkstick-v2
Version:
Improved Blickstick API for Node.js
68 lines • 3.35 kB
JavaScript
"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([
[],
[],
]);
});
(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([
[],
[],
]);
(0, vitest_1.expect)(secondFrame.duration).toBe(10);
(0, vitest_1.expect)(secondFrame.colors).toEqual([
[],
[],
]);
});
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([
[],
[],
]);
(0, vitest_1.expect)(secondFrame.duration).toBe(10);
(0, vitest_1.expect)(secondFrame.colors).toEqual([
[],
[],
]);
(0, vitest_1.expect)(thirdFrame.duration).toBe(10);
(0, vitest_1.expect)(thirdFrame.colors).toEqual([
[],
[],
]);
(0, vitest_1.expect)(fourthFrame.duration).toBe(20);
(0, vitest_1.expect)(fourthFrame.colors).toEqual([
[],
[],
]);
});
});
//# sourceMappingURL=convert-simple-frames-to-complex-frame.spec.js.map