import {readFileSync as file} from 'fs'; import {join} from 'path'; import unified from 'unified'; import test from 'ava'; import raw from 'rehype-raw'; import reParse from 'remark-parse'; import stringify from 'rehype-stringify'; import remark2rehype from 'remark-rehype'; import plugin from '../app'; const render = text => unified() .use(reParse) .use(plugin) .use(remark2rehype) .use(stringify) .processSync(text); const renderRaw = text => unified() .use(reParse) .use(plugin) .use(remark2rehype, {allowDangerousHTML: true}) .use(raw) .use(stringify) .processSync(text); test('simple', t => { const {contents} = render(` - [x] ! False - [ ] ~ None - [x] = True`); t.is(contents, `
`); }); test('mchoide-snap', t => { const {contents} = render(file(join(__dirname, 'mchoice.md'))); t.snapshot(contents); }); test('all-checked', t => { const {contents} = render(` - [x] ! False - [x] ~ None - [x] = True`); t.is(contents, `
`); }); test('none-checked', t => { const {contents} = render(` - [ ] ! False - [ ] ~ None - [ ] = True`); t.is(contents, `
`); }); test('caps-checked', t => { const {contents} = render(` - [X] ! False - [X] ~ None - [X] = True`); t.is(contents, `
`); }); test('empty-square-check', t => { const {contents} = render(` - [] ! False - [] ~ None - [] = True`); t.is(contents, `
`); }); test('multi-check', t => { const {contents} = render(` - [X] = caps - [] ! empty - [ ] ! space - [x] = checkmark`); t.is(contents, `
`); }); test('mchoide-raw-snap', t => { const {contents} = renderRaw(file(join(__dirname, 'mchoice-raw.md'))); t.snapshot(contents); }); test.todo('Citation in a multiple-choice'); test.todo('Feedback feature test'); test.todo('raw render'); test.todo('Error about check'); test.todo('Error about list'); test.todo('Error about space'); test.todo('with brackets for single choice'); test.todo('real test 1'); test.todo('real test 2'); test.todo('real test 3');