forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountry.test.js
More file actions
89 lines (63 loc) · 2.48 KB
/
country.test.js
File metadata and controls
89 lines (63 loc) · 2.48 KB
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
describe('Shopify#country', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/country');
const common = require('./common');
const shopify = common.shopify;
const scope = common.scope;
afterEach(() => expect(scope.isDone()).to.be.true);
it('gets a list of all countries (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/countries.json').reply(200, output);
return shopify.country
.list()
.then((data) => expect(data).to.deep.equal(output.countries));
});
it('gets a list of all countries (2/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/countries.json?since_id=359115487').reply(200, output);
return shopify.country
.list({ since_id: 359115487 })
.then((data) => expect(data).to.deep.equal(output.countries));
});
it('gets a count of all countries', () => {
scope.get('/admin/countries/count.json').reply(200, { count: 3 });
return shopify.country.count().then((data) => expect(data).to.equal(3));
});
it('gets a single country by its ID (1/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/countries/879921427.json').reply(200, output);
return shopify.country
.get(879921427)
.then((data) => expect(data).to.deep.equal(output.country));
});
it('gets a single country by its ID (2/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/countries/879921427.json?foo=bar').reply(200, output);
return shopify.country
.get(879921427, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.country));
});
it('creates a new country', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope.post('/admin/countries.json', input).reply(201, output);
return shopify.country
.create(input.country)
.then((data) => expect(data).to.deep.equal(output.country));
});
it('updates a country', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope.put('/admin/countries/879921427.json', input).reply(200, output);
return shopify.country
.update(879921427, input.country)
.then((data) => expect(data).to.deep.equal(output.country));
});
it('deletes a country', () => {
scope.delete('/admin/countries/879921427.json').reply(200, {});
return shopify.country
.delete(879921427)
.then((data) => expect(data).to.deep.equal({}));
});
});