-
Notifications
You must be signed in to change notification settings - Fork 10
/
tests.js
41 lines (35 loc) · 1.27 KB
/
tests.js
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
var vows = require('vows');
var assert = require('assert');
var fs = require('fs');
var _ = require('./lib/underscore-min');
var requirejs = require('requirejs');
requirejs.config({
nodeRequire: require,
baseUrl: 'verbs'
});
requirejs(['list.js'], function(verbs) {
vows.describe('Tin Can Verbs').addBatch({
'The imported verbs': {
topic: verbs,
'include all files in the verbs directory': function(verbs) {
var files = fs.readdirSync('verbs');
var missing = _.difference(files, verbs.names);
assert.isEmpty(missing);
},
'do not have conflicting IDs': function(verbs) {
var uris = _.pluck(verbs.modules, 'uri');
var name_to_uri = _.object(verbs.names, uris);
var uri_to_names = _.groupBy(verbs.names, function(name){
return name_to_uri[name];
});
var counts = _.countBy(uris, _.identity);
var uri;
for(uri in counts) {
assert.isTrue(counts[uri] == 1,
"Verb ID " + uri +
" is used in " + uri_to_names[uri].join(" and "));
}
}
}
}).run();
});