diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-01-27 22:48:23 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-01-27 22:48:23 +0100 |
commit | ddc99104d4394cc21eaa615b01d73ec001ac7a16 (patch) | |
tree | 9855406d0a162cf744576c91501480f0450324c7 /lib/backbone/glossary.js | |
parent | 8d277e9108afa6a027c61feb581a2150958f8571 (diff) | |
download | gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.zip gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.gz gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.bz2 |
Add unit tests for glossary parsing
Diffstat (limited to 'lib/backbone/glossary.js')
-rw-r--r-- | lib/backbone/glossary.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/backbone/glossary.js b/lib/backbone/glossary.js index b25d7c7..0f5e567 100644 --- a/lib/backbone/glossary.js +++ b/lib/backbone/glossary.js @@ -7,7 +7,7 @@ A glossary entry is represented by a name and a short description An unique id for the entry is generated using its name */ function GlossaryEntry(name, description) { - if (!(this instanceof Glossary)) return new Glossary(); + if (!(this instanceof GlossaryEntry)) return new GlossaryEntry(name, description); this.name = name; this.description = description; @@ -54,4 +54,9 @@ Glossary.prototype.get = function(id) { }); }; +// Return false if glossary has entries (and exists) +Glossary.prototype.isEmpty = function(id) { + return _.size(this.entries) === 0; +}; + module.exports = Glossary; |