Skip to content

Commit

Permalink
Merge branch 'main' of github.com:adobe/da-live
Browse files Browse the repository at this point in the history
  • Loading branch information
auniverseaway committed Sep 17, 2024
2 parents f46fc48 + cc3e712 commit b9de2b7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions test/unit/blocks/edit/da-versions/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand All @@ -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);
});
Expand Down Expand Up @@ -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]' }],
Expand All @@ -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' }],
Expand Down

0 comments on commit b9de2b7

Please sign in to comment.