diff options
author | James Phillpotts <jphillpotts@scottlogic.co.uk> | 2014-04-08 09:51:11 +0100 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-04-12 01:25:07 -0700 |
commit | f6595f51119baca04bf91e619f64518d400e5cae (patch) | |
tree | 765ad8ab0f40d3bb68c03e8df1d5246664556e9c /test/page.js | |
parent | ab27725b9935b185a58b725e75aedeb579e87d8f (diff) | |
download | gitbook-f6595f51119baca04bf91e619f64518d400e5cae.zip gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.gz gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.bz2 |
Tabular quiz
Diffstat (limited to 'test/page.js')
-rw-r--r-- | test/page.js | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/test/page.js b/test/page.js index fa6db06..2954155 100644 --- a/test/page.js +++ b/test/page.js @@ -4,28 +4,27 @@ 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, { - 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 LEXED = loadPage('PAGE'); +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() { @@ -64,12 +63,20 @@ 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.base); + assert(QUIZ_LEXED[1].quiz.solution); + assert(QUIZ_LEXED[1].quiz.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', |