Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mdx TOC #883

Merged
merged 26 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/components/CodeTabs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from '@testing-library/react';
import React from 'react';
import { compile, run } from '../../index';
import { execute } from '../helpers';

describe('CodeTabs', () => {
it.skip('render _all_ its children', async () => {
Expand All @@ -12,7 +12,7 @@ assert('theme', 'dark');
assert('theme', 'light');
\`\`\`
`;
const Component = await run(compile(md));
const Component = await execute(md);
const { container } = render(<Component />);

expect(container).toHaveTextContent(`assert('theme', 'dark')`);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Glossary.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import { run, compile } from '../../index';
import { execute } from '../helpers';

describe('Glossary', () => {
it('renders a glossary item', async () => {
const md = `<Glossary>parliament</Glossary>`;
const Content = await run(compile(md));
const Content = await execute(md);
render(<Content />);

expect(screen.getByText('parliament')).toBeVisible();
Expand Down
5 changes: 2 additions & 3 deletions __tests__/components/HTMLBlock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { renderToStaticMarkup, renderToString } from 'react-dom/server';
import { vi } from 'vitest';

import HTMLBlock from '../../components/HTMLBlock';
import { compile, run } from '../../index';
import { execute } from '../helpers';

describe('HTML Block', () => {
beforeEach(() => {
Expand Down Expand Up @@ -55,8 +55,7 @@ describe('HTML Block', () => {

it('renders the html in a `<pre>` tag if safeMode={true}', async () => {
const md = '<HTMLBlock safeMode={true}>{`<button onload="alert(\'gotcha!\')"/>`}</HTMLBlock>';
const code = compile(md);
const Component = await run(code);
const Component = await execute(md);
expect(renderToStaticMarkup(<Component />)).toMatchInlineSnapshot(
'"<pre class="html-unsafe"><code>&lt;button onload=&quot;alert(&#x27;gotcha!&#x27;)&quot;/&gt;</code></pre>"',
);
Expand Down
37 changes: 0 additions & 37 deletions __tests__/components/Style.test.jsx

This file was deleted.

6 changes: 3 additions & 3 deletions __tests__/components/Variable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render, screen } from '@testing-library/react';
import React from 'react';

import { run, compile } from '../../index';
import { execute } from '../helpers';

describe('Variable', () => {
it('render a variable', async () => {
const md = `<Variable variable="name" />`;
const Content = await run(compile(md));
const Content = await execute(md);

render(<Content />);

expect(screen.getByText('NAME')).toBeVisible();
Expand Down
6 changes: 3 additions & 3 deletions __tests__/custom-components/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { compile, run } from '../../index';
import React from 'react';

import { render, screen } from '@testing-library/react';
import { execute } from '../helpers';

describe('Custom Components', () => {
const Example = () => <div>It works!</div>;
Expand All @@ -16,7 +16,7 @@ describe('Custom Components', () => {
const doc = `
<Example />
`;
const Page = await run(compile(doc), { components: { Example } });
const Page = await execute(doc, undefined, { components: { Example } });
render(<Page />);

expect(screen.getByText('It works!')).toBeVisible();
Expand All @@ -27,7 +27,7 @@ describe('Custom Components', () => {
<Composite />
`;

const Page = await run(compile(doc), { components: { Example, Composite } });
const Page = await execute(doc, undefined, { components: { Example, Composite } });
render(<Page />);

expect(screen.getByText('It works!')).toBeVisible();
Expand Down
Loading
Loading