summaryrefslogtreecommitdiffstats
path: root/test/page.js
blob: 082cda6bfb0314087957b7feadf84bb82ac642b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var fs = require('fs');
var path = require('path');
var assert = require('assert');

var page = require('../').parse.page;


var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.md'), 'utf8');
var LEXED = page(CONTENT);

describe('Page parsing', function() {
    it('should detection sections', function() {
        assert.equal(LEXED.length, 3);
    });

    it('should detection section types', function() {
        assert.equal(LEXED[0].type, 'normal');
        assert.equal(LEXED[1].type, 'exercise');
        assert.equal(LEXED[2].type, 'normal');
    });

    it('should gen content for normal sections', function() {
        assert(LEXED[0].content);
        assert(LEXED[2].content);
    });

    it('should gen code and content for exercise sections', function() {
        assert(LEXED[1].content);
        assert(LEXED[1].code);
        assert(LEXED[1].code.base);
        assert(LEXED[1].code.solution);
        assert(LEXED[1].code.validation);
    });
});