Skip to content

Commit

Permalink
Improve test for #278
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Dec 21, 2024
1 parent 5173539 commit 71880f3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lib/services/contents/entry/slug.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ describe('Test fillSlugTemplate()', () => {
});

test('date/time', () => {
// The time zone should be UTC, not local
const { year, month, day, hour, minute, second } = getDateTimeParts({ timeZone: 'UTC' });
const template = '{{year}}-{{month}}-{{day}}-{{hour}}-{{minute}}-{{second}}';
const dateTimeParts = getDateTimeParts({ timeZone: 'UTC' });
const { year, month, day, hour, minute, second } = dateTimeParts;
const result = `${year}-${month}-${day}-${hour}-${minute}-${second}`;

expect(fillSlugTemplate(template, { collection, content: {} })).toEqual(
`${year}-${month}-${day}-${hour}-${minute}-${second}`,
);
// The time zone should always be UTC, not local, with or without the `dateTimeParts` option
expect(fillSlugTemplate(template, { collection, content: {} })).toEqual(result);
expect(fillSlugTemplate(template, { collection, content: {}, dateTimeParts })).toEqual(result);
});

test('random ID fallback', () => {
Expand Down

0 comments on commit 71880f3

Please sign in to comment.