forked from godaddy/feedsme-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
60 lines (48 loc) · 1.27 KB
/
Copy pathtest.js
File metadata and controls
60 lines (48 loc) · 1.27 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
describe('feedsme-api-client', function () {
'use strict';
var assume = require('assume')
, Feedsme = require('./')
, nock = require('nock')
, url = require('url')
, feedsme
, uri;
beforeEach(function each() {
uri = 'http://localhost:1212/';
feedsme = new Feedsme(uri);
});
afterEach(function each() {
feedsme = null;
});
it('can be configured with object', function () {
feedsme = new Feedsme(url.parse(uri));
assume(feedsme.base).to.be.an('string');
assume(feedsme.base).to.equal(uri);
});
it('can be configured with an agent', function () {
feedsme = new Feedsme({
uri: uri,
agent: new require('http').Agent()
});
assume(feedsme.agent).is.instanceof(require('http').Agent);
assume(feedsme.base).equals(uri);
});
describe('#change', function () {
it('sends a request to /change/dev ', function (next) {
next = assume.wait(2, next);
nock(uri)
.post('/change/dev')
.reply(200, function reply(uri, body) {
body = JSON.parse(body);
assume(body.name).equals('foo-bar');
nock.cleanAll();
next();
return {};
});
feedsme.change('dev', {
data: {
name: 'foo-bar'
}
}, next);
});
});
});