forked from MONEI/Shopify-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.test.js
More file actions
143 lines (102 loc) · 3.93 KB
/
comment.test.js
File metadata and controls
143 lines (102 loc) · 3.93 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
describe('Shopify#comment', () => {
'use strict';
const expect = require('chai').expect;
const fixtures = require('./fixtures/comment');
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 comments (1/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/comments.json').reply(200, output);
return shopify.comment
.list()
.then((data) => expect(data).to.deep.equal(output.comments));
});
it('gets a list of all comments (2/2)', () => {
const output = fixtures.res.list;
scope.get('/admin/comments.json?blog_id=241253187').reply(200, output);
return shopify.comment
.list({ blog_id: 241253187 })
.then((data) => expect(data).to.deep.equal(output.comments));
});
it('gets a count of all comments (1/2)', () => {
scope.get('/admin/comments/count.json').reply(200, { count: 2 });
return shopify.comment.count().then((data) => expect(data).to.equal(2));
});
it('gets a count of all comments (2/2)', () => {
scope
.get('/admin/comments/count.json?blog_id=241253187')
.reply(200, { count: 2 });
return shopify.comment
.count({ blog_id: 241253187 })
.then((data) => expect(data).to.equal(2));
});
it('gets a single comment by its ID (1/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/comments/118373535.json').reply(200, output);
return shopify.comment
.get(118373535)
.then((data) => expect(data).to.deep.equal(output.comment));
});
it('gets a single comment by its ID (2/2)', () => {
const output = fixtures.res.get;
scope.get('/admin/comments/118373535.json?foo=bar').reply(200, output);
return shopify.comment
.get(118373535, { foo: 'bar' })
.then((data) => expect(data).to.deep.equal(output.comment));
});
it('creates a new comment for an article', () => {
const input = fixtures.req.create;
const output = fixtures.res.create;
scope.post('/admin/comments.json', input).reply(201, output);
return shopify.comment
.create(input.comment)
.then((data) => expect(data).to.deep.equal(output.comment));
});
it('updates a comment', () => {
const input = fixtures.req.update;
const output = fixtures.res.update;
scope.put('/admin/comments/118373535.json', input).reply(200, output);
return shopify.comment
.update(118373535, input.comment)
.then((data) => expect(data).to.deep.equal(output.comment));
});
it('marks a comment as spam', () => {
const output = fixtures.res.spam;
scope.post('/admin/comments/653537639/spam.json', {}).reply(200, output);
return shopify.comment
.spam(653537639)
.then((data) => expect(data).to.deep.equal(output));
});
it('marks a comment as not spam', () => {
const output = fixtures.res.notSpam;
scope
.post('/admin/comments/653537639/not_spam.json', {})
.reply(200, output);
return shopify.comment
.notSpam(653537639)
.then((data) => expect(data).to.deep.equal(output));
});
it('approves a pending comment', () => {
const output = fixtures.res.approve;
scope.post('/admin/comments/653537639/approve.json', {}).reply(200, output);
return shopify.comment
.approve(653537639)
.then((data) => expect(data).to.deep.equal(output));
});
it('removes a comment', () => {
const output = fixtures.res.remove;
scope.post('/admin/comments/653537639/remove.json', {}).reply(200, output);
return shopify.comment
.remove(653537639)
.then((data) => expect(data).to.deep.equal(output));
});
it('restores a comment', () => {
const output = fixtures.res.restore;
scope.post('/admin/comments/653537639/restore.json', {}).reply(200, output);
return shopify.comment
.restore(653537639)
.then((data) => expect(data).to.deep.equal(output));
});
});