diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-07-10 17:59:34 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-07-10 17:59:34 -0700 |
commit | a9f473260cdbf7944a8d95c4292a93897f9210eb (patch) | |
tree | 83e78b9028850606722da6ec66c45e453ee28693 /test/includes.js | |
parent | 520045441b9401fadfba2b1b03696bd15b60027d (diff) | |
parent | d16577e8bf2e404cbc2cabb78fc1bf6c8a36d3ea (diff) | |
download | gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.zip gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.gz gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.bz2 |
Merge pull request #356 from GitbookIO/feature/includes
Support importing code snippets
Diffstat (limited to 'test/includes.js')
-rw-r--r-- | test/includes.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/includes.js b/test/includes.js new file mode 100644 index 0000000..69adc11 --- /dev/null +++ b/test/includes.js @@ -0,0 +1,38 @@ +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); + +var page = require('../').parse.page; + +var FIXTURES_DIR = path.join(__dirname, './fixtures/'); + +function loadPage (name, options) { + var CONTENT = fs.readFileSync(FIXTURES_DIR + name + '.md', 'utf8'); + return page(CONTENT, options); +} + + +describe('Code includes', function() { + + var LEXED = loadPage('INCLUDES', { + 'dir': FIXTURES_DIR, + }); + + var INCLUDED_C = fs.readFileSync(path.join(FIXTURES_DIR, 'included.c'), 'utf8'); + + it('should work for snippets', function() { + assert.equal(LEXED[0].type, 'normal'); + // Has replaced include + assert.equal( + LEXED[0].content.indexOf('{{ included.c }}'), + -1 + ); + }); + + it('should work for exercises', function() { + assert.equal(LEXED[1].type, 'exercise'); + + // Solution is trimmed version of source + assert.equal(LEXED[1].code.solution, INCLUDED_C.trim()); + }); +}); |