-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Upgrade ts and improve types/tests of invalid scenarios (#650)
- Loading branch information
1 parent
24f0ded
commit 6ce349e
Showing
26 changed files
with
1,501 additions
and
1,502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { utilsTest, formats, TEST_TIMESTAMP } from "./test-utils"; | ||
|
||
describe("DateTime calculations", () => { | ||
utilsTest("getFormatHelperText - invalid input", (_, utils) => { | ||
if (utils.lib === "luxon") { | ||
return; | ||
} | ||
// if the format provided here is not a format we must simply return as is | ||
// in case user is using a custom specified format text | ||
expect(utils.getFormatHelperText("testtest")).toBe("testtest"); | ||
}); | ||
|
||
utilsTest("isEqual - invalid input", (date, utils) => { | ||
expect(utils.isEqual(null, null)).toBe(true); | ||
expect(utils.isEqual(date, null)).toBe(false); | ||
expect(utils.isEqual(null, date)).toBe(false); | ||
}); | ||
|
||
utilsTest("parse - invalid input", (_, utils) => { | ||
const result = utils.parse("jf.bioifjwe.-", utils.formats.fullDateTime12h); | ||
expect(utils.isValid(result)).toBe(false); | ||
}); | ||
|
||
utilsTest("getDiff - invalid input", (date, utils) => { | ||
const result = utils.getDiff(date, "fwe", "minutes"); | ||
expect(result).toBe(0); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IUtils } from "@date-io/core/IUtils"; | ||
import DayjsUtils from "../packages/dayjs/src/dayjs-utils"; | ||
import { Dayjs } from "dayjs"; | ||
|
||
class CustomDateTime extends DayjsUtils implements IUtils<Dayjs> { | ||
getYear = () => 2007; | ||
getWeekdays = () => { | ||
const start = this.dayjs().startOf("week"); | ||
return [0, 1].map((diff) => this.formatByString(start.add(diff, "day"), "dd")); | ||
}; | ||
} | ||
|
||
test("Should be possible to override methods of utility classes", () => { | ||
const utils = new CustomDateTime(); | ||
expect(utils.getWeekdays()).toEqual(["Su", "Mo"]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testMatch: ["**/__tests__/**/*.test.ts"], | ||
collectCoverageFrom: ["packages/**/src/**/*"], | ||
globals: { | ||
'ts-jest': { | ||
tsConfig: './__tests__/tsconfig.test.json' | ||
} | ||
} | ||
"ts-jest": { | ||
tsconfig: "./__tests__/tsconfig.test.json", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.