diff options
Diffstat (limited to 'packages/gitbook/src/modifiers/summary/__tests__/removeArticle.js')
-rw-r--r-- | packages/gitbook/src/modifiers/summary/__tests__/removeArticle.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/gitbook/src/modifiers/summary/__tests__/removeArticle.js b/packages/gitbook/src/modifiers/summary/__tests__/removeArticle.js new file mode 100644 index 0000000..14587ca --- /dev/null +++ b/packages/gitbook/src/modifiers/summary/__tests__/removeArticle.js @@ -0,0 +1,53 @@ +const Summary = require('../../../models/summary'); +const File = require('../../../models/file'); + +describe('removeArticle', function() { + const removeArticle = require('../removeArticle'); + const 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() { + const newSummary = removeArticle(summary, '2.1.1'); + + const removed = newSummary.getByLevel('2.1.1'); + const nextOne = newSummary.getByLevel('2.1.2'); + + expect(removed.getTitle()).toBe('2.1.2'); + expect(nextOne).toBe(null); + }); +}); |