diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-28 14:47:34 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-28 14:47:34 +0100 |
commit | 4aa66338fce505566a2fe6ba6aee79ddf3f656a2 (patch) | |
tree | ffce4b558735f6a41228542f8c36e3a6ba1e562d /test/init.js | |
parent | 8cda844ef12cf87525024348c104413def02ed7f (diff) | |
download | gitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.zip gitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.tar.gz gitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.tar.bz2 |
Add init command
Diffstat (limited to 'test/init.js')
-rw-r--r-- | test/init.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/init.js b/test/init.js new file mode 100644 index 0000000..e1e8a4a --- /dev/null +++ b/test/init.js @@ -0,0 +1,57 @@ +var Book = require('../lib/book'); +var mock = require('./mock'); + +describe('Init', function() { + + it('should create file according to summary', function() { + return mock.setupFS({ + 'SUMMARY.md': '# Summary\n\n' + + '* [Hello](hello.md)\n' + + '* [Hello 2](hello 2.md)\n' + }) + .then(function(rootFolder) { + return Book.init(mock.fs, rootFolder, { + log: function() {} + }) + .then(function() { + rootFolder.should.have.file('SUMMARY.md'); + rootFolder.should.have.file('README.md'); + rootFolder.should.have.file('hello.md'); + rootFolder.should.have.file('hello 2.md'); + }); + }) + }); + + it('should create file subfolder', function() { + return mock.setupFS({ + 'SUMMARY.md': '# Summary\n\n' + + '* [Hello](test/hello.md)\n' + + '* [Hello 2](test/test2/world.md)\n' + }) + .then(function(rootFolder) { + return Book.init(mock.fs, rootFolder, { + log: function() {} + }) + .then(function() { + rootFolder.should.have.file('README.md'); + rootFolder.should.have.file('SUMMARY.md'); + rootFolder.should.have.file('test/hello.md'); + rootFolder.should.have.file('test/test2/world.md'); + }); + }) + }); + + it('should create SUMMARY if non-existant', function() { + return mock.setupFS({}) + .then(function(rootFolder) { + return Book.init(mock.fs, rootFolder, { + log: function() {} + }) + .then(function() { + rootFolder.should.have.file('SUMMARY.md'); + rootFolder.should.have.file('README.md'); + }); + }) + }); + +}); |