Skip to content

Commit

Permalink
test(uiScientificNotationMask): include missing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
assisrafael committed Sep 24, 2017
1 parent 613c78f commit ba6ba7e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/global/scientific-notation/scientific-notation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<input ng-model="model" ui-scientific-notation-mask="0">', {
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('<input ng-model="model" ui-scientific-notation-mask="3">', {
model: 12345.67890123456
});

var model = input.controller('ngModel');
expect(model.$viewValue).toBe('1.235e4');
});

it('should format input', function() {
var input = TestUtil.compile('<input ng-model="model" ui-scientific-notation-mask>');
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('<input ng-model="model" ui-scientific-notation-mask>');
var model = input.controller('ngModel');
Expand Down

0 comments on commit ba6ba7e

Please sign in to comment.