Skip to content

Commit

Permalink
WP Date: Fix JS unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 23, 2017
1 parent 144814f commit 3cdbc7c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions bootstrap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,31 @@ global.window.tinyMCEPreInit = {
// <script> tag where it was loaded from, which of course fails here.
baseURL: 'about:blank',
};
global.window._wpDateSettings = {
formats: {
date: 'j F Y',
datetime: 'j F Y G \h i \m\i\n',
time: 'G \h i \m\i\n',
},
l10n: {
locale: 'en',
meridiem: {
am: 'am',
AM: 'AM',
pm: 'pm',
PM: 'PM',
},
months: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
weekdays: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
relative: {
future: '%s from now',
past: '%s ago',
},
},
timezone: {
offset: '-5',
string: 'America/New_York',
},
};
2 changes: 1 addition & 1 deletion date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const formatMap = {
function setupLocale( settings ) {
// Backup and restore current locale.
const currentLocale = moment.locale();
moment.defineLocale( settings.l10n.locale, {
moment.updateLocale( settings.l10n.locale, {
// Inherit anything missing from the default locale.
parentLocale: currentLocale,
months: settings.l10n.months,
Expand Down

0 comments on commit 3cdbc7c

Please sign in to comment.