forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarketing-event.test.js
More file actions
98 lines (71 loc) · 2.83 KB
/
marketing-event.test.js
File metadata and controls
98 lines (71 loc) · 2.83 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
describe('Shopify#marketingEvent', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/marketing-event');
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 marketing events (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/marketing_events.json').reply(200, output);
return shopify.marketingEvent
.list()
.then((data) => expect(data).to.deep.equal(output.marketing_events));
});
it('gets a list of all marketing events (2/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/marketing_events.json?limit=50').reply(200, output);
return shopify.marketingEvent
.list({ limit: 50 })
.then((data) => expect(data).to.deep.equal(output.marketing_events));
});
it('gets a count of all marketing events', () => {
const output = { count: 1 };
scope.get('/admin/marketing_events/count.json').reply(200, output);
return shopify.marketingEvent
.count()
.then((data) => expect(data).to.equal(1));
});
it('gets a single marketing event by its ID', () => {
const output = fixtures.res.get;
scope.get('/admin/marketing_events/998730532.json').reply(200, output);
return shopify.marketingEvent
.get(998730532)
.then((data) => expect(data).to.deep.equal(output.marketing_event));
});
it('creates a new marketing event', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope.post('/admin/marketing_events.json', input).reply(201, output);
return shopify.marketingEvent
.create(input.marketing_event)
.then((data) => expect(data).to.deep.equal(output.marketing_event));
});
it('updates a marketing event', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope
.put('/admin/marketing_events/998730532.json', input)
.reply(200, output);
return shopify.marketingEvent
.update(998730532, input.marketing_event)
.then((data) => expect(data).to.deep.equal(output.marketing_event));
});
it('deletes a marketing event', () => {
scope.delete('/admin/marketing_events/998730532.json').reply(200, {});
return shopify.marketingEvent
.delete(998730532)
.then((data) => expect(data).to.deep.equal({}));
});
it('creates marketing engagements', () => {
const input = fixtures.req.engagements;
const output = fixtures.res.engagements;
scope
.post('/admin/marketing_events/998730532/engagements.json', input)
.reply(201, output);
return shopify.marketingEvent
.engagements(998730532, input.engagements)
.then((data) => expect(data).to.deep.equal(output.engagements));
});
});