@timvir/mdx 0.2.43 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/index.test.js +53 -0
- package/knip.config.d.ts +0 -1
- package/knip.config.ts +1 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.test.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
4
|
+
import { mdxFromMarkdown } from "mdast-util-mdx";
|
|
5
|
+
import { mdxjs } from "micromark-extension-mdxjs";
|
|
6
|
+
import { remarkPlugin } from "./index.js";
|
|
7
|
+
|
|
8
|
+
async function process(doc) {
|
|
9
|
+
const tree = fromMarkdown(doc, {
|
|
10
|
+
extensions: [mdxjs()],
|
|
11
|
+
mdastExtensions: [mdxFromMarkdown()],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
await remarkPlugin()(tree, { history: ["test/samples/index.mdx"] });
|
|
15
|
+
|
|
16
|
+
return tree;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test("Sample variant=basic", async () => {
|
|
20
|
+
const tree = await process(`<Sample variant="basic" />`);
|
|
21
|
+
|
|
22
|
+
assert.strictEqual(tree.type, "root");
|
|
23
|
+
|
|
24
|
+
assert.strictEqual(tree.children.at(0).type, "mdxjsEsm");
|
|
25
|
+
|
|
26
|
+
assert.strictEqual(tree.children.at(1).type, "mdxJsxFlowElement");
|
|
27
|
+
assert.strictEqual(tree.children.at(1).name, "CIBEfJwpOCZBzAhgVmaaNZUkovAEFETME");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("Sample variant=basic props={{ variant }}", async () => {
|
|
31
|
+
const tree = await process(`<Sample variant="basic" props={{ extra: 1 }} />`);
|
|
32
|
+
|
|
33
|
+
assert.strictEqual(tree.type, "root");
|
|
34
|
+
|
|
35
|
+
assert.strictEqual(tree.children.at(0).type, "mdxjsEsm");
|
|
36
|
+
|
|
37
|
+
assert.strictEqual(tree.children.at(1).type, "mdxJsxFlowElement");
|
|
38
|
+
assert.strictEqual(tree.children.at(1).name, "CIBEfJwpOCZBzAhgVmaaNZUkovAEFETME");
|
|
39
|
+
|
|
40
|
+
assert.strictEqual(tree.children.at(1).attributes.at(0).type, "mdxJsxExpressionAttribute");
|
|
41
|
+
assert.strictEqual(tree.children.at(1).attributes.at(0).value, "...{ extra: 1 }");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("Sample as inline", async () => {
|
|
45
|
+
const tree = await process(`<Sample variant="basic" /> or <Sample variant="basic" />`);
|
|
46
|
+
|
|
47
|
+
assert.strictEqual(tree.type, "root");
|
|
48
|
+
|
|
49
|
+
assert.strictEqual(tree.children.at(0).type, "mdxjsEsm");
|
|
50
|
+
|
|
51
|
+
assert.strictEqual(tree.children.at(2).type, "paragraph");
|
|
52
|
+
assert.strictEqual(tree.children.at(2).children.at(0).type, "mdxJsxTextElement");
|
|
53
|
+
});
|
package/knip.config.d.ts
CHANGED
package/knip.config.ts
CHANGED