Skip to content

Commit

Permalink
test: Series generics
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Jan 13, 2024
1 parent 227cf9f commit e19fbbc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion __tests__/series.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable newline-per-chained-call */
import pl from "@polars";
import pl, { DataType } from "@polars";
import { InvalidOperationError } from "../polars/error";
import Chance from "chance";

Expand Down Expand Up @@ -814,3 +814,23 @@ describe("series struct", () => {
expect(actual).toEqual(expected);
});
});
describe("generics", () => {
const series = pl.Series([1, 2, 3]);

test("dtype", () => {
expect(series.dtype).toStrictEqual(DataType.Float64);
});
test("to array", () => {
const arr = series.toArray();
expect<number[]>(arr).toStrictEqual([1, 2, 3]);

const arr2 = [...series];
expect<number[]>(arr2).toStrictEqual([1, 2, 3]);
});
test("to object", () => {
const obj = series.toObject();
expect<{ name: string; datatype: "Float64"; values: number[] }>(
obj,
).toMatchObject({ name: "", datatype: "Float64", values: [1, 2, 3] });
});
});

0 comments on commit e19fbbc

Please sign in to comment.