Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
test(changeLanguage): fix a failing test case + better deprecation me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
urish committed Sep 7, 2014
1 parent cf99e17 commit f7146be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 4 additions & 7 deletions angular-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,18 @@
}
return result;
};

/**
* @ngdoc function
* @name angularMoment.service.amMoment#changeLanguage
* @methodOf angularMoment.service.amMoment
* @deprecated Please use changeLocale() instead.
*
* @description
* Deprecated. Please use changeLocale()
* Changes the language for moment.js and updates all the am-time-ago directive instances
* with the new language.
*
* @param {string} lang 2-letter language code (e.g. en, es, ru, etc.)
* Deprecated. Please use changeLocale() instead.
*/
this.changeLanguage = function (lang) {
$log.warn('angular-moment: Usage of angular-moment.changeLanguage() is deprecated. Please use changeLocale()');
$log.warn('angular-moment: Usage of amMoment.changeLanguage() is deprecated. Please use changeLocale()');
return that.changeLocale(lang);
};

Expand Down
10 changes: 4 additions & 6 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('module angularMoment', function () {
originalAngularMomentConfig = angular.copy(angularMomentConfig);

// Ensure the locale of moment.js is set to en by default
moment.lang('en');
(moment.locale || moment.lang)('en');
// Add a sample timezone for tests
moment.tz.add('Pacific/Tahiti|LMT TAHT|9W.g a0|01|-2joe1.I');
}));
Expand Down Expand Up @@ -499,16 +499,14 @@ describe('module angularMoment', function () {
expect(eventBroadcasted).toBe(false);
});
});



describe('#changeLanguage', function () {
it('should issue a warning about changeLanguage() deprecation', inject(function ($log) {
amMoment.changeLocale('fr');
spyOn($log, 'warn');
expect($log.warn).toHaveBeenCalledWith('angular-moment: Usage of changeLanguage() is deprecated. Please use changeLocale()');
amMoment.changeLanguage('fr');
expect($log.warn).toHaveBeenCalledWith('angular-moment: Usage of amMoment.changeLanguage() is deprecated. Please use changeLocale()');
}));
});


describe('#preprocessDate', function () {
it('should call a custom preprocessor that was registered on amMoment.preprocessors', function () {
Expand Down

0 comments on commit f7146be

Please sign in to comment.