diff options
Diffstat (limited to 'test/page.js')
-rw-r--r-- | test/page.js | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/test/page.js b/test/page.js index fa6db06..a8a3770 100644 --- a/test/page.js +++ b/test/page.js @@ -4,28 +4,30 @@ var assert = require('assert'); var page = require('../').parse.page; +function loadPage (name, options) { + var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/' + name + '.md'), 'utf8'); + return page(CONTENT, options); +} -var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.md'), 'utf8'); -var LEXED = page(CONTENT, { +var LEXED = loadPage('PAGE', { dir: 'course', outdir: '_book' }); - -var HR_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/HR_PAGE.md'), 'utf8'); -var HR_LEXED = page(HR_CONTENT); - -var LINKS_CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GITHUB_LINKS.md'), 'utf8'); - +var QUIZ_LEXED = loadPage('QUIZ_PAGE'); +var HR_LEXED = loadPage('HR_PAGE'); describe('Page parsing', function() { - it('should detection sections', function() { + it('should detect sections', function() { assert.equal(LEXED.length, 4); }); - it('should detection section types', function() { + it('should detect section types', function() { assert.equal(LEXED[0].type, 'normal'); assert.equal(LEXED[1].type, 'exercise'); assert.equal(LEXED[2].type, 'normal'); + assert.equal(QUIZ_LEXED[0].type, 'normal'); + assert.equal(QUIZ_LEXED[1].type, 'quiz'); + assert.equal(QUIZ_LEXED[2].type, 'normal'); }); it('should gen content for normal sections', function() { @@ -35,7 +37,7 @@ describe('Page parsing', function() { it('should make image URLs relative', function() { assert(LEXED[2].content.indexOf('_book/assets/my-pretty-picture.png') !== -1); - }) + }); it('should gen code and content for exercise sections', function() { assert(LEXED[1].content); @@ -64,12 +66,23 @@ describe('Page parsing', function() { it('should detect an exercise\'s language', function() { assert.equal(LEXED[1].lang, 'python'); }); + + it('should render a quiz', function() { + assert(QUIZ_LEXED[1].content); + assert(QUIZ_LEXED[1].quiz); + assert(QUIZ_LEXED[1].quiz[0].base); + assert(QUIZ_LEXED[1].quiz[0].solution); + assert(QUIZ_LEXED[1].quiz[0].feedback); + assert(QUIZ_LEXED[1].quiz[1].base); + assert(QUIZ_LEXED[1].quiz[1].solution); + assert(QUIZ_LEXED[1].quiz[1].feedback); + }); }); describe('Relative links', function() { it('should be resolved to their GitHub counterparts', function() { - var LEXED = page(LINKS_CONTENT, { + var LEXED = loadPage('GITHUB_LINKS', { // GitHub repo ID repo: 'GitBookIO/javascript', |