Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Jun 15, 2023
1 parent b87c41c commit a623dbc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/date/test/src/DateTime.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {DateTime, DateTimeKind} from "../../src";
import {DateTime, XDate, XDateIntervalKind} from "../../src";

describe("DateTime", () => {
const date = new DateTime("2020-02-12T12:35:13.123Z");
test("mutate()", () => {
const mutations: [DateTimeKind, number][] = [
const mutations: [XDateIntervalKind, number][] = [
["ms", +100],
["sec", +10],
["min", -10],
Expand All @@ -24,7 +24,7 @@ describe("DateTime", () => {
});

test("set()", () => {
const setters: [DateTimeKind, number][] = [
const setters: [XDateIntervalKind, number][] = [
["ms", 333],
["sec", 22],
["min", 11],
Expand All @@ -44,7 +44,7 @@ describe("DateTime", () => {

test("begins/ends()", () => {
const result = [];
const begins: Exclude<DateTimeKind, "ms">[] = ["sec", "min", "hour", "day", "month", "year"];
const begins: Exclude<XDateIntervalKind, "ms">[] = ["sec", "min", "hour", "day", "month", "year"];
for (const kind of begins) {
result.push({
kind,
Expand All @@ -56,12 +56,12 @@ describe("DateTime", () => {
expect(result).toMatchSnapshot();
});

const tests: [number, DateTime][] = new Array(7)
const tests: [number, XDate][] = new Array(7)
.fill(new Date(2020, 4, 11))
.map((d: Date, index) => new DateTime(d).mutate(["day", index]).date)
.map((d: Date) => [d.getDate(), new DateTime(d)]);
test.each(tests)("begins/ends ( %d )", (...args) => {
const dt = args.pop() as DateTime;
const dt = args.pop() as XDate;
expect(dt.begins("week").date.getDate()).toBe(11);
expect(dt.ends("week").date.getDate()).toBe(17);
});
Expand Down

0 comments on commit a623dbc

Please sign in to comment.