Skip to content

Commit

Permalink
fix(uiCreditCardMask): rename "uiCreditCard" to "uiCreditCardMask"
Browse files Browse the repository at this point in the history
BREAKING CHANGE the "ui-credit-card" mask was renamed to "ui-credit-card-mask"
  • Loading branch information
assisrafael committed Sep 24, 2017
1 parent 640aa7f commit 48ca80d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/global/credit-card/credit-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<body ng-app="app">
<form name="form" ng-controller="ctrl">
<h2>ui-br-phone-number</h2>
<input type="text" name="freeLinePhoneNumber" ng-model="freeLinePhoneNumber" ng-model-options="{allowInvalid:true}" ui-credit-card><br>
<input type="text" name="freeLinePhoneNumber" ng-model="freeLinePhoneNumber" ng-model-options="{allowInvalid:true}" ui-credit-card-mask><br>
<span ng-bind="freeLinePhoneNumber">-</span> - {{form.freeLinePhoneNumber.$error}}<br>
<br>
<input type="text" name="creditCard" ng-model="creditCard" ng-model-options="{allowInvalid:true}" ui-credit-card><br>
<input type="text" name="creditCard" ng-model="creditCard" ng-model-options="{allowInvalid:true}" ui-credit-card-mask><br>
<span ng-bind="creditCard">-</span> - {{form.creditCard.$error}}<br>
<br>
<input type="text" name="initializedCC" ng-model="initializedCC" ng-model-options="{allowInvalid:true}" ui-credit-card><br>
<input type="text" name="initializedCC" ng-model="initializedCC" ng-model-options="{allowInvalid:true}" ui-credit-card-mask><br>
<span ng-bind="initializedCC">-</span> - {{form.initializedCC.$error}}<br>
</form>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src/global/credit-card/credit-card.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

describe('uiCreditCard', function() {
describe('uiCreditCardMask', function() {
it('should load the demo page', function() {
browser.get('/src/global/credit-card/credit-card.html');
expect(browser.getTitle()).toEqual('Credit Card Spec');
Expand Down
15 changes: 7 additions & 8 deletions src/global/credit-card/credit-card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

require('../global-masks');

describe('ui-credit-card', function() {
describe('uiCreditCardMask', function() {
beforeEach(angular.mock.module('ui.utils.masks.global'));

it('should throw an error if used without ng-model', function() {
expect(function() {
TestUtil.compile('<input ui-credit-card>');
TestUtil.compile('<input ui-credit-card-mask>');
}).toThrow();
});

it('should register a $parser and a $formatter', function() {
var input = TestUtil.compile('<input ng-model="model">');
var model = input.controller('ngModel');

var maskedInput = TestUtil.compile('<input ng-model="maskedModel" ui-credit-card>');
var maskedInput = TestUtil.compile('<input ng-model="maskedModel" ui-credit-card-mask>');
var maskedModel = maskedInput.controller('ngModel');

expect(maskedModel.$parsers.length).toBe(model.$parsers.length + 1);
expect(maskedModel.$formatters.length).toBe(model.$formatters.length + 1);
});

it('should format initial model values', function() {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card>', {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card-mask>', {
model: '4242424242424242'
});

Expand All @@ -32,8 +32,7 @@ describe('ui-credit-card', function() {
});

it('should ignore non digits', function() {
var input = TestUtil.compile('<input ng-model="model" ng-model-options="{allowInvalid:true}"' +
' ui-credit-card>');
var input = TestUtil.compile('<input ng-model="model" ng-model-options="{allowInvalid:true}" ui-credit-card-mask>');
var model = input.controller('ngModel');

var tests = [
Expand All @@ -54,7 +53,7 @@ describe('ui-credit-card', function() {
});

it('should validate a credit card number', function() {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card>', {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card-mask>', {
model: '417900'
});

Expand All @@ -65,7 +64,7 @@ describe('ui-credit-card', function() {
});

it('should use the type of the model value (if initialized)', function() {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card>', {
var input = TestUtil.compile('<input ng-model="model" ui-credit-card-mask>', {
model: '7777333300008888'
});

Expand Down
2 changes: 1 addition & 1 deletion src/global/global-masks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var m = angular.module('ui.utils.masks.global', [])
.directive('uiCreditCard', require('./credit-card/credit-card'))
.directive('uiCreditCardMask', require('./credit-card/credit-card'))
.directive('uiDateMask', require('./date/date'))
.directive('uiMoneyMask', require('./money/money'))
.directive('uiNumberMask', require('./number/number'))
Expand Down

0 comments on commit 48ca80d

Please sign in to comment.