This repository was archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathmdx.js
43 lines (41 loc) · 1.8 KB
/
mdx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { extractTextFromAst, normalizeMdx } from "../mdx";
import { mdxAsts, mdxNodes } from "./fixtures/mdx";
describe("extractTextFromAst", () => {
it("extracts text without headers", () => {
expect(extractTextFromAst(mdxAsts.basic)).toBe(
"Horizon is an API for interacting with the Stellar network. This API serves the bridge between apps and stellar-core. Projects like wallets, decentralized exchanges, and asset issuers use Horizon to submit transactions, query an account balance, or stream events like transactions to an account. Horizon is a RESTful API and can be accessed via cURL, a browser, or one of the Stellar SDKs. To reduce the complexity of your project, we recommend you use an SDK instead of making direct API calls. The Stellar Development Foundation (SDF) runs two instances of Horizon: https://horizon.stellar.org/ for interacting with the public network https://horizon-testnet.stellar.org/ for interacting with the testnet",
);
});
});
describe("normalizeMdx", () => {
it("converts nodes", () => {
expect(normalizeMdx(mdxNodes.basic)).toMatchObject({
id: expect.any(String),
order: expect.any(Number),
title: expect.any(String),
githubLink: expect.any(String),
body: expect.any(String),
directory: expect.any(String),
currentDirectory: expect.any(String),
folder: {
order: expect.any(Number),
title: expect.any(String),
},
});
});
it("gracefully fails on missing fields", () => {
expect(normalizeMdx(mdxNodes.empty)).toMatchObject({
id: undefined,
order: undefined,
title: undefined,
githubLink: undefined,
body: undefined,
directory: undefined,
currentDirectory: undefined,
folder: {
order: undefined,
title: undefined,
},
});
});
});