Skip to content

Commit

Permalink
This commit:
Browse files Browse the repository at this point in the history
- exports `getMediaDetails()` from the post-featured-image sidebar component and uses it if there's a featured image in the post record
- cleans up components and unused functions
- uses available wordcount and readtime functions
- implements i18n strings
- shuffles page-specific styles around
  • Loading branch information
ramonjd committed May 22, 2023
1 parent 4b24dbf commit 5207277
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 274 deletions.
31 changes: 30 additions & 1 deletion packages/date/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ describe( 'Moment.js Localization', () => {
} );

describe( 'humanTimeDiff', () => {
it( 'should return human readable time differences', () => {
it( 'should return human readable time differences in the past', () => {
expect(
humanTimeDiff(
'2023-04-28T11:00:00.000Z',
Expand All @@ -642,6 +642,35 @@ describe( 'Moment.js Localization', () => {
'2023-04-30T13:00:00.000Z'
)
).toBe( '2 days ago' );

expect(
humanTimeDiff(
'2023-04-28T11:00:00.000Z',
'2023-04-28T13:00:00.000Z'
)
).toBe( '2 hours ago' );

expect(
humanTimeDiff(
'2023-04-26T13:00:00.000Z',
'2023-04-28T13:00:00.000Z'
)
).toBe( '2 days ago' );
} );

it( 'should return human readable time differences in the future', () => {
// Future.
const now = new Date();
const twoHoursLater = new Date(
now.getTime() + 2 * 60 * 60 * 1000
);
expect( humanTimeDiff( twoHoursLater ) ).toBe( 'in 2 hours' );

const twoDaysLater = new Date(
now.getTime() + 2 * 24 * 60 * 60 * 1000
); // Adding 2 days in milliseconds

expect( humanTimeDiff( twoDaysLater ) ).toBe( 'in 2 days' );
} );
} );
} );
1 change: 1 addition & 0 deletions packages/edit-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@wordpress/url": "file:../url",
"@wordpress/viewport": "file:../viewport",
"@wordpress/widgets": "file:../widgets",
"@wordpress/wordcount": "file:../wordcount",
"classnames": "^2.3.1",
"colord": "^2.9.2",
"downloadjs": "^1.4.7",
Expand Down
Loading

0 comments on commit 5207277

Please sign in to comment.