-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing journal title date formatting support
- Loading branch information
1 parent
3def810
commit 5da910a
Showing
5 changed files
with
106 additions
and
28 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
48 changes: 48 additions & 0 deletions
48
packages/engine-test-utils/src/__tests__/common-all/journalTitle.spec.ts
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,48 @@ | ||
import { getJournalTitle } from "@dendronhq/common-all"; | ||
|
||
/** | ||
* Tests the behavior around generating the note title for a journal note | ||
*/ | ||
describe("GIVEN journal note title generation", () => { | ||
describe("WHEN a journal note with the default format like journal.2021.01.01", () => { | ||
test("THEN note title should be formatted properly", () => { | ||
const result = getJournalTitle("journal.2021.01.01", "y.MM.dd"); | ||
expect(result).toEqual("2021-01-01"); | ||
}); | ||
}); | ||
|
||
describe("WHEN a journal note with a note name like double.prefix.2021.01.01", () => { | ||
test("THEN note title should be formatted properly", () => { | ||
const result = getJournalTitle("double.prefix.2021.01.01", "y.MM.dd"); | ||
expect(result).toEqual("2021-01-01"); | ||
}); | ||
}); | ||
|
||
describe("WHEN a journal note with a note name like journal.12.01 without the year", () => { | ||
test("THEN note title should be formatted properly", () => { | ||
const result = getJournalTitle("journal.12.01", "MM.dd"); | ||
expect(result).toEqual("12-01"); | ||
}); | ||
}); | ||
|
||
describe("WHEN a journal note with a configured date format of MM-dd like journal.12-01 with dashes", () => { | ||
test("THEN note title should be formatted properly", () => { | ||
const result = getJournalTitle("journal.12-01", "MM-dd"); | ||
expect(result).toEqual("12-01"); | ||
}); | ||
}); | ||
|
||
describe("WHEN a journal note does not match the configured date format ", () => { | ||
test("THEN note title override should return undefined", () => { | ||
const result = getJournalTitle("journal.12.01", "MM-dd"); | ||
expect(result).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe("WHEN a journal note has a suffix like journal.2021.01.01.suffix", () => { | ||
test("THEN note title override should return undefined", () => { | ||
const result = getJournalTitle("journal.2021.01.01.suffix", "y.MM.dd"); | ||
expect(result).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
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