|
|
@@ -55,4 +55,47 @@ describe('useFormatter', () => {
|
|
|
expect(markdown).toBe('markdown body');
|
|
|
});
|
|
|
|
|
|
+ it('returns markdown formatted when currentPagePath is undefined', () => {
|
|
|
+ // when
|
|
|
+ const { format } = useFormatter();
|
|
|
+ const template = mock<ITemplate>();
|
|
|
+ template.markdown = `
|
|
|
+title: {{{title}}}{{^title}}(empty){{/title}}
|
|
|
+path: {{{path}}}
|
|
|
+`;
|
|
|
+ const markdown = format(template);
|
|
|
+
|
|
|
+ // then
|
|
|
+ expect(markdown).toBe(`
|
|
|
+title: (empty)
|
|
|
+path: /
|
|
|
+`);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('returns markdown formatted', () => {
|
|
|
+ // setup
|
|
|
+ mocks.useCurrentPagePathMock.mockImplementation(() => {
|
|
|
+ return { data: '/Sandbox' };
|
|
|
+ });
|
|
|
+ // 2023/5/31 15:01:xx
|
|
|
+ vi.setSystemTime(new Date(2023, 4, 31, 15, 1));
|
|
|
+
|
|
|
+ // when
|
|
|
+ const { format } = useFormatter();
|
|
|
+ const template = mock<ITemplate>();
|
|
|
+ template.markdown = `
|
|
|
+title: {{{title}}}
|
|
|
+path: {{{path}}}
|
|
|
+date: {{yyyy}}/{{MM}}/{{dd}} {{HH}}:{{mm}}
|
|
|
+`;
|
|
|
+ const markdown = format(template);
|
|
|
+
|
|
|
+ // then
|
|
|
+ expect(markdown).toBe(`
|
|
|
+title: Sandbox
|
|
|
+path: /Sandbox
|
|
|
+date: 2023/05/31 15:01
|
|
|
+`);
|
|
|
+ });
|
|
|
+
|
|
|
});
|