summaryrefslogtreecommitdiffstats
path: root/lib/backbone
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-01-27 22:48:23 +0100
committerSamy Pessé <samypesse@gmail.com>2016-01-27 22:48:23 +0100
commitddc99104d4394cc21eaa615b01d73ec001ac7a16 (patch)
tree9855406d0a162cf744576c91501480f0450324c7 /lib/backbone
parent8d277e9108afa6a027c61feb581a2150958f8571 (diff)
downloadgitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.zip
gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.gz
gitbook-ddc99104d4394cc21eaa615b01d73ec001ac7a16.tar.bz2
Add unit tests for glossary parsing
Diffstat (limited to 'lib/backbone')
-rw-r--r--lib/backbone/glossary.js7
-rw-r--r--lib/backbone/summary.js8
2 files changed, 13 insertions, 2 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;
diff --git a/lib/backbone/summary.js b/lib/backbone/summary.js
index 7eb6e0c..96815a6 100644
--- a/lib/backbone/summary.js
+++ b/lib/backbone/summary.js
@@ -1,8 +1,14 @@
+var util = require('util');
+var BackboneFile = require('./file');
+
var Article = require('./article');
function Summary() {
- if (!(this instanceof Summary)) return new Summary();
+ BackboneFile.apply(this, arguments);
+
+ this.articles = [];
}
+util.inherits(Summary, BackboneFile);
Summary.prototype.type = 'summary';