1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/utils/__tests__/chunk.test.ts
Sebastian Malton aea545526d Make the upgrade routes actually use a router
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-01-19 09:37:26 -05:00

62 lines
1.9 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { chunkSkipEnd } from "../chunk";
describe("chunkSkipEnd", () => {
it("should yield no elements when given an empty iterator", () => {
const i = chunkSkipEnd([], 2);
expect(i.next()).toEqual({ done: true });
});
it("should yield no elements when given an iterator of size less than chunk=2", () => {
const i = chunkSkipEnd([1], 2);
expect(i.next()).toEqual({ done: true });
});
it("should yield no elements when given an chunk=0", () => {
const i = chunkSkipEnd([1], 0);
expect(i.next()).toEqual({ done: true });
});
it("should yield no elements when given an chunk<0", () => {
const i = chunkSkipEnd([1], 0);
expect(i.next()).toEqual({ done: true });
});
it("should yield no elements when given an iterator of size less than chunk=3", () => {
const i = chunkSkipEnd([1, 2], 3);
expect(i.next()).toEqual({ done: true });
});
it("should yield one chunk when given an iterator of size equal to chunk", () => {
const i = chunkSkipEnd([1, 2], 2);
expect(i.next()).toEqual({ done: false, value: [1, 2] });
expect(i.next()).toEqual({ done: true });
});
it("should yield two chunks when given an iterator of size equal to chunk*2", () => {
const i = chunkSkipEnd([1, 2, 3, 4], 2);
expect(i.next()).toEqual({ done: false, value: [1, 2] });
expect(i.next()).toEqual({ done: false, value: [3, 4] });
expect(i.next()).toEqual({ done: true });
});
it("should yield two chunks when given an iterator of size between chunk*2 and chunk*3", () => {
const i = chunkSkipEnd([1, 2, 3, 4, 5], 2);
expect(i.next()).toEqual({ done: false, value: [1, 2] });
expect(i.next()).toEqual({ done: false, value: [3, 4] });
expect(i.next()).toEqual({ done: true });
});
});