-
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.
Merge branch 'main' of github.com:adobe/da-live
- Loading branch information
Showing
1 changed file
with
13 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ import { expect } from '@esm-bundle/chai'; | |
import { formatDate, formatVersions } from '../../../../../blocks/edit/da-versions/helpers.js'; | ||
|
||
const TIME_OPTS = { hour: 'numeric', minute: '2-digit' }; | ||
const DATE_OPTS = { year: 'numeric', month: 'short', day: 'numeric' }; | ||
|
||
describe('Versions helper', () => { | ||
it('Format date', () => { | ||
const { date: d, time: t } = formatDate(1709205071123); | ||
expect(d).to.equal('February 29, 2024'); | ||
|
||
expect(d).to.equal(new Date(1709205071123).toLocaleDateString([], DATE_OPTS)); | ||
expect(t).to.equal(new Date(1709205071123).toLocaleTimeString([], TIME_OPTS)); | ||
}); | ||
|
||
|
@@ -23,8 +25,8 @@ describe('Versions helper', () => { | |
} | ||
|
||
expect(before).to.deep.equal(after); | ||
const expectedDate = now.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' }); | ||
const expectedTime = now.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' }); | ||
const expectedDate = now.toLocaleDateString(undefined, DATE_OPTS); | ||
const expectedTime = now.toLocaleTimeString(undefined, TIME_OPTS); | ||
expect(expectedDate).to.equal(after.date); | ||
expect(expectedTime).to.equal(after.time); | ||
}); | ||
|
@@ -63,25 +65,25 @@ describe('Versions helper', () => { | |
const formatted = formatVersions(versions); | ||
|
||
const expected = [{ | ||
date: 'May 15, 2024', | ||
date: new Date(1715766906908).toLocaleDateString([], DATE_OPTS), | ||
audits: [{ | ||
date: 'May 15, 2024', | ||
date: new Date(1715766906908).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715766906908).toLocaleTimeString([], TIME_OPTS), | ||
users: [{ email: '[email protected]' }, { email: 'anonymous' }], | ||
timestamp: 1715766906908, | ||
path: 'da-aem-boilerplate/blah7.html', | ||
isVersion: false, | ||
}, | ||
{ | ||
date: 'May 15, 2024', | ||
date: new Date(1715766405165).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715766405165).toLocaleTimeString([], TIME_OPTS), | ||
users: [{ email: '[email protected]' }], | ||
timestamp: 1715766405165, | ||
path: 'da-aem-boilerplate/blah7.html', | ||
isVersion: false, | ||
}], | ||
}, { | ||
date: 'May 15, 2024', | ||
date: new Date(1715766894180).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715766894180).toLocaleTimeString([], TIME_OPTS), | ||
url: '/versionsource/joey/ghi.html', | ||
users: [{ email: '[email protected]' }], | ||
|
@@ -90,25 +92,25 @@ describe('Versions helper', () => { | |
label: 'hello', | ||
isVersion: true, | ||
}, { | ||
date: 'May 14, 2024', | ||
date: new Date(1715701875589).toLocaleDateString([], DATE_OPTS), | ||
audits: [{ | ||
date: 'May 14, 2024', | ||
date: new Date(1715701875589).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715701875589).toLocaleTimeString([], TIME_OPTS), | ||
users: [{ email: 'anonymous' }], | ||
timestamp: 1715701875589, | ||
path: 'da-aem-boilerplate/blah7.html', | ||
isVersion: false, | ||
}], | ||
}, { | ||
date: 'May 13, 2024', | ||
date: new Date(1715594902707).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715594902707).toLocaleTimeString([], TIME_OPTS), | ||
url: '/versionsource/joey/def.html', | ||
users: [{ email: 'anonymous' }], | ||
timestamp: 1715594902707, | ||
path: 'da-aem-boilerplate/blah7.html', | ||
isVersion: true, | ||
}, { | ||
date: 'May 13, 2024', | ||
date: new Date(1715594886177).toLocaleDateString([], DATE_OPTS), | ||
time: new Date(1715594886177).toLocaleTimeString([], TIME_OPTS), | ||
url: '/versionsource/joey/abc.html', | ||
users: [{ email: 'anonymous' }], | ||
|