forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomer-address.test.js
More file actions
116 lines (89 loc) · 3.2 KB
/
customer-address.test.js
File metadata and controls
116 lines (89 loc) · 3.2 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
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
describe('Shopify#customerAddress', () => {
'use strict';
const expect = require('chai').expect;
const qs = require('qs');
const fixtures = require('./fixtures/customer-address');
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 addresses from a customer (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/customers/207119551/addresses.json').reply(200, output);
return shopify.customerAddress
.list(207119551)
.then((data) => expect(data).to.deep.equal(output.addresses));
});
it('gets a list of all articles from a certain blog (2/2)', () => {
const output = fixtures.res.list;
scope
.get('/admin/customers/207119551/addresses.json?page=1')
.reply(200, output);
return shopify.customerAddress
.list(207119551, { page: 1 })
.then((data) => expect(data).to.deep.equal(output.addresses));
});
it('gets a single address by its ID', () => {
const output = fixtures.res.get;
scope
.get('/admin/customers/207119551/addresses/207119551.json')
.reply(200, output);
return shopify.customerAddress
.get(207119551, 207119551)
.then((data) => expect(data).to.deep.equal(output.customer_address));
});
it('creates a new address for a customer', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope
.post('/admin/customers/207119551/addresses.json', input)
.reply(201, output);
return shopify.customerAddress
.create(207119551, input.address)
.then((data) => expect(data).to.deep.equal(output.customer_address));
});
it('updates an address', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope
.put('/admin/customers/207119551/addresses/207119551.json', input)
.reply(200, output);
return shopify.customerAddress
.update(207119551, 207119551, input.address)
.then((data) => expect(data).to.deep.equal(output.customer_address));
});
it('deletes an address', () => {
scope
.delete('/admin/customers/207119551/addresses/207119551.json')
.reply(200, {});
return shopify.customerAddress
.delete(207119551, 207119551)
.then((data) => expect(data).to.deep.equal({}));
});
it('performs bulk operations against a number of addresses', () => {
const query = {
address_ids: [1053317300],
operations: 'destroy'
};
scope
.put(
'/admin/customers/207119551/addresses/set.json?' +
qs.stringify(query, {
arrayFormat: 'brackets'
})
)
.reply(200, {});
return shopify.customerAddress
.set(207119551, query)
.then((data) => expect(data).to.deep.equal({}));
});
it('sets default address for a customer', () => {
const output = fixtures.res.default;
scope
.put('/admin/customers/207119551/addresses/1053317297/default.json')
.reply(200, output);
return shopify.customerAddress
.default(207119551, 1053317297)
.then((data) => expect(data).to.deep.equal(output.customer_address));
});
});