mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-19 10:58:10 +08:00
* Added TS. Updated build and linting config. Added types. * [ts-migrate][.] Rename files from JS/JSX to TS/TSX Co-authored-by: ts-migrate <> * [ts-migrate][.] Run TS Migrate Co-authored-by: ts-migrate <> * Corrected files mangled by ts-migrate. * Updated lint config, minor linting. * Re-enabled Husky. * Updated tests and config. * Reverted webpack devtool config. * Removed obsolete snapshots. * Added annotations snap. * Updated tsconfig includes wrt linting. * Removed ts-migrate. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { range, rangeFill, linspace } from "../../src/util/range";
|
|
|
|
describe("range", () => {
|
|
test("no defaults", () => {
|
|
expect(range(0, 3, 1)).toMatchObject([0, 1, 2]);
|
|
});
|
|
|
|
test("range(stop)", () => {
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
expect(range(3)).toMatchObject([0, 1, 2]);
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
expect(range(0)).toMatchObject([]);
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
expect(range(1)).toMatchObject([0]);
|
|
});
|
|
|
|
test("range(start,stop)", () => {
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
expect(range(0, 0)).toMatchObject([]);
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
expect(range(0, 2)).toMatchObject([0, 1]);
|
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
expect(range(4, 8)).toMatchObject([4, 5, 6, 7]);
|
|
});
|
|
|
|
test("range(start, stop, step", () => {
|
|
expect(range(4, 0, -1)).toMatchObject([4, 3, 2, 1]);
|
|
expect(range(0, 4, 2)).toMatchObject([0, 2]);
|
|
});
|
|
});
|
|
|
|
describe("rangefill", () => {
|
|
test("rangeFill(arr)", () => {
|
|
expect(rangeFill(new Int32Array(3))).toMatchObject(
|
|
new Int32Array([0, 1, 2])
|
|
);
|
|
});
|
|
test("rangeFill(arr, start)", () => {
|
|
expect(rangeFill(new Int32Array(2), 1)).toMatchObject(
|
|
new Int32Array([1, 2])
|
|
);
|
|
});
|
|
test("rangeFill(arr, start, step)", () => {
|
|
expect(rangeFill(new Int32Array(3), 2, -1)).toMatchObject(
|
|
new Int32Array([2, 1, 0])
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("linspace", () => {
|
|
test("linspace(arr, start, step)", () => {
|
|
expect(linspace(0.0, 2.0, 5)).toMatchObject([0.0, 0.5, 1.0, 1.5, 2.0]);
|
|
});
|
|
});
|