This repository was archived by the owner on May 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
96 lines (77 loc) · 2.17 KB
/
Copy pathtest.js
File metadata and controls
96 lines (77 loc) · 2.17 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
describe('feedsme-api-client', function () {
'use strict';
var assume = require('assume'),
Feedsme = require('./'),
nock = require('nock'),
http = require('http'),
url = require('url');
var 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 http.Agent()
});
assume(feedsme.agent).is.instanceof(require('http').Agent);
assume(feedsme.base).equals(uri);
});
it('can be configured with an api version', function () {
[1, '1', 'v1'].forEach(function (version) {
assume(new Feedsme({ uri, version }).version).equals('');
});
});
it('defaults to the v2 api', function () {
assume(new Feedsme({ uri, version: 'not one' }).version).equals('v2');
assume(new Feedsme({ uri }).version).equals('v2');
});
describe('#change', function () {
it('sends a request to /v2/change/dev', function (next) {
next = assume.wait(2, next);
nock(uri)
.post('/v2/change/dev')
.reply(200, function reply(uri, body) {
assume(body.name).equals('foo-bar');
nock.cleanAll();
next();
return {};
});
feedsme.change('dev', {
data: {
name: 'foo-bar'
}
}, next);
});
it('sends a request to /change/dev when using v1 API', function (next) {
feedsme = new Feedsme({
uri,
agent: new http.Agent(),
version: 'v1'
});
next = assume.wait(2, next);
nock(uri)
.post('/change/dev')
.reply(200, function reply(uri, body) {
assume(body.name).equals('foo-bar');
nock.cleanAll();
next();
return {};
});
feedsme.change('dev', {
data: {
name: 'foo-bar'
}
}, next);
});
});
});