Skip to content

Commit

Permalink
refactor: improve e2e tests output
Browse files Browse the repository at this point in the history
  • Loading branch information
assisrafael committed Sep 24, 2017
1 parent dca19b2 commit 7abc08d
Show file tree
Hide file tree
Showing 20 changed files with 1,414 additions and 1,449 deletions.
2 changes: 1 addition & 1 deletion src/br/br-masks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var m = angular.module('ui.utils.masks.br', [
require('../helpers'),
])
.directive('uiBrBoletoBancarioMask', require('./boleto-bancario/boleto-bancario'))
.directive('uiBrCarPlateMask', require('./car-plate/car-plate'))
.directive('uiBrCepMask', require('./cep/cep'))
.directive('uiBrCnpjMask', require('./cnpj/cnpj'))
.directive('uiBrCpfMask', require('./cpf/cpf'))
.directive('uiBrCpfcnpjMask', require('./cpf-cnpj/cpf-cnpj'))
.directive('uiBrIeMask', require('./inscricao-estadual/ie'))
.directive('uiNfeAccessKeyMask', require('./nfe/nfe'))
.directive('uiBrCarPlateMask', require('./car-plate/car-plate'))
.directive('uiBrPhoneNumber', require('./phone/br-phone'));

module.exports = m.name;
66 changes: 32 additions & 34 deletions src/br/car-plate/car-plate.spec.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
'use strict';

