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