1 | 'use strict'
|
2 | const describe = require('mocha').describe
|
3 | const it = require('mocha').it
|
4 | const expect = require('chai').expect
|
5 | const createMDScope = require('./create-md-scope')
|
6 |
|
7 | describe('createMDScope', () => {
|
8 | it('should init sync and async plugins', () => {
|
9 | function syncPlugin (opts) {
|
10 | return { foo: 'foo' }
|
11 | }
|
12 |
|
13 | function asyncPlugin (opts) {
|
14 | return Promise.resolve({ bar: 'bar' })
|
15 | }
|
16 |
|
17 | return createMDScope([syncPlugin, asyncPlugin], {})
|
18 | .then(scope => {
|
19 | expect(scope).to.eql({
|
20 | foo: 'foo',
|
21 | bar: 'bar',
|
22 | })
|
23 | })
|
24 | })
|
25 |
|
26 | it('should throw error if the scope variable is a reserved word', done => {
|
27 | createMDScope([() => ({ delete: 1 })], {})
|
28 | .catch(err => {
|
29 | expect(err).to.be.instanceof(Error)
|
30 | expect(err.message).to.eq("Cannot make 'delete' a scope variable because it is a reserved word")
|
31 | done()
|
32 | })
|
33 | })
|
34 | })
|