-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15bf107
commit 7e5a52c
Showing
12 changed files
with
3,171 additions
and
834 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
import Importer from "../src/settings/import/importer"; | ||
import { vi, test, expect } from "vitest"; | ||
|
||
const GREGORIAN_EXPORT = require("./data/exports/gregorian-export.json"); | ||
const HARPTOS_EXPORT = require("./data/exports/harptos-custom-export.json"); | ||
const IMPERIAL_EXPORT = require("./data/exports/imperial-export.json"); | ||
|
||
global.createDiv = vi.fn( | ||
( | ||
o?: DomElementInfo | string, | ||
callback?: (el: HTMLDivElement) => void | ||
): HTMLDivElement => { | ||
return document.createElement("div") as HTMLDivElement; | ||
} | ||
); | ||
|
||
test("Import Gregorian", () => { | ||
const importedCalendars = Importer.import([GREGORIAN_EXPORT]); | ||
expect(importedCalendars.length).toBe(1); | ||
|
||
const calendar = importedCalendars[0]; | ||
|
||
expect(calendar.name).toBe("Gregorian Calendar"); | ||
}); | ||
test("Import Harptos", () => { | ||
const importedCalendars = Importer.import([HARPTOS_EXPORT]); | ||
expect(importedCalendars.length).toBe(1); | ||
|
||
const calendar = importedCalendars[0]; | ||
|
||
expect(calendar.name).toBe("Events"); | ||
}); | ||
test("Import Imperial", () => { | ||
const importedCalendars = Importer.import([IMPERIAL_EXPORT]); | ||
expect(importedCalendars.length).toBe(1); | ||
|
||
const calendar = importedCalendars[0]; | ||
|
||
expect(calendar.name).toBe("Third Imperium"); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,70 +1,86 @@ | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
import { CalEventDate } from "../src/@types"; | ||
import { CalEventHelper } from "../src/events/event.helper"; | ||
import { PRESET_CALENDARS } from "../src/utils/presets"; | ||
import { test, expect } from "vitest"; | ||
|
||
import Moment from 'moment'; | ||
Object.defineProperty(window, 'moment', { value: Moment }); | ||
import Moment from "moment"; | ||
Object.defineProperty(window, "moment", { value: Moment }); | ||
|
||
const GREGORIAN = PRESET_CALENDARS.find((p) => p.name == "Gregorian Calendar"); | ||
const file = { | ||
path: "path", | ||
basename: "basename" | ||
} | ||
basename: "basename", | ||
}; | ||
|
||
const input: CalEventDate = { | ||
year: 1400, | ||
month: 1, | ||
day: 28 | ||
day: 28, | ||
}; | ||
|
||
test("YYYY-MM-DD", () => { | ||
const YMD = new CalEventHelper(GREGORIAN, true); | ||
const datestring = '1400-02-28'; | ||
expect(YMD.formatDigest).toEqual('YMD'); | ||
const datestring = "1400-02-28"; | ||
expect(YMD.formatDigest).toEqual("YMD"); | ||
expect(YMD.toCalDateString(input)).toEqual(datestring); | ||
expect(YMD.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
expect(YMD.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); | ||
test("YYYY-MMM-DD", () => { | ||
GREGORIAN.dateFormat = "YYYY-MMM-DD"; | ||
const YMD = new CalEventHelper(GREGORIAN, true); | ||
const datestring = '1400-February-28'; | ||
expect(YMD.formatDigest).toEqual('YMD'); | ||
const datestring = "1400-February-28"; | ||
expect(YMD.formatDigest).toEqual("YMD"); | ||
expect(YMD.toCalDateString(input)).toEqual(datestring); | ||
expect(YMD.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
expect(YMD.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); | ||
|
||
test("M-D-Y", () => { | ||
GREGORIAN.dateFormat = "M-D-Y"; | ||
const MDY = new CalEventHelper(GREGORIAN, true); | ||
const datestring = "2-28-1400"; | ||
expect(MDY.formatDigest).toEqual('MDY'); | ||
expect(MDY.formatDigest).toEqual("MDY"); | ||
expect(MDY.toCalDateString(input)).toEqual(datestring); | ||
expect(MDY.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
expect(MDY.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); | ||
|
||
test("MM-D-Y", () => { | ||
GREGORIAN.dateFormat = "MM-D-Y"; | ||
const MDY = new CalEventHelper(GREGORIAN, true); | ||
const datestring = "02-28-1400"; | ||
expect(MDY.formatDigest).toEqual('MDY'); | ||
expect(MDY.formatDigest).toEqual("MDY"); | ||
expect(MDY.toCalDateString(input)).toEqual(datestring); | ||
expect(MDY.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
expect(MDY.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); | ||
|
||
test("DD-M-Y", () => { | ||
GREGORIAN.dateFormat = "DD-M-Y"; | ||
const DMY = new CalEventHelper(GREGORIAN, true); | ||
const datestring = "28-2-1400"; | ||
expect(DMY.formatDigest).toEqual('DMY'); | ||
expect(DMY.formatDigest).toEqual("DMY"); | ||
expect(DMY.toCalDateString(input)).toEqual(datestring); | ||
expect(DMY.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
expect(DMY.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); | ||
|
||
test("DD-MMM-Y", () => { | ||
GREGORIAN.dateFormat = "DD-MMM-Y"; | ||
const DMY = new CalEventHelper(GREGORIAN, true); | ||
const datestring = "28-February-1400"; | ||
expect(DMY.formatDigest).toEqual('DMY'); | ||
expect(DMY.formatDigest).toEqual("DMY"); | ||
expect(DMY.toCalDateString(input)).toEqual(datestring); | ||
expect(DMY.parseCalDateString(datestring, file)).toEqual(expect.objectContaining(input)); | ||
}); | ||
expect(DMY.parseCalDateString(datestring, file)).toEqual( | ||
expect.objectContaining(input) | ||
); | ||
}); |
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.