diff --git a/src/global/scientific-notation/scientific-notation.test.js b/src/global/scientific-notation/scientific-notation.test.js index 9e5803d3..021352f0 100644 --- a/src/global/scientific-notation/scientific-notation.test.js +++ b/src/global/scientific-notation/scientific-notation.test.js @@ -31,6 +31,36 @@ describe('ui-scientific-notation-mask', function() { expect(model.$viewValue).toBe('1.23e4'); }); + it('should format initial model values with 0 decimals', function() { + var input = TestUtil.compile('', { + model: 12345.67890123456 + }); + + var model = input.controller('ngModel'); + expect(model.$viewValue).toBe('1e4'); + }); + + it('should format initial model values with 3 decimals', function() { + var input = TestUtil.compile('', { + model: 12345.67890123456 + }); + + var model = input.controller('ngModel'); + expect(model.$viewValue).toBe('1.235e4'); + }); + + it('should format input', function() { + var input = TestUtil.compile(''); + var model = input.controller('ngModel'); + + input.val('123').triggerHandler('input'); + expect(model.$viewValue).toBe('1.23'); + expect(model.$modelValue).toBe(1.23); + input.val('1.2345').triggerHandler('input'); + expect(model.$viewValue).toBe('1.23e45'); + expect(model.$modelValue).toBe(1.23e45); + }); + it('should handle corner cases', angular.mock.inject(function($rootScope) { var input = TestUtil.compile(''); var model = input.controller('ngModel');