var test = require('tape')
var fromMarkdown = require('mdast-util-from-markdown')
var toMarkdown = require('mdast-util-to-markdown')
var syntax = require('micromark-extension-mdxjs')
var mdx = require('.')
test('markdown -> mdast', function (t) {
t.deepEqual(
JSON.parse(
JSON.stringify(
fromMarkdown('import a from "b"', {
extensions: [syntax()],
mdastExtensions: [mdx.fromMarkdown]
})
)
),
{
type: 'root',
children: [
{
type: 'mdxjsEsm',
value: 'import a from "b"',
position: {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 18, offset: 17}
},
data: {
estree: {
type: 'Program',
start: 0,
end: 17,
loc: {start: {line: 1, column: 0}, end: {line: 1, column: 17}},
body: [
{
type: 'ImportDeclaration',
start: 0,
end: 17,
loc: {
start: {line: 1, column: 0},
end: {line: 1, column: 17}
},
specifiers: [
{
type: 'ImportDefaultSpecifier',
start: 7,
end: 8,
loc: {
start: {line: 1, column: 7},
end: {line: 1, column: 8}
},
local: {
type: 'Identifier',
start: 7,
end: 8,
loc: {
start: {line: 1, column: 7},
end: {line: 1, column: 8}
},
name: 'a'
}
}
],
source: {
type: 'Literal',
start: 14,
end: 17,
loc: {
start: {line: 1, column: 14},
end: {line: 1, column: 17}
},
value: 'b',
raw: '"b"'
}
}
],
sourceType: 'module'
}
}
}
],
position: {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 18, offset: 17}
}
},
'should support esm'
)
t.deepEqual(
fromMarkdown('