diff options
author | ache <ache@ache.one> | 2018-02-07 12:48:40 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2018-02-07 12:48:40 +0100 |
commit | a0f758c21347c386226f1cc22cf7489069efb0c8 (patch) | |
tree | 22af144c1025fb17aa35477223007991a977aeb5 | |
parent | Add test with AVA (diff) |
Add more tests
-rw-r--r-- | __tests__/__snapshots__/index.js.md | 22 | ||||
-rw-r--r-- | __tests__/__snapshots__/index.js.snap | bin | 549 -> 564 bytes | |||
-rw-r--r-- | __tests__/index.js | 84 | ||||
-rw-r--r-- | __tests__/mchoice.md | 7 |
4 files changed, 90 insertions, 23 deletions
diff --git a/__tests__/__snapshots__/index.js.md b/__tests__/__snapshots__/index.js.md index 3063a53..f67280e 100644 --- a/__tests__/__snapshots__/index.js.md +++ b/__tests__/__snapshots__/index.js.md @@ -4,26 +4,20 @@ The actual snapshot is saved in `index.js.snap`. Generated by [AVA](https://ava.li). -## mchoide +## mchoide-raw-snap > Snapshot 1 `<p>That is a multiple choice test :</p>␊ - <fieldset class="mc check" id="mc_1"><ul style="list-style-type: none"><li style="list-style-type: none"><input type="checkbox" id="mc_1_0" class="!"><label for="mc_1_0"> The answer D␍ - </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_1" class="="><label for="mc_1_1"> That doesn't work ␍ - <em>at the moment</em></label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_2" class="!"><label for="mc_1_2"> It's still work !␍ - </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_1_3"><label for="mc_1_3"> It will work␍ - </label></li></ul><input onclick="check('mc_1',[0,1,0,0.5])" value="Validate" type="button"></fieldset>` + <fieldset class="mc check" id="mc_0"><ul><li><input type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">The answer D</label></li><li><input type="checkbox" id="mc_0_1" class="="><label for="mc_0_1">That doesn't work<em>at the moment</em></label></li><li><input type="checkbox" id="mc_0_2" class="!"><label for="mc_0_2">It's still work !</label></li><li><input type="checkbox" id="mc_0_3" class="~"><label for="mc_0_3">It will work</label></li></ul><input onclick="check('mc_0',[0,1,0,0.5])" value="Validate" type="button"></fieldset>␊ + <p><span>This is a HTML injected in a markdown file</span></p>␊ + <div>The plugin should not modify the HTML injected part</div>` -## mchoide-raw +## mchoide-snap > Snapshot 1 `<p>That is a multiple choice test :</p>␊ - <fieldset class="mc check" id="mc_2"><ul style="list-style-type: none"><li style="list-style-type: none"><input type="checkbox" id="mc_2_0" class="!"><label for="mc_2_0"> The answer D␍ - </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_1" class="="><label for="mc_2_1"> That doesn't work ␍ - <em>at the moment</em></label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_2" class="!"><label for="mc_2_2"> It's still work !␍ - </label></li><li style="list-style-type: none"><input type="checkbox" id="mc_2_3"><label for="mc_2_3"> It will work␍ - </label></li></ul><input onclick="check('mc_2',[0,1,0,0.5])" value="Validate" type="button"></fieldset>␊ - <p><span>This is a HTML injected in a markdown file</span></p>␊ - <div>The plugin should not modify the HTML injected part</div>` + <fieldset class="mc check" id="mc_0"><ul><li><input type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">The answer D</label></li><li><input type="checkbox" id="mc_0_1" class="="><label for="mc_0_1">That doesn't work<em>at the moment</em></label></li><li><input type="checkbox" id="mc_0_2" class="!"><label for="mc_0_2">It's still work !</label></li><li><input type="checkbox" id="mc_0_3" class="~"><label for="mc_0_3">It will work</label></li></ul><input onclick="check('mc_0',[0,1,0,0.5])" value="Validate" type="button"></fieldset>␊ + <p>And this is an other QCM :</p>␊ + <fieldset class="mc check" id="mc_1"><ul><li><input type="checkbox" id="mc_1_0" class="!"><label for="mc_1_0">The answer D</label></li><li><input checked type="checkbox" id="mc_1_1" class="="><label for="mc_1_1">That doesn't work<em>at the moment</em></label></li><li><input type="checkbox" id="mc_1_2" class="!"><label for="mc_1_2">It's still work !</label></li><li><input checked type="checkbox" id="mc_1_3" class="~"><label for="mc_1_3">It will work</label></li></ul><input onclick="check('mc_1',[0,1,0,0.5])" value="Validate" type="button"></fieldset>` diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap Binary files differindex 0464d51..e58a82b 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap diff --git a/__tests__/index.js b/__tests__/index.js index df1e62f..59afa38 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -30,25 +30,91 @@ test('simple', t => { - [x] ! False - [ ] ~ None - [x] = True`); - t.is(contents, ''); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input checked type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">False</label></li>\ +<li><input type="checkbox" id="mc_0_1" class="~"><label for="mc_0_1">None</label></li>\ +<li><input checked type="checkbox" id="mc_0_2" class="="><label for="mc_0_2">True</label></li>\ +</ul><input onclick="check('mc_0',[0,0.5,1])" value="Validate" type="button"></fieldset>`); }); -test('mchoide', t => { +test('mchoide-snap', t => { const {contents} = render(file(join(__dirname, 'mchoice.md'))); t.snapshot(contents); }); -test('mchoide-raw', t => { +test('all-checked', t => { + const {contents} = render(` + - [x] ! False + - [x] ~ None + - [x] = True`); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input checked type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">False</label></li>\ +<li><input checked type="checkbox" id="mc_0_1" class="~"><label for="mc_0_1">None</label></li>\ +<li><input checked type="checkbox" id="mc_0_2" class="="><label for="mc_0_2">True</label></li>\ +</ul><input onclick="check('mc_0',[0,0.5,1])" value="Validate" type="button"></fieldset>`); +}); + +test('none-checked', t => { + const {contents} = render(` + - [ ] ! False + - [ ] ~ None + - [ ] = True`); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">False</label></li>\ +<li><input type="checkbox" id="mc_0_1" class="~"><label for="mc_0_1">None</label></li>\ +<li><input type="checkbox" id="mc_0_2" class="="><label for="mc_0_2">True</label></li>\ +</ul><input onclick="check('mc_0',[0,0.5,1])" value="Validate" type="button"></fieldset>`); +}); + +test('caps-checked', t => { + const {contents} = render(` + - [X] ! False + - [X] ~ None + - [X] = True`); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input checked type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">False</label></li>\ +<li><input checked type="checkbox" id="mc_0_1" class="~"><label for="mc_0_1">None</label></li>\ +<li><input checked type="checkbox" id="mc_0_2" class="="><label for="mc_0_2">True</label></li>\ +</ul><input onclick="check('mc_0',[0,0.5,1])" value="Validate" type="button"></fieldset>`); +}); + +test('empty-square-check', t => { + const {contents} = render(` + - [] ! False + - [] ~ None + - [] = True`); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input type="checkbox" id="mc_0_0" class="!"><label for="mc_0_0">False</label></li>\ +<li><input type="checkbox" id="mc_0_1" class="~"><label for="mc_0_1">None</label></li>\ +<li><input type="checkbox" id="mc_0_2" class="="><label for="mc_0_2">True</label></li>\ +</ul><input onclick="check('mc_0',[0,0.5,1])" value="Validate" type="button"></fieldset>`); +}); + +test('multi-check', t => { + const {contents} = render(` + - [X] = caps + - [] ! empty + - [ ] ! space + - [x] = checkmark`); + t.is(contents, +`<fieldset class="mc check" id="mc_0"><ul>\ +<li><input checked type="checkbox" id="mc_0_0" class="="><label for="mc_0_0">caps</label></li>\ +<li><input type="checkbox" id="mc_0_1" class="!"><label for="mc_0_1">empty</label></li>\ +<li><input type="checkbox" id="mc_0_2" class="!"><label for="mc_0_2">space</label></li>\ +<li><input checked type="checkbox" id="mc_0_3" class="="><label for="mc_0_3">checkmark</label></li>\ +</ul><input onclick="check('mc_0',[1,0,0,1])" value="Validate" type="button"></fieldset>`); +}); + +test('mchoide-raw-snap', t => { const {contents} = renderRaw(file(join(__dirname, 'mchoice-raw.md'))); t.snapshot(contents); }); -test.todo('all checked'); -test.todo('none checked'); -test.todo('caps checked'); -test.todo('enpty square brackets'); -test.todo('every kind of checked'); - test.todo('Citation in a multiple-choice'); test.todo('Feedback feature test'); diff --git a/__tests__/mchoice.md b/__tests__/mchoice.md index 8a4d65d..6b8298d 100644 --- a/__tests__/mchoice.md +++ b/__tests__/mchoice.md @@ -6,3 +6,10 @@ That is a multiple choice test : - [ ] ! It's still work ! - [ ] ~ It will work +And this is an other QCM : + + - [ ] ! The answer D + - [x] = That doesn't work *at the moment* + - [x] ! It's still work ! + - [x] ~ It will work + |