|
| 1 | +var should = require('should'); |
| 2 | + |
| 3 | +describe('Navigation', function () { |
| 4 | + var book; |
| 5 | + |
| 6 | + before(function() { |
| 7 | + return books.parse("summary") |
| 8 | + .then(function(_book) { |
| 9 | + book = _book; |
| 10 | + }); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should correctly parse navigation as a map', function() { |
| 14 | + book.should.have.property("navigation"); |
| 15 | + book.navigation.should.have.property("README.md"); |
| 16 | + book.navigation.should.have.property("README.md"); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should correctly include filenames', function() { |
| 20 | + book.navigation.should.have.property("README.md"); |
| 21 | + book.navigation.should.have.property("PAGE1.md"); |
| 22 | + book.navigation.should.have.property("folder/PAGE2.md"); |
| 23 | + book.navigation.should.not.have.property("NOTFOUND.md"); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should correctly detect next/prev for README', function() { |
| 27 | + var README = book.navigation['README.md']; |
| 28 | + |
| 29 | + README.index.should.equal(0); |
| 30 | + README.should.have.property('next'); |
| 31 | + should(README.prev).not.be.ok(); |
| 32 | + |
| 33 | + README.next.should.have.property('path'); |
| 34 | + README.next.path.should.equal('PAGE1.md'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should correctly detect next/prev a page', function() { |
| 38 | + var PAGE = book.navigation['PAGE1.md']; |
| 39 | + |
| 40 | + PAGE.index.should.equal(1); |
| 41 | + PAGE.should.have.property('next'); |
| 42 | + PAGE.should.have.property('prev'); |
| 43 | + |
| 44 | + PAGE.prev.should.have.property('path'); |
| 45 | + PAGE.prev.path.should.equal('README.md'); |
| 46 | + |
| 47 | + PAGE.next.should.have.property('path'); |
| 48 | + PAGE.next.path.should.equal('folder/PAGE2.md'); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should correctly detect next/prev for last page', function() { |
| 52 | + var PAGE = book.navigation['folder/PAGE2.md']; |
| 53 | + |
| 54 | + PAGE.index.should.equal(2); |
| 55 | + PAGE.should.have.property('prev'); |
| 56 | + should(PAGE.next).not.be.ok(); |
| 57 | + |
| 58 | + PAGE.prev.should.have.property('path'); |
| 59 | + PAGE.prev.path.should.equal('PAGE1.md'); |
| 60 | + }); |
| 61 | +}); |
0 commit comments