]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Mark unit test deprecations in tests 3065/head
authorIskren Chernev <iskren.chernev@gmail.com>
Thu, 24 Mar 2016 14:22:05 +0000 (07:22 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Thu, 24 Mar 2016 14:29:44 +0000 (07:29 -0700)
15 files changed:
src/test/locale/lt.js
src/test/moment/add_subtract.js
src/test/moment/create.js
src/test/moment/deprecate.js
src/test/moment/duration.js
src/test/moment/format.js
src/test/moment/getters_setters.js
src/test/moment/invalid.js
src/test/moment/locale.js
src/test/moment/locale_update.js
src/test/moment/preparse_postformat.js
src/test/moment/utc.js
src/test/moment/week_year.js
src/test/moment/zone_switching.js
src/test/moment/zones.js

index 069b90da608d8d54b7f31545c2bee7407285f63e..45bf2e550797fc5fec8b064bc15505666833418d 100644 (file)
@@ -106,12 +106,12 @@ test('format week', function (assert) {
 
 test('format week on US calendar', function (assert) {
     // Tests, whether the weekday names are correct, even if the week does not start on Monday
-    moment.locale('lt', {week: {dow: 0, doy: 6}});
+    moment.updateLocale('lt', {week: {dow: 0, doy: 6}});
     var expected = 'sekmadienis Sek S_pirmadienis Pir P_antradienis Ant A_trečiadienis Tre T_ketvirtadienis Ket K_penktadienis Pen Pn_šeštadienis Šeš Š'.split('_'), i;
     for (i = 0; i < expected.length; i++) {
         assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
     }
-    moment.locale('lt', {week: {dow: 1, doy: 4}});
+    moment.updateLocale('lt', null);
 });
 
 test('from', function (assert) {
index ec7e316839b8d8976303aea0bf53655fb4c41029..da1f22d67066c83cc5d8559a17645596944d4eec 100644 (file)
@@ -80,6 +80,9 @@ test('add long singular reverse args', function (assert) {
 
 test('add string long reverse args', function (assert) {
     var a = moment(), b;
+
+    test.expectedDeprecations('moment().add(period, number)');
+
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -104,6 +107,9 @@ test('add string long reverse args', function (assert) {
 
 test('add string long singular reverse args', function (assert) {
     var a = moment(), b;
+
+    test.expectedDeprecations('moment().add(period, number)');
+
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -128,6 +134,8 @@ test('add string long singular reverse args', function (assert) {
 
 test('add string short reverse args', function (assert) {
     var a = moment();
+    test.expectedDeprecations('moment().add(period, number)');
+
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -210,8 +218,10 @@ test('add string short', function (assert) {
     assert.equal(a.add(1, 'Q').month(), 1, 'Add quarter');
 });
 
-test('add strings string short args', function (assert) {
+test('add strings string short reversed', function (assert) {
     var a = moment();
+    test.expectedDeprecations('moment().add(period, number)');
+
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -231,8 +241,10 @@ test('add strings string short args', function (assert) {
     assert.equal(a.add('Q', '1').month(), 1, 'Add quarter');
 });
 
-test('subtract strings string short args', function (assert) {
+test('subtract strings string short reversed', function (assert) {
     var a = moment();
+    test.expectedDeprecations('moment().subtract(period, number)');
+
     a.year(2011);
     a.month(9);
     a.date(12);
index 02181e40b668c76e2e6c7d5f2499dd96fe046ae4..2af09d21365b5bc4bf43c57aa0d1f1c5c11eb122 100644 (file)
@@ -664,6 +664,7 @@ test('parsing week year/week/weekday (dow 6, doy 12)', function (assert) {
     assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
     assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
     assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+    moment.defineLocale('dow:6,doy:12', null);
 });
 
 test('parsing ISO with Z', function (assert) {
@@ -952,6 +953,7 @@ test('parsing localized weekdays', function (assert) {
         ver('1999 37 Di', 'gggg ww dd', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
     }
     finally {
+        moment.defineLocale('dow:1,doy:4', null);
         moment.locale('en');
     }
 });
index 455ab9fddf7e7bfcf1bda555c428ab952064d59c..eaf23cad724337d8881117e10b016cc6b320feae 100644 (file)
@@ -5,6 +5,8 @@ import moment from '../../moment';
 module('deprecate');
 
 test('deprecate', function (assert) {
+    // NOTE: hooks inside deprecate.js and moment are different, so this is can
+    // not be test.expectedDeprecations(...)
     var fn = function () {};
     var deprecatedFn = deprecate('testing deprecation', fn);
     deprecatedFn();
index eaf2c263be9e526fcbc2f8450f178dc98d004ea6..03bf5d61583d671e0ae8f1e0a5f451899a72e8ff 100644 (file)
@@ -280,6 +280,8 @@ test('toString acts as toISOString', function (assert) {
 });
 
 test('toIsoString deprecation', function (assert) {
+    test.expectedDeprecations('toIsoString()');
+
     assert.equal(moment.duration({}).toIsoString(), moment.duration({}).toISOString(), 'toIsoString delegates to toISOString');
 });
 
index 6b7f26b0a152ba6f5e29d9742c9bfd552fd2839e..dc8d6cea7ded8813e491c1f1e66a6672013cd15b 100644 (file)
@@ -242,7 +242,7 @@ test('week year formats', function (assert) {
         '405-12-31': '0405-52'
     }, i, isoWeekYear, formatted5, formatted4, formatted2;
 
-    moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
+    moment.defineLocale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
 
     for (i in cases) {
         isoWeekYear = cases[i].split('-')[0];
@@ -253,6 +253,7 @@ test('week year formats', function (assert) {
         formatted2 = moment(i, 'YYYY-MM-DD').format('gg');
         assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': gg should be ' + isoWeekYear + ', but ' + formatted2);
     }
+    moment.defineLocale('dow:1,doy:4', null);
 });
 
 test('iso weekday formats', function (assert) {
@@ -266,7 +267,7 @@ test('iso weekday formats', function (assert) {
 });
 
 test('weekday formats', function (assert) {
-    moment.locale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
+    moment.defineLocale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
     assert.equal(moment([1985, 1,  6]).format('e'), '0', 'Feb  6 1985 is Wednesday -- 0th day');
     assert.equal(moment([2029, 8, 20]).format('e'), '1', 'Sep 20 2029 is Thursday  -- 1st day');
     assert.equal(moment([2013, 3, 26]).format('e'), '2', 'Apr 26 2013 is Friday    -- 2nd day');
@@ -274,6 +275,7 @@ test('weekday formats', function (assert) {
     assert.equal(moment([1970, 0,  4]).format('e'), '4', 'Jan  4 1970 is Sunday    -- 4th day');
     assert.equal(moment([2001, 4, 14]).format('e'), '5', 'May 14 2001 is Monday    -- 5th day');
     assert.equal(moment([2000, 0,  4]).format('e'), '6', 'Jan  4 2000 is Tuesday   -- 6th day');
+    moment.defineLocale('dow: 3,doy: 5', null);
 });
 
 test('toString is just human readable format', function (assert) {
@@ -282,13 +284,13 @@ test('toString is just human readable format', function (assert) {
 });
 
 test('toJSON skips postformat', function (assert) {
-    moment.locale('postformat', {
+    moment.defineLocale('postformat', {
         postformat: function (s) {
             s.replace(/./g, 'X');
         }
     });
     assert.equal(moment.utc([2000, 0, 1]).toJSON(), '2000-01-01T00:00:00.000Z', 'toJSON doesn\'t postformat');
-    moment.locale('postformat', null);
+    moment.defineLocale('postformat', null);
 });
 
 test('calendar day timezone', function (assert) {
index ac21854acf59a2eb01418c228b5c25c0778090b3..6f7b5216dc8a1fc6538e92fb01712d48280a6d60 100644 (file)
@@ -36,6 +36,8 @@ test('getters programmatic', function (assert) {
 
 test('setters plural', function (assert) {
     var a = moment();
+    test.expectedDeprecations('years accessor', 'months accessor', 'dates accessor');
+
     a.years(2011);
     a.months(9);
     a.dates(12);
index 0d62c75f88d37b4bc2261a25cd04d4cf601c3aa8..e10e6503fd180d96cafb4b1bedf1102a1ee1db43 100644 (file)
@@ -37,6 +37,8 @@ test('invalid operations', function (assert) {
         invalid,
         valid = moment();
 
+    test.expectedDeprecations('moment().min', 'moment().max');
+
     for (i = 0; i < invalids.length; ++i) {
         invalid = invalids[i];
 
index b41f6776843c0378038efb5b41beeeb836d1c1fb..3d320ad46038e27b39a6674ab19870a365b4ea63 100644 (file)
@@ -139,10 +139,12 @@ test('library localeData', function (assert) {
 });
 
 test('library deprecations', function (assert) {
+    test.expectedDeprecations('moment.lang');
     moment.lang('dude', {months: ['Movember']});
     assert.equal(moment.locale(), 'dude', 'setting the lang sets the locale');
     assert.equal(moment.lang(), moment.locale());
     assert.equal(moment.langData(), moment.localeData(), 'langData is localeData');
+    moment.defineLocale('dude', null);
 });
 
 test('defineLocale', function (assert) {
@@ -150,18 +152,21 @@ test('defineLocale', function (assert) {
     moment.defineLocale('dude', {months: ['Movember']});
     assert.equal(moment().locale(), 'dude', 'defineLocale also sets it');
     assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
+    moment.defineLocale('dude', null);
 });
 
 test('locales', function (assert) {
     moment.defineLocale('dude', {months: ['Movember']});
     assert.equal(true, !!~moment.locales().indexOf('dude'), 'locales returns an array of defined locales');
     assert.equal(true, !!~moment.locales().indexOf('en'), 'locales should always include english');
+    moment.defineLocale('dude', null);
 });
 
 test('library convenience', function (assert) {
     moment.locale('something', {week: {dow: 3}});
     moment.locale('something');
     assert.equal(moment.locale(), 'something', 'locale can be used to create the locale too');
+    moment.defineLocale('something', null);
 });
 
 test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
@@ -169,6 +174,7 @@ test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
     moment.locale('something');
     assert.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
     assert.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');
+    moment.defineLocale('something', null);
 });
 
 test('instance locale method', function (assert) {
@@ -239,6 +245,7 @@ test('changing the global locale doesn\'t affect existing duration instances', f
 });
 
 test('duration deprecations', function (assert) {
+    test.expectedDeprecations('moment().lang()');
     assert.equal(moment.duration().lang(), moment.duration().localeData(), 'duration.lang is the same as duration.localeData');
 });
 
@@ -330,6 +337,7 @@ test('instance locale used with from', function (assert) {
 test('instance localeData', function (assert) {
     moment.defineLocale('dude', {week: {dow: 3}});
     assert.equal(moment().locale('dude').localeData()._week.dow, 3);
+    moment.defineLocale('dude', null);
 });
 
 test('month name callback function', function (assert) {
@@ -357,6 +365,8 @@ test('month name callback function', function (assert) {
 });
 
 test('changing parts of a locale config', function (assert) {
+    test.expectedDeprecations('defineLocaleOverride');
+
     moment.locale('partial-lang', {
         months : 'a b c d e f g h i j k l'.split(' ')
     });
@@ -368,6 +378,8 @@ test('changing parts of a locale config', function (assert) {
     });
 
     assert.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set locale values after creating the localeuage');
+
+    moment.defineLocale('partial-lang', null);
 });
 
 test('start/endOf week feature for first-day-is-monday locales', function (assert) {
@@ -380,6 +392,7 @@ test('start/endOf week feature for first-day-is-monday locales', function (asser
     moment.locale('monday-lang');
     assert.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for locale monday-lang first day of the week should be monday');
     assert.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for locale monday-lang last day of the week should be sunday');
+    moment.defineLocale('monday-lang', null);
 });
 
 test('meridiem parsing', function (assert) {
@@ -393,6 +406,7 @@ test('meridiem parsing', function (assert) {
     moment.locale('meridiem-parsing');
     assert.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
     assert.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
+    moment.defineLocale('meridiem-parsing', null);
 });
 
 test('invalid date formatting', function (assert) {
@@ -402,12 +416,14 @@ test('invalid date formatting', function (assert) {
 
     assert.equal(moment.invalid().format(), 'KHAAAAAAAAAAAN!');
     assert.equal(moment.invalid().format('YYYY-MM-DD'), 'KHAAAAAAAAAAAN!');
+    moment.defineLocale('has-invalid', null);
 });
 
 test('return locale name', function (assert) {
     var registered = moment.locale('return-this', {});
 
     assert.equal(registered, 'return-this', 'returns the locale configured');
+    moment.locale('return-this', null);
 });
 
 test('changing the global locale doesn\'t affect existing instances', function (assert) {
@@ -417,6 +433,7 @@ test('changing the global locale doesn\'t affect existing instances', function (
 });
 
 test('setting a language on instance returns the original moment for chaining', function (assert) {
+    test.expectedDeprecations('moment().lang()');
     var mom = moment();
 
     assert.equal(mom.lang('fr'), mom, 'setting the language (lang) returns the original moment for chaining');
@@ -424,6 +441,7 @@ test('setting a language on instance returns the original moment for chaining',
 });
 
 test('lang(key) changes the language of the instance', function (assert) {
+    test.expectedDeprecations('moment().lang()');
     var m = moment().month(0);
     m.lang('fr');
     assert.equal(m.locale(), 'fr', 'm.lang(key) changes instance locale');
@@ -447,6 +465,7 @@ test('moment().locale with missing key doesn\'t change locale', function (assert
 });
 
 test('moment().lang with missing key doesn\'t change locale', function (assert) {
+    test.expectedDeprecations('moment().lang()');
     assert.equal(moment().lang('boo').localeData(), moment.localeData(),
             'preserve global locale in case of bad locale id');
 });
index 13ca2e9cf1975a4442253e554e737f22ce56c716..dbac84bd5901a70f5f0c6ec8375998724f9397fc 100644 (file)
@@ -110,8 +110,7 @@ test('ordinal', function (assert) {
     moment.defineLocale('ordinal-2', {
         ordinal : '%dx'
     });
-    moment.defineLocale('ordinal-2', {
-        parentLocale: 'ordinal-2',
+    moment.updateLocale('ordinal-2', {
         ordinal : function (num) {
             return num + 'y';
         }
index b43fffa6d550197326d74c200591699531ec3950..4f09f2eb74a18852b1fd5e8c49081a33067daae9 100644 (file)
@@ -41,6 +41,9 @@ module('preparse and postformat', {
                 });
             }
         });
+    },
+    teardown: function () {
+        moment.defineLocale('symbol', null);
     }
 });
 
index 6dc111f67e111171324757607562203cbf796e80..64a0bb12ca10b7368d21862c69f0aeef114af3bf 100644 (file)
@@ -13,7 +13,7 @@ test('utc and local', function (assert) {
 
     // local
     m.local();
-    if (m.zone() > 180) {
+    if (m.utcOffset() < -180) {
         assert.equal(m.date(), 1, 'the date should be correct for local');
         assert.equal(m.day(), 2, 'the day should be correct for local');
     } else {
index 1390f5ba747922829be0085a112dbedd4fde2307..522ce884757741685451d27e6c12889746275c64 100644 (file)
@@ -66,16 +66,18 @@ test('week year', function (assert) {
 
 // Verifies that the week number, week day computation is correct for all dow, doy combinations
 test('week year roundtrip', function (assert) {
-    var dow, doy, wd, m;
+    var dow, doy, wd, m, localeName;
     for (dow = 0; dow < 7; ++dow) {
         for (doy = dow; doy < dow + 7; ++doy) {
             for (wd = 0; wd < 7; ++wd) {
-                moment.locale('dow: ' + dow + ', doy: ' + doy, {week: {dow: dow, doy: doy}});
+                localeName = 'dow: ' + dow + ', doy: ' + doy;
+                moment.locale(localeName, {week: {dow: dow, doy: doy}});
                 // We use the 10th week as the 1st one can spill to the previous year
                 m = moment('2015 10 ' + wd, 'gggg w d', true);
                 assert.equal(m.format('gggg w d'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
                 m = moment('2015 10 ' + wd, 'gggg w e', true);
                 assert.equal(m.format('gggg w e'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
+                moment.defineLocale(localeName, null);
             }
         }
     }
@@ -90,6 +92,7 @@ test('week numbers 2012/2013', function (assert) {
     assert.equal(2, moment('2013-01-11', 'YYYY-MM-DD').week(), '2013-01-11 is week 2'); // 53 -- should be 2
     assert.equal(3, moment('2013-01-12', 'YYYY-MM-DD').week(), '2013-01-12 is week 3'); // 1 -- should be 3
     assert.equal(52, moment('2012-01-01', 'YYYY-MM-DD').weeksInYear(), 'weeks in 2012 are 52'); // 52
+    moment.defineLocale('dow: 6, doy: 12', null);
 });
 
 test('weeks numbers dow:1 doy:4', function (assert) {
@@ -134,6 +137,7 @@ test('weeks numbers dow:1 doy:4', function (assert) {
     assert.equal(moment([2011,  0,  3]).week(),  1, 'Jan  3 2011 should be week 1');
     assert.equal(moment([2011,  0,  9]).week(),  1, 'Jan  9 2011 should be week 1');
     assert.equal(moment([2011,  0, 10]).week(),  2, 'Jan 10 2011 should be week 2');
+    moment.defineLocale('dow: 1, doy: 4', null);
 });
 
 test('weeks numbers dow:6 doy:12', function (assert) {
@@ -176,6 +180,7 @@ test('weeks numbers dow:6 doy:12', function (assert) {
     assert.equal(moment([2011, 0,  8]).week(), 2, 'Jan  8 2011 should be week 2');
     assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
     assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
+    moment.defineLocale('dow: 6, doy: 12', null);
 });
 
 test('weeks numbers dow:1 doy:7', function (assert) {
@@ -220,6 +225,7 @@ test('weeks numbers dow:1 doy:7', function (assert) {
     assert.equal(moment([2011,  0,  3]).week(), 2, 'Jan  3 2011 should be week 2');
     assert.equal(moment([2011,  0,  9]).week(), 2, 'Jan  9 2011 should be week 2');
     assert.equal(moment([2011,  0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
+    moment.defineLocale('dow: 1, doy: 7', null);
 });
 
 test('weeks numbers dow:0 doy:6', function (assert) {
@@ -264,6 +270,7 @@ test('weeks numbers dow:0 doy:6', function (assert) {
     assert.equal(moment([2011,  0,  2]).week(), 2, 'Jan  2 2011 should be week 2');
     assert.equal(moment([2011,  0,  8]).week(), 2, 'Jan  8 2011 should be week 2');
     assert.equal(moment([2011,  0,  9]).week(), 3, 'Jan  9 2011 should be week 3');
+    moment.defineLocale('dow: 0, doy: 6', null);
 });
 
 test('week year overflows', function (assert) {
index d3d66e0f61633e932170b803e7c07cb7d26c6821..61ff8213102b07d44c320db849ea284faf06190c 100644 (file)
@@ -17,6 +17,7 @@ test('local to utc, keepLocalTime = false', function (assert) {
 });
 
 test('local to zone, keepLocalTime = true', function (assert) {
+    test.expectedDeprecations('moment().zone');
     var m = moment(),
         fmt = 'YYYY-DD-MM HH:mm:ss',
         z;
@@ -31,6 +32,7 @@ test('local to zone, keepLocalTime = true', function (assert) {
 });
 
 test('local to zone, keepLocalTime = false', function (assert) {
+    test.expectedDeprecations('moment().zone');
     var m = moment(),
         z;
 
@@ -65,6 +67,7 @@ test('utc to local, keepLocalTime = false', function (assert) {
 });
 
 test('zone to local, keepLocalTime = true', function (assert) {
+    test.expectedDeprecations('moment().zone');
     // Don't test near the spring DST transition
     if (isNearSpringDST()) {
         expect(0);
@@ -87,6 +90,7 @@ test('zone to local, keepLocalTime = true', function (assert) {
 });
 
 test('zone to local, keepLocalTime = false', function (assert) {
+    test.expectedDeprecations('moment().zone');
     var m = moment(),
         z;
 
index e9e0b3414e7089317e2ca1ba465815843afbc98a..11ede118438e475bd904a5c4f78329470ebe4608 100644 (file)
@@ -1,7 +1,11 @@
 import { module, test } from '../qunit';
 import moment from '../../moment';
 
-module('zones');
+module('zones', {
+    'setup': function () {
+        test.expectedDeprecations('moment().zone');
+    }
+});
 
 test('set zone', function (assert) {
     var zone = moment();
@@ -360,6 +364,7 @@ test('isDST', function (assert) {
 });
 
 test('zone names', function (assert) {
+    test.expectedDeprecations();
     assert.equal(moment().zoneAbbr(),   '', 'Local zone abbr should be empty');
     assert.equal(moment().format('z'),  '', 'Local zone formatted abbr should be empty');
     assert.equal(moment().zoneName(),   '', 'Local zone name should be empty');
@@ -422,6 +427,7 @@ test('parse zone static', function (assert) {
 });
 
 test('parse zone with more arguments', function (assert) {
+    test.expectedDeprecations();
     var m;
     m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
     assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');