feat(locale): add getPluralCat function

This commit is contained in:
Di Peng 2011-08-24 11:00:18 -07:00 committed by Igor Minar
parent 3ba90003b4
commit 0da4902e9d
2 changed files with 15 additions and 0 deletions

View file

@ -58,6 +58,13 @@ angularServiceInject('$locale', function() {
shortDate: 'M/d/yy',
mediumTime: 'h:mm:ss a',
shortTime: 'h:mm a'
},
pluralCat: function(num) {
if (num === 1) {
return 'one';
}
return 'other';
}
};
});

View file

@ -36,5 +36,13 @@ describe('$locale', function() {
expect(datetime.MONTH.length).toBe(12);
expect(datetime.AMPMS.length).toBe(2);
});
it('should return correct plural types', function() {
expect($locale.pluralCat(-1)).toBe('other');
expect($locale.pluralCat(0)).toBe('other');
expect($locale.pluralCat(2)).toBe('other');
expect($locale.pluralCat(1)).toBe('one');
})
});