Skip to content

Commit efa88d2

Browse files
committed
Add roundtrip tests
1 parent d1f200d commit efa88d2

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"devDependencies": {
4444
"browserify": "^16.0.0",
45+
"mdast-util-from-markdown": "^0.7.0",
4546
"nyc": "^15.0.0",
4647
"prettier": "^2.0.0",
4748
"remark-cli": "^8.0.0",

test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var test = require('tape')
2+
var from = require('mdast-util-from-markdown')
23
var to = require('.')
34

45
test('mdast-util-to-markdown', function (t) {
@@ -2384,3 +2385,47 @@ test('escape', function (t) {
23842385

23852386
t.end()
23862387
})
2388+
2389+
test('roundtrip', function (t) {
2390+
var doc = [
2391+
'> * Lorem ipsum dolor sit amet',
2392+
'>',
2393+
'> * consectetur adipisicing elit'
2394+
].join('\n')
2395+
2396+
t.equal(to(from(doc)), doc, 'should roundtrip spread items in block quotes')
2397+
2398+
doc = [
2399+
'* Lorem ipsum dolor sit amet',
2400+
'',
2401+
' 1. consectetur adipisicing elit',
2402+
'',
2403+
' 2. sed do eiusmod tempor incididunt'
2404+
].join('\n')
2405+
2406+
t.equal(to(from(doc)), doc, 'should roundtrip spread items in sublists (1)')
2407+
2408+
doc = [
2409+
'* 1. Lorem ipsum dolor sit amet',
2410+
'',
2411+
' 2. consectetur adipisicing elit'
2412+
].join('\n')
2413+
2414+
t.equal(to(from(doc)), doc, 'should roundtrip spread items in sublists (2)')
2415+
2416+
doc = [
2417+
'* hello',
2418+
' * world',
2419+
' how',
2420+
'',
2421+
' are',
2422+
' you',
2423+
'',
2424+
' * today',
2425+
'* hi'
2426+
].join('\n')
2427+
2428+
t.equal(to(from(doc)), doc, 'should roundtrip spread items in sublists (3)')
2429+
2430+
t.end()
2431+
})

0 commit comments

Comments
 (0)