Skip to content

Commit

Permalink
chore(tests): Comple all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Dec 18, 2016
1 parent 0ff3390 commit e46c444
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,62 @@ describe('codigo-postal', () => {
});
});
});

describe('server error', () => {

const data = {
address: 'avenida siempreviva',
number: 666,
commune: 'springfield'
};

beforeEach(() => {
const query = {
calle: data.address,
numero: data.number,
comuna: data.commune
};
nock.disableNetConnect();
nock('http://www.correos.cl')
.get('/SitePages/codigo_postal/codigo_postal.aspx')
.query(query)
.replyWithError('Server error');
});

it('should return an error', done => {
lib(data).catch(err => {
expect(err).to.be.an('error');
done();
});
});
});

describe('bad status code', () => {

const data = {
address: 'avenida siempreviva',
number: 666,
commune: 'springfield'
};

beforeEach(() => {
const query = {
calle: data.address,
numero: data.number,
comuna: data.commune
};
nock.disableNetConnect();
nock('http://www.correos.cl')
.get('/SitePages/codigo_postal/codigo_postal.aspx')
.query(query)
.reply(301);
});

it('should return an error', done => {
lib(data).catch(err => {
expect(err).to.be.an('error');
done();
});
});
});
});

0 comments on commit e46c444

Please sign in to comment.