forked from MartinsOnuoha/countriesNowAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrencies.js
69 lines (61 loc) · 2.01 KB
/
currencies.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
/* eslint-disable no-undef */
/**
* @module test/currencies
*/
const chai = require('chai');
const chaiHttp = require('chai-http');
const server = require('../app');
const basePath = '/api/v0.1/countries';
const should = chai.should();
chai.use(chaiHttp);
describe('Currencies', () => {
describe('/GET', () => {
it('it should get all countries and their currencies', (done) => {
chai.request(server)
.get(`${basePath}/currency`)
.end((err, res) => {
should.not.exist(err);
res.should.have.status(200);
res.body.should.be.a('object');
res.body.should.have.property('error').eql(false);
res.body.should.have.property('data');
res.body.should.have.property('data').be.a('array');
res.body.data.length.should.not.equal(0);
done();
});
});
});
describe('/POST', () => {
it('it should a single country and its currencies', (done) => {
chai.request(server)
.post(`${basePath}/currency`)
.send({ country: 'nigeria' })
.end((err, res) => {
should.not.exist(err);
res.should.have.status(200);
res.body.should.be.a('object');
res.body.should.have.property('error').eql(false);
res.body.should.have.property('data');
res.body.should.have.property('data').be.a('object');
res.body.should.have.property('data').have.property('currency');
done();
});
});
});
describe('/POST', () => {
it('it should require "country" param to get currencies', (done) => {
chai.request(server)
.post(`${basePath}/currency`)
.send({ })
.end((err, res) => {
should.not.exist(err);
res.should.have.status(400);
res.body.should.be.a('object');
res.body.should.have.property('error').eql(true);
res.body.should.have.property('msg');
res.body.should.have.property('msg').be.a('string');
done();
});
});
});
});