-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.js
35 lines (35 loc) · 1.09 KB
/
test.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
const synonyms = require('./index.js');
const assert = require('assert');
describe('synonyms', function () {
it('get synonyms with type define', function () {
assert.equal(Array.isArray(synonyms("existent","a")),true);
});
it('get synonyms with type not defined', function () {
assert.equal(typeof synonyms("existent"),"object");
});
it('get dictionary', function () {
assert.equal(typeof synonyms.dictionary,"object");
});
it('non existent word', function () {
assert.equal(synonyms("asdfghjkl"),undefined);
});
it('non existent type', function () {
assert.equal(synonyms("dictionary","asdfghjkl"),undefined);
});
it('marked & deep', function () {
assert.equal(Array.isArray(synonyms("vibrate","v")),true);
});
it('Counting dictionary', function () {
this.timeout(30000);
var words = [];
for (var entry in synonyms.dictionary) {
if(!~words.indexOf(entry)) words.push(entry);
for(var type in synonyms.dictionary[entry]) {
synonyms.dictionary[entry][type].forEach((x)=>{
if(!~words.indexOf(x)) words.push(x);
});
}
}
console.log(" " + words.length);
});
});