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 | |
parent | ab27725b9935b185a58b725e75aedeb579e87d8f (diff) | |
download | gitbook-f6595f51119baca04bf91e619f64518d400e5cae.zip gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.gz gitbook-f6595f51119baca04bf91e619f64518d400e5cae.tar.bz2 |
Tabular quiz
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/HR_PAGE.md | 2 | ||||
-rw-r--r-- | test/fixtures/QUIZ_PAGE.md | 25 | ||||
-rw-r--r-- | test/page.js | 35 |
3 files changed, 47 insertions, 15 deletions
diff --git a/test/fixtures/HR_PAGE.md b/test/fixtures/HR_PAGE.md index da53b0c..49115d0 100644 --- a/test/fixtures/HR_PAGE.md +++ b/test/fixtures/HR_PAGE.md @@ -4,7 +4,7 @@ Some nice content here --- -A beautiful separator, but non an exercise ! +A beautiful separator, but non an exercise or a quiz ! --- diff --git a/test/fixtures/QUIZ_PAGE.md b/test/fixtures/QUIZ_PAGE.md new file mode 100644 index 0000000..f494592 --- /dev/null +++ b/test/fixtures/QUIZ_PAGE.md @@ -0,0 +1,25 @@ +# Gitbook quiz + +Gitbook lets you write a quiz using GFM tables: + +--- + +Here's a quiz about Gitbook + +| | Good | Bad | +| ---------------- | ---- | --- | +| What is Gitbook? | ( ) | ( ) | + +| | Good | Bad | +| ---------------- | ---- | --- | +| What is Gitbook? | (x) | ( ) | + +> Gitbook is good + +--- + +Some more nice content .... + +[Cool stuff](http://gitbook.io) + +[Link to another Markdown file](./xyz/file.md) 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', |