@ginden/blinkstick-v2
Version:
Improved Blickstick API for Node.js
39 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const index_1 = require("../../index");
const index_2 = require("../../index");
const iterate_1 = require("./iterate");
(0, vitest_1.describe)('repeat', () => {
async function* base() {
yield new index_2.SimpleFrame([1, 1, 1], 10);
yield new index_2.SimpleFrame([2, 2, 2], 20);
}
(0, vitest_1.it)('throws if times <= 0', () => {
(0, vitest_1.expect)(() => (0, index_1.repeat)(base(), 0)).toThrowError();
});
(0, vitest_1.it)('returns the same animation for times=1', async () => {
const frames = [];
for await (const frame of (0, index_1.repeat)(base(), 1)) {
frames.push(frame);
}
(0, vitest_1.expect)(frames.map((f) => f.rgb)).toEqual([
[1, 1, 1],
[2, 2, 2],
]);
});
(0, vitest_1.it)('repeats the animation twice for times=2', async () => {
// This one fails
const frames = (await (0, iterate_1.asyncCollect)((0, index_1.repeat)(() => base(), 2)));
const actual = frames.map((f) => f.rgb);
const expected = [
[1, 1, 1],
[2, 2, 2],
[1, 1, 1],
[2, 2, 2],
];
(0, vitest_1.expect)(actual.length).toEqual(expected.length);
(0, vitest_1.expect)(actual).toEqual(expected);
});
});
//# sourceMappingURL=repeat.spec.js.map