Skip to content

Commit 0c760ae

Browse files
committed
tests: adapt to stop using cepaberto service
1 parent cc4ce89 commit 0c760ae

File tree

2 files changed

+1
-68
lines changed

2 files changed

+1
-68
lines changed

test/e2e/cep-promise.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('cep-promise (E2E)', () => {
4848
message: 'Todos os serviços de CEP retornaram erro.',
4949
type: 'service_error',
5050
errors: [{
51-
message: 'CEP NAO ENCONTRADO',
51+
message: 'CEP INVÁLIDO',
5252
service: 'correios'
5353
}, {
5454
message: 'CEP não encontrado na base do ViaCEP.',

test/unit/cep-promise.spec.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ describe('cep-promise (unit)', () => {
2929
nock('https://viacep.com.br')
3030
.get('/ws/05010000/json/')
3131
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
32-
nock('http://www.cepaberto.com')
33-
.get('/api/v2/ceps.json?cep=05010000')
34-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
3532

3633
const cepPromise = cep('05010000')
3734
expect(cepPromise.then).to.be.a('function')
@@ -124,9 +121,6 @@ describe('cep-promise (unit)', () => {
124121
nock('https://viacep.com.br')
125122
.get('/ws/05010000/json/')
126123
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
127-
nock('http://www.cepaberto.com')
128-
.get('/api/v2/ceps.json?cep=05010000')
129-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
130124

131125
return expect(cep('05010000')).to.eventually.deep.equal({
132126
cep: '05010000',
@@ -146,9 +140,6 @@ describe('cep-promise (unit)', () => {
146140
nock('https://viacep.com.br')
147141
.get('/ws/05010000/json/')
148142
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
149-
nock('http://www.cepaberto.com')
150-
.get('/api/v2/ceps.json?cep=05010000')
151-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
152143

153144
return expect(cep(5010000)).to.eventually.deep.equal({
154145
cep: '05010000',
@@ -168,9 +159,6 @@ describe('cep-promise (unit)', () => {
168159
nock('https://viacep.com.br')
169160
.get('/ws/05010000/json/')
170161
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json'))
171-
nock('http://www.cepaberto.com')
172-
.get('/api/v2/ceps.json?cep=05010000')
173-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-99999999-error.json'))
174162

175163
return expect(cep('5010000')).to.eventually.deep.equal({
176164
cep: '05010000',
@@ -190,32 +178,7 @@ describe('cep-promise (unit)', () => {
190178
nock('https://viacep.com.br')
191179
.get('/ws/05010000/json/')
192180
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
193-
nock('http://www.cepaberto.com')
194-
.get('/api/v2/ceps.json?cep=05010000')
195-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-99999999-error.json'))
196-
197-
return expect(cep('5010000')).to.eventually.deep.equal({
198-
cep: '05010000',
199-
state: 'SP',
200-
city: 'São Paulo',
201-
neighborhood: 'Perdizes',
202-
street: 'Rua Caiubi'
203-
})
204-
})
205-
})
206181

207-
describe('Should succeed only with cep aberto service', () => {
208-
it('should fulfill with correct address', () => {
209-
nock('https://apps.correios.com.br')
210-
.post('/SigepMasterJPA/AtendeClienteService/AtendeCliente')
211-
.replyWithFile(500, path.join(__dirname, '/fixtures/response-unknown-format.xml'))
212-
nock('https://viacep.com.br')
213-
.get('/ws/05010000/json/')
214-
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json'))
215-
nock('http://www.cepaberto.com')
216-
.get('/api/v2/ceps.json?cep=05010000')
217-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
218-
219182
return expect(cep('5010000')).to.eventually.deep.equal({
220183
cep: '05010000',
221184
state: 'SP',
@@ -234,9 +197,6 @@ describe('cep-promise (unit)', () => {
234197
nock('https://viacep.com.br')
235198
.get('/ws/05010000/json/')
236199
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
237-
nock('http://www.cepaberto.com')
238-
.get('/api/v2/ceps.json?cep=05010000')
239-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
240200

241201
return expect(cep('5010000')).to.eventually.deep.equal({
242202
cep: '05010000',
@@ -256,9 +216,6 @@ describe('cep-promise (unit)', () => {
256216
nock('https://viacep.com.br')
257217
.get('/ws/05010000/json/')
258218
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-05010000-found.json'))
259-
nock('http://www.cepaberto.com')
260-
.get('/api/v2/ceps.json?cep=05010000')
261-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-05010000-found.json'))
262219

263220
return expect(cep('5010000')).to.eventually.deep.equal({
264221
cep: '05010000',
@@ -278,9 +235,6 @@ describe('cep-promise (unit)', () => {
278235
nock('https://viacep.com.br')
279236
.get('/ws/99999999/json/')
280237
.replyWithFile(200, path.join(__dirname, '/fixtures/viacep-cep-99999999-error.json'))
281-
nock('http://www.cepaberto.com')
282-
.get('/api/v2/ceps.json?cep=99999999')
283-
.replyWithFile(200, path.join(__dirname, '/fixtures/cep-aberto-99999999-error.json'))
284238

285239
return cep('99999999')
286240
.catch((error) => {
@@ -296,9 +250,6 @@ describe('cep-promise (unit)', () => {
296250
}, {
297251
message: 'CEP não encontrado na base do ViaCEP.',
298252
service: 'viacep'
299-
}, {
300-
message: 'CEP não encontrado na base do Cep Aberto.',
301-
service: 'cepaberto'
302253
}]
303254
})
304255
})
@@ -332,9 +283,6 @@ describe('cep-promise (unit)', () => {
332283
nock('https://viacep.com.br')
333284
.get('/ws/05010000/json/')
334285
.reply(400, '<h2>Bad Request (400)</h2>')
335-
nock('http://www.cepaberto.com')
336-
.get('/api/v2/ceps.json?cep=05010000')
337-
.reply(400, '<h2>Bad Request (400)</h2>')
338286

339287
return cep('05010000')
340288
.catch((error) => {
@@ -350,9 +298,6 @@ describe('cep-promise (unit)', () => {
350298
}, {
351299
message: 'Erro ao se conectar com o serviço ViaCEP.',
352300
service: 'viacep'
353-
}, {
354-
message: 'Erro ao se conectar com o serviço Cep Aberto.',
355-
service: 'cepaberto'
356301
}]
357302
})
358303
})
@@ -367,9 +312,6 @@ describe('cep-promise (unit)', () => {
367312
nock('https://viacep.com.br')
368313
.get('/ws/05010000/json/')
369314
.reply(400, '<h2>Bad Request (400)</h2>')
370-
nock('http://www.cepaberto.com')
371-
.get('/api/v2/ceps.json?cep=05010000')
372-
.reply(400, '<h2>Bad Request (400)</h2>')
373315

374316
return cep('05010000')
375317
.catch((error) => {
@@ -385,9 +327,6 @@ describe('cep-promise (unit)', () => {
385327
}, {
386328
message: 'Erro ao se conectar com o serviço ViaCEP.',
387329
service: 'viacep'
388-
}, {
389-
message: 'Erro ao se conectar com o serviço Cep Aberto.',
390-
service: 'cepaberto'
391330
}]
392331
})
393332
})
@@ -402,9 +341,6 @@ describe('cep-promise (unit)', () => {
402341
nock('https://viacep.com.br')
403342
.get('/ws/05010000/json/')
404343
.replyWithError('getaddrinfo ENOTFOUND apps.correios.com.br apps.correios.com.br:443')
405-
nock('http://www.cepaberto.com')
406-
.get('/api/v2/ceps.json?cep=05010000')
407-
.replyWithError('getaddrinfo ENOTFOUND apps.correios.com.br apps.correios.com.br:443')
408344

409345
return cep('05010000')
410346
.catch((error) => {
@@ -420,9 +356,6 @@ describe('cep-promise (unit)', () => {
420356
}, {
421357
message: 'Erro ao se conectar com o serviço ViaCEP.',
422358
service: 'viacep'
423-
}, {
424-
message: 'Erro ao se conectar com o serviço Cep Aberto.',
425-
service: 'cepaberto'
426359
}]
427360
})
428361
})

0 commit comments

Comments
 (0)