-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtransportadorTest.js
146 lines (118 loc) · 4.3 KB
/
transportadorTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
'use strict';
var Pessoa = require('../lib/pessoa'),
Endereco = require('../lib/endereco'),
Transportador = require('../lib/transportador'),
transportador;
module.exports = {
setUp: function(callback) {
transportador = new Transportador();
callback();
},
tearDown: function(callback) {
callback();
},
'Verifica que transportador herda de pessoa': function(test) {
var transportador = new Transportador();
test.ok(transportador instanceof Pessoa);
test.done();
},
'Verifica que tem um endereço vazio por padrão': function(test) {
test.ok(new Transportador().getEndereco() instanceof Endereco);
test.done();
},
comCodigoAntt: {
'É possível definir': function(test) {
test.doesNotThrow(function() {
transportador.comCodigoAntt('ABC123');
});
test.done();
}
},
getCodigoAntt: {
'Retorna string vazia antes de ser definido': function(test) {
test.equal(transportador.getCodigoAntt(), '');
test.done();
},
'É possível recuperar o valor definido': function(test) {
transportador.comCodigoAntt('ABC123');
test.equal(transportador.getCodigoAntt(), 'ABC123');
test.done();
},
'Retorna valor em caixa alta mesmo passado em caixa baixa': function(test) {
transportador.comCodigoAntt('abcdefgh');
test.equal(transportador.getCodigoAntt(), 'ABCDEFGH');
test.done();
},
},
comPlacaDoVeiculo: {
'É possível definir': function(test) {
test.doesNotThrow(function() {
transportador.comPlacaDoVeiculo('ABC-1234');
});
test.done();
},
'Lança exceção ao passar placa inválida': function(test) {
test.throws(function() {
transportador.comPlacaDoVeiculo('Não é uma placa');
});
test.done();
},
},
getPlacaDoVeiculo: {
'Retorna string vazia antes de ser definido': function(test) {
test.equal(transportador.getPlacaDoVeiculo(), '');
test.done();
},
'É possível recuperar o valor definido': function(test) {
transportador.comPlacaDoVeiculo('ABC-1234');
test.equal(transportador.getPlacaDoVeiculo(), 'ABC-1234');
test.done();
},
'Retorna placa em caixa alta mesmo quando definida em caixa baixa': function(test) {
transportador.comPlacaDoVeiculo('abc-1234');
test.equal(transportador.getPlacaDoVeiculo(), 'ABC-1234');
test.done();
},
},
getPlacaDoVeiculoFormatada: {
'Retorna string vazia antes de ser definido': function(test) {
test.equal(transportador.getPlacaDoVeiculoFormatada(), '');
test.done();
},
'Aplica formatação corretamente': function(test) {
transportador.comPlacaDoVeiculo('ABC1234');
test.equal(transportador.getPlacaDoVeiculoFormatada(), 'ABC-1234');
test.done();
}
},
comUfDaPlacaDoVeiculo: {
'É possível definir': function(test) {
test.doesNotThrow(function() {
transportador.comUfDaPlacaDoVeiculo('DF');
});
test.done();
},
'Lança exceção ao tentar definir um estado inválido': function(test) {
test.throws(function() {
transportador.comUfDaPlacaDoVeiculo('ZZ');
});
test.done();
},
},
getUfDaPlacaDoVeiculo: {
'Retorna string vazia antes de ser definido': function(test) {
test.equal(transportador.getUfDaPlacaDoVeiculo(), '');
test.done();
},
'É possível recuperar o valor definido': function(test) {
transportador.comUfDaPlacaDoVeiculo('DF');
test.equal(transportador.getUfDaPlacaDoVeiculo(), 'DF');
test.done();
},
'Retorna a UF em caixa alta mesmo tendo sido definida em caixa baixa': function(test) {
transportador.comUfDaPlacaDoVeiculo('df');
test.equal(transportador.getUfDaPlacaDoVeiculo(), 'DF');
test.done();
},
},
};