diff options
Diffstat (limited to 'lib/modifiers/summary/__tests__/removeArticle.js')
-rw-r--r-- | lib/modifiers/summary/__tests__/removeArticle.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/modifiers/summary/__tests__/removeArticle.js b/lib/modifiers/summary/__tests__/removeArticle.js new file mode 100644 index 0000000..c961f14 --- /dev/null +++ b/lib/modifiers/summary/__tests__/removeArticle.js @@ -0,0 +1,54 @@ +var Summary = require('../../../models/summary'); +var SummaryArticle = require('../../../models/summaryArticle'); +var File = require('../../../models/file'); + +describe('removeArticle', function() { + var removeArticle = require('../removeArticle'); + var summary = Summary.createFromParts(File(), [ + { + articles: [ + { + title: '1.1', + path: '1.1' + }, + { + title: '1.2', + path: '1.2' + } + ] + }, + { + title: 'Part I', + articles: [ + { + title: '2.1', + path: '2.1', + articles: [ + { + title: '2.1.1', + path: '2.1.1' + }, + { + title: '2.1.2', + path: '2.1.2' + } + ] + }, + { + title: '2.2', + path: '2.2' + } + ] + } + ]); + + it('should remove an article at a given level', function() { + var newSummary = removeArticle(summary, '2.1.1'); + + var removed = newSummary.getByLevel('2.1.1'); + var nextOne = newSummary.getByLevel('2.1.2'); + + expect(removed.getTitle()).toBe('2.1.2'); + expect(nextOne).toBe(null); + }); +}); |