Skip to content

Commit 2597732

Browse files
committed
Mock dateI18n function to ensure snapshot date is always in GMT
1 parent 7ad02d1 commit 2597732

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

plugin/tests/js/settings/components/integrations/__snapshots__/updater.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exports[`Settings: Updater matches snapshot 1`] = `
2222
<p
2323
class="mdc-typography--body1"
2424
>
25-
Last update on Apr 13, 2021, 08:28 PM
25+
Last update on Tue, 13 Apr 2021 14:58:26 GMT
2626
</p>
2727
</div>
2828
<div
@@ -255,7 +255,7 @@ exports[`Settings: Updater matches snapshot when should not update 1`] = `
255255
<p
256256
class="mdc-typography--body1"
257257
>
258-
Last update on Apr 13, 2021, 08:28 PM
258+
Last update on Tue, 13 Apr 2021 14:58:26 GMT
259259
</p>
260260
</div>
261261
<div

plugin/tests/js/settings/components/integrations/updater.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ import { render } from '@testing-library/react';
2626
import Updater from '../../../../../assets/src/settings/components/integrations/updater';
2727
import { SettingsProvider } from '../../../../../assets/src/settings/context';
2828

29+
// Mock the @wordpress/date component.
30+
jest.mock( '@wordpress/date', () => {
31+
const original = jest.requireActual( '@wordpress/date' );
32+
return {
33+
...original,
34+
dateI18n: ( format, value ) => new Date( value ).toGMTString(),
35+
};
36+
} );
37+
2938
const baseProps = {
3039
title: 'Google Fonts',
3140
type: 'FONTS',

0 commit comments

Comments
 (0)