-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathencoding-test.js
More file actions
77 lines (76 loc) · 2.38 KB
/
encoding-test.js
File metadata and controls
77 lines (76 loc) · 2.38 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
var _ = require('underscore'),
vows = require('vows'),
assert = require('assert'),
Resource = require('../lib/resource'),
Fsm = require('../lib/fsm');
vows.describe('FSM Encoding').addBatch({
'given all encodings': {
topic: function () {
root = {
route: '/'
};
var resource = new Resource(root);
var fsm = new Fsm(resource);
var identityFunc = function(x){ return x; };
var provided = {"identity":identityFunc};
var acceptencoding = '*';
var encoding = fsm.doChooseEncoding(provided, acceptencoding);
this.callback(true, encoding);
},
'default to identity': function (passed, charset) {
assert.equal(charset, 'identity');
}
},
'given identity encoding': {
topic: function () {
root = {
route: '/'
};
var resource = new Resource(root);
var fsm = new Fsm(resource);
var identityFunc = function(x){ return x; };
var provided = {"deflate":identityFunc,"identity":identityFunc};
var acceptencoding = 'identity';
var encoding = fsm.doChooseEncoding(provided, acceptencoding);
this.callback(true, encoding);
},
'choose identity': function (passed, charset) {
assert.equal(charset, 'identity');
}
},
'given deflate encoding': {
topic: function () {
root = {
route: '/'
};
var resource = new Resource(root);
var fsm = new Fsm(resource);
var identityFunc = function(x){ return x; };
var provided = {"deflate":identityFunc,"identity":identityFunc};
var acceptencoding = 'deflate';
var encoding = fsm.doChooseEncoding(provided, acceptencoding);
this.callback(true, encoding);
},
'choose deflate': function (passed, charset) {
assert.equal(charset, 'deflate');
}
},
'given no valid encoding': {
topic: function () {
root = {
route: '/'
};
var resource = new Resource(root);
var fsm = new Fsm(resource);
var identityFunc = function(x){ return x; };
var provided = {"identity":identityFunc};
var acceptencoding = 'derp';
var encoding = fsm.doChooseEncoding(provided, acceptencoding);
this.callback(true, encoding);
},
'choose null': function (passed, charset) {
assert.equal(charset, null);
}
}
// check that * works against a lower q match
}).export(module);