From: Chris Myers Date: Thu, 19 Oct 2017 23:02:54 +0000 (+0100) Subject: Added test and minor refactor X-Git-Tag: 2.19.2~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=695fd7528d0def1ab1bcaf4176fcf810f8bcf650;p=thirdparty%2Fmoment.git Added test and minor refactor --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index e45415fca..7d8fb26e0 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -133,7 +133,7 @@ export function updateLocale(name, config) { if (config != null) { var locale, tmpLocale, parentConfig = baseConfig; // MERGE - tmpLocale = locales[name] || loadLocale(name); + tmpLocale = loadLocale(name); if (tmpLocale != null) { parentConfig = tmpLocale._config; } diff --git a/src/test/moment/locale_update.js b/src/test/moment/locale_update.js index ab956b415..3a525e279 100644 --- a/src/test/moment/locale_update.js +++ b/src/test/moment/locale_update.js @@ -164,3 +164,11 @@ test('months', function (assert) { }); assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child'); }); + +test('update existing locale', function (assert) { + moment.updateLocale('de', { + monthsShort: ['JAN', 'FEB', 'MÄR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEZ'] + }); + assert.equal(moment('2017-02-01').format('YYYY MMM MMMM'), '2017 FEB Februar'); + moment.updateLocale('de', null); +});