blob: e1ba82a924d743c81dc0509213da7232fb953c4e (
plain)
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
|
var should = require('should');
var mock = require('./mock');
describe('Glossary', function() {
it('should parse empty glossary', function() {
return mock.setupDefaultBook({
'GLOSSARY.md': ''
})
.then(function(book) {
return book.prepareConfig()
.then(function() {
return book.glossary.load();
})
.then(function() {
book.glossary.isEmpty().should.be.true();
});
});
});
describe('Non-empty glossary', function() {
var book;
before(function() {
return mock.setupDefaultBook({
'GLOSSARY.md': '# Glossary\n\n## Hello World\n\nThis is an entry'
})
.then(function(_book) {
book = _book;
return book.prepareConfig();
})
.then(function() {
return book.glossary.load();
});
});
it('should not be empty', function() {
book.glossary.isEmpty().should.be.false();
});
describe('glossary.get', function() {
it('should return an existing entry', function() {
var entry = book.glossary.get('hello_world');
should.exist(entry);
entry.name.should.equal('Hello World');
entry.description.should.equal('This is an entry');
entry.id.should.equal('hello_world');
});
it('should undefined return non existing entry', function() {
var entry = book.glossary.get('cool');
should.not.exist(entry);
});
});
describe('glossary.find', function() {
it('should return an existing entry', function() {
var entry = book.glossary.find('HeLLo World');
should.exist(entry);
entry.id.should.equal('hello_world');
});
it('should return undefined for non existing entry', function() {
var entry = book.glossary.find('Hello');
should.not.exist(entry);
});
});
});
});
|