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