describe('ui.utils.masks.br.car-plate', function() {
describe('uiBrCarPlateMask', function() {
it('should load the demo page', function() {
browser.get('/src/br/car-plate/car-plate.html');
expect(browser.getTitle()).toEqual('Car Plate Spec');
});

describe('ui-br-car-plate-mask:', function() {
it('should apply a Car Plate mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;
it('should apply a Car Plate mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;

var tests = [
{key:'@', viewValue:'', modelValue:''},
{key:'A', viewValue:'A', modelValue:'A'},
{key:'B', viewValue:'AB', modelValue:'AB'},
{key:'C', viewValue:'ABC', modelValue:'ABC'},
{key:'-', viewValue:'ABC', modelValue:'ABC'},
{key:'2', viewValue:'ABC-2', modelValue:'ABC2'},
{key:'0', viewValue:'ABC-20', modelValue:'ABC20'},
{key:'1', viewValue:'ABC-201', modelValue:'ABC201'},
{key:'0', viewValue:'ABC-2010', modelValue:'ABC2010'},
{key:'9', viewValue:'ABC-2010', modelValue:'ABC2010'},
{key:BS, viewValue:'ABC-201', modelValue:'ABC201'},
{key:BS, viewValue:'ABC-20', modelValue:'ABC20'},
{key:BS, viewValue:'ABC-2', modelValue:'ABC2'},
{key:BS, viewValue:'ABC', modelValue:'ABC'},
{key:BS, viewValue:'AB', modelValue:'AB'},
{key:BS, viewValue:'A', modelValue:'A'},
];
var tests = [
{key:'@', viewValue:'', modelValue:''},
{key:'A', viewValue:'A', modelValue:'A'},
{key:'B', viewValue:'AB', modelValue:'AB'},
{key:'C', viewValue:'ABC', modelValue:'ABC'},
{key:'-', viewValue:'ABC', modelValue:'ABC'},
{key:'2', viewValue:'ABC-2', modelValue:'ABC2'},
{key:'0', viewValue:'ABC-20', modelValue:'ABC20'},
{key:'1', viewValue:'ABC-201', modelValue:'ABC201'},
{key:'0', viewValue:'ABC-2010', modelValue:'ABC2010'},
{key:'9', viewValue:'ABC-2010', modelValue:'ABC2010'},
{key:BS, viewValue:'ABC-201', modelValue:'ABC201'},
{key:BS, viewValue:'ABC-20', modelValue:'ABC20'},
{key:BS, viewValue:'ABC-2', modelValue:'ABC2'},
{key:BS, viewValue:'ABC', modelValue:'ABC'},
{key:BS, viewValue:'AB', modelValue:'AB'},
{key:BS, viewValue:'A', modelValue:'A'},
];

var input = element(by.model('carPlate')),
value = element(by.binding('carPlate'));
var input = element(by.model('carPlate')),
value = element(by.binding('carPlate'));

for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});
for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});

it('should apply a Car Plate mask in a model with default value:', function() {
var input = element(by.model('initializedCarPlate'));
it('should apply a Car Plate mask in a model with default value:', function() {
var input = element(by.model('initializedCarPlate'));

expect(input.getAttribute('value')).toEqual('ABC-2010');
});
expect(input.getAttribute('value')).toEqual('ABC-2010');
});
});
70 changes: 34 additions & 36 deletions src/br/cep/cep.spec.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
'use strict';

describe('ui.utils.masks.br.cep', function() {
describe('uiBrCepMask', function() {
it('should load the demo page', function() {
browser.get('/src/br/cep/cep.html');
expect(browser.getTitle()).toEqual('CEP Spec');
});

describe('ui-br-cep-mask:', function() {
it('should apply a CEP mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;
it('should apply a CEP mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;

var tests = [
{key:'@', viewValue:'', modelValue:''},
{key:'3', viewValue:'3', modelValue:'3'},
{key:'0', viewValue:'30', modelValue:'30'},
{key:'1', viewValue:'301', modelValue:'301'},
{key:'1', viewValue:'3011', modelValue:'3011'},
{key:'2', viewValue:'30112', modelValue:'30112'},
{key:'-', viewValue:'30112', modelValue:'30112'},
{key:'0', viewValue:'30112-0', modelValue:'301120'},
{key:'1', viewValue:'30112-01', modelValue:'3011201'},
{key:'0', viewValue:'30112-010', modelValue:'30112010'},
{key:'9', viewValue:'30112-010', modelValue:'30112010'},
{key:BS, viewValue:'30112-01', modelValue:'3011201'},
{key:BS, viewValue:'30112-0', modelValue:'301120'},
{key:BS, viewValue:'30112', modelValue:'30112'},
{key:BS, viewValue:'3011', modelValue:'3011'},
{key:BS, viewValue:'301', modelValue:'301'},
{key:BS, viewValue:'30', modelValue:'30'},
{key:BS, viewValue:'3', modelValue:'3'}
];
var tests = [
{key:'@', viewValue:'', modelValue:''},
{key:'3', viewValue:'3', modelValue:'3'},
{key:'0', viewValue:'30', modelValue:'30'},
{key:'1', viewValue:'301', modelValue:'301'},
{key:'1', viewValue:'3011', modelValue:'3011'},
{key:'2', viewValue:'30112', modelValue:'30112'},
{key:'-', viewValue:'30112', modelValue:'30112'},
{key:'0', viewValue:'30112-0', modelValue:'301120'},
{key:'1', viewValue:'30112-01', modelValue:'3011201'},
{key:'0', viewValue:'30112-010', modelValue:'30112010'},
{key:'9', viewValue:'30112-010', modelValue:'30112010'},
{key:BS, viewValue:'30112-01', modelValue:'3011201'},
{key:BS, viewValue:'30112-0', modelValue:'301120'},
{key:BS, viewValue:'30112', modelValue:'30112'},
{key:BS, viewValue:'3011', modelValue:'3011'},
{key:BS, viewValue:'301', modelValue:'301'},
{key:BS, viewValue:'30', modelValue:'30'},
{key:BS, viewValue:'3', modelValue:'3'}
];

var input = element(by.model('cep')),
value = element(by.binding('cep'));
var input = element(by.model('cep')),
value = element(by.binding('cep'));

for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});
for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});

it('should apply a CEP mask in a model with default value:', function() {
var input = element(by.model('initializedCep'));
it('should apply a CEP mask in a model with default value:', function() {
var input = element(by.model('initializedCep'));

expect(input.getAttribute('value')).toEqual('30112-010');
});
expect(input.getAttribute('value')).toEqual('30112-010');
});
});
2 changes: 1 addition & 1 deletion src/br/cnpj/cnpj.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

describe('ui-br-cnpj:', function() {
describe('uiBrCnpjMask', function() {
it('should load the demo page', function() {
browser.get('/src/br/cnpj/cnpj.html');
expect(browser.getTitle()).toEqual('CNPJ Spec');
Expand Down
98 changes: 48 additions & 50 deletions src/br/cpf-cnpj/cpf-cnpj.spec.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,66 @@
'use strict';

describe('ui.utils.masks.cpfCnpj', function() {
describe('uiBrCpfcnpjMask', function() {
it('should load the demo page', function() {
browser.get('/src/br/cpf-cnpj/cpf-cnpj.html');
expect(browser.getTitle()).toEqual('CPF-CNPJ Spec');
});

describe('ui-br-cpfcnpj:', function() {
it('should apply a CPF/CNPJ mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;
it('should apply a CPF/CNPJ mask while the user is typping:', function() {
var BS = protractor.Key.BACK_SPACE;

var tests = [
{key:'1', viewValue:'1', modelValue: '1'},
{key:'3', viewValue:'13', modelValue: '13'},
{key:'8', viewValue:'138', modelValue: '138'},
{key:'8', viewValue:'138.8', modelValue: '1388'},
{key:'3', viewValue:'138.83', modelValue: '13883'},
{key:'8', viewValue:'138.838', modelValue: '138838'},
{key:'7', viewValue:'138.838.7', modelValue: '1388387'},
{key:'5', viewValue:'138.838.75', modelValue: '13883875'},
{key:'0', viewValue:'138.838.750', modelValue: '138838750'},
{key:'0', viewValue:'138.838.750-0', modelValue: '1388387500'},
{key:'0', viewValue:'138.838.750-00', modelValue: '13883875000'},
var tests = [
{key:'1', viewValue:'1', modelValue: '1'},
{key:'3', viewValue:'13', modelValue: '13'},
{key:'8', viewValue:'138', modelValue: '138'},
{key:'8', viewValue:'138.8', modelValue: '1388'},
{key:'3', viewValue:'138.83', modelValue: '13883'},
{key:'8', viewValue:'138.838', modelValue: '138838'},
{key:'7', viewValue:'138.838.7', modelValue: '1388387'},
{key:'5', viewValue:'138.838.75', modelValue: '13883875'},
{key:'0', viewValue:'138.838.750', modelValue: '138838750'},
{key:'0', viewValue:'138.838.750-0', modelValue: '1388387500'},
{key:'0', viewValue:'138.838.750-00', modelValue: '13883875000'},

{key:'1', viewValue:'13.883.875/0001', modelValue: '138838750001'},
{key:'2', viewValue:'13.883.875/0001-2', modelValue: '1388387500012'},
{key:'0', viewValue:'13.883.875/0001-20', modelValue: '13883875000120'},
{key:'0', viewValue:'13.883.875/0001-20', modelValue: '13883875000120'},
{key:BS, viewValue:'13.883.875/0001-2', modelValue: '1388387500012'},
{key:BS, viewValue:'13.883.875/0001', modelValue: '138838750001'},
{key:'1', viewValue:'13.883.875/0001', modelValue: '138838750001'},
{key:'2', viewValue:'13.883.875/0001-2', modelValue: '1388387500012'},
{key:'0', viewValue:'13.883.875/0001-20', modelValue: '13883875000120'},
{key:'0', viewValue:'13.883.875/0001-20', modelValue: '13883875000120'},
{key:BS, viewValue:'13.883.875/0001-2', modelValue: '1388387500012'},
{key:BS, viewValue:'13.883.875/0001', modelValue: '138838750001'},

{key:BS, viewValue:'138.838.750-00', modelValue: '13883875000'},
{key:BS, viewValue:'138.838.750-0', modelValue: '1388387500'},
{key:BS, viewValue:'138.838.750', modelValue: '138838750'},
{key:BS, viewValue:'138.838.75', modelValue: '13883875'},
{key:BS, viewValue:'138.838.7', modelValue: '1388387'},
{key:BS, viewValue:'138.838', modelValue: '138838'},
{key:BS, viewValue:'138.83', modelValue: '13883'},
{key:BS, viewValue:'138.8', modelValue: '1388'},
{key:BS, viewValue:'138', modelValue: '138'},
{key:BS, viewValue:'13', modelValue: '13'},
{key:BS, viewValue:'1', modelValue: '1'}
];
{key:BS, viewValue:'138.838.750-00', modelValue: '13883875000'},
{key:BS, viewValue:'138.838.750-0', modelValue: '1388387500'},
{key:BS, viewValue:'138.838.750', modelValue: '138838750'},
{key:BS, viewValue:'138.838.75', modelValue: '13883875'},
{key:BS, viewValue:'138.838.7', modelValue: '1388387'},
{key:BS, viewValue:'138.838', modelValue: '138838'},
{key:BS, viewValue:'138.83', modelValue: '13883'},
{key:BS, viewValue:'138.8', modelValue: '1388'},
{key:BS, viewValue:'138', modelValue: '138'},
{key:BS, viewValue:'13', modelValue: '13'},
{key:BS, viewValue:'1', modelValue: '1'}
];

var input = element(by.model('cpfcnpj')),
value = element(by.binding('cpfcnpj'));
var input = element(by.model('cpfcnpj')),
value = element(by.binding('cpfcnpj'));

for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});
for (var i = 0; i < tests.length; i++) {
input.sendKeys(tests[i].key);
expect(input.getAttribute('value')).toEqual(tests[i].viewValue);
expect(value.getText()).toEqual(tests[i].modelValue);
}
});

it('should apply a CPFCNPJ mask in a model with default CPF value:', function() {
var input = element(by.model('initializedCpfCnpj1'));
it('should apply a CPFCNPJ mask in a model with default CPF value:', function() {
var input = element(by.model('initializedCpfCnpj1'));

expect(input.getAttribute('value')).toEqual('563.383.329-58');
});
expect(input.getAttribute('value')).toEqual('563.383.329-58');
});

it('should apply a CPFCNPJ mask in a model with default CNPJ value:', function() {
var input = element(by.model('initializedCpfCnpj2'));
it('should apply a CPFCNPJ mask in a model with default CNPJ value:', function() {
var input = element(by.model('initializedCpfCnpj2'));

expect(input.getAttribute('value')).toEqual('23.212.161/0001-44');
});
expect(input.getAttribute('value')).toEqual('23.212.161/0001-44');
});
});
2 changes: 1 addition & 1 deletion src/br/cpf/cpf.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

describe('ui-br-cpf:', function() {
describe('uiBrCpfMask', function() {
it('should load the demo page', function() {
browser.get('/src/br/cpf/cpf.html');
expect(browser.getTitle()).toEqual('CPF Spec');
Expand Down
Loading

0 comments on commit 7abc08d

Please sign in to comment.