1 | 'use strict'
|
2 | const describe = require('mocha').describe
|
3 | const it = require('mocha').it
|
4 | const expect = require('chai').expect
|
5 | const m = require('markdownscript')
|
6 | const mos = require('.')
|
7 |
|
8 | describe('mos', () => {
|
9 | describe('use', () => {
|
10 | it('should register mos plugin', done => {
|
11 | const processor = mos().use(md => ({ foo: 'foo' }))
|
12 | return processor.process('<!--@foo--><!--/@-->', {filePath: __filename})
|
13 | .then(newmd => {
|
14 | expect(newmd).to.eq('<!--@foo-->\nfoo\n<!--/@-->\n')
|
15 | done()
|
16 | })
|
17 | .catch(done)
|
18 | })
|
19 | })
|
20 |
|
21 | it('should process AST', done => {
|
22 | const ast = m('markdownScript', { code: 'foo' }, [])
|
23 | return mos()
|
24 | .use(md => ({ foo: 'foo' }))
|
25 | .process(ast, {filePath: __filename})
|
26 | .then(newmd => {
|
27 | expect(newmd).to.eq('<!--@foo-->\nfoo\n<!--/@-->')
|
28 | done()
|
29 | })
|
30 | .catch(done)
|
31 | })
|
32 | })
|