Skip to content

Commit

Permalink
wip: add text & leaf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OzakIOne committed Oct 12, 2023
1 parent f87a0b4 commit 3ea1c74
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`directives remark plugin default behavior for custom keyword 1`] = `
exports[`directives remark plugin default behavior for container directives 1`] = `
"<admonition type="danger"><p>Take care of snowstorms...</p></admonition>
<div><p>unused directive content</p></div>
<p>:::NotAContainerDirective with a phrase after</p>
Expand All @@ -9,10 +9,41 @@ exports[`directives remark plugin default behavior for custom keyword 1`] = `
<p>:::</p>"
`;

exports[`directives remark plugin default behavior for custom keyword 2`] = `
exports[`directives remark plugin default behavior for container directives 2`] = `
[
[
"[WARNING] We found a potential error in your documentation unusedDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/containerDirectives.md":7:1",
],
]
`;

exports[`directives remark plugin default behavior for leaf directives 1`] = `
"<div></div>
<p>Leaf directive in a phrase ::NotALeafDirective</p>
<p>::NotALeafDirective with a phrase after</p>"
`;

exports[`directives remark plugin default behavior for leaf directives 2`] = `
[
[
"[WARNING] We found a potential error in your documentation unusedLeafDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/leafDirectives.md":1:1",
],
]
`;

exports[`directives remark plugin default behavior for text directives 1`] = `
"<p>Simple: textDirective1</p>
<pre><code class="language-sh">Simple: textDirective1
</code></pre>
<p>Simple<div></div></p>
<pre><code class="language-sh">Simple:textDirective1
</code></pre>"
`;

exports[`directives remark plugin default behavior for text directives 2`] = `
[
[
"[WARNING] We found a potential error in your documentation textDirective2 "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/textDirectives.md":7:7",
],
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,37 @@ const processFixture = async (name: string) => {
};

describe('directives remark plugin', () => {
it('default behavior for custom keyword', async () => {
const consoleMock = jest
.spyOn(console, 'warn')
.mockImplementation(() => {});
let consoleMock;

beforeEach(() => {
consoleMock = jest.spyOn(console, 'warn').mockImplementation(() => {});
});

afterEach(() => {
consoleMock.mockRestore();
});

it('default behavior for container directives', async () => {
const result = await processFixture('containerDirectives');

expect(result).toMatchSnapshot();

expect(consoleMock.mock.calls).toMatchSnapshot();

Check failure on line 49 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Windows Tests (18.0)

directives remark plugin › default behavior for container directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for container directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/containerDirectives.md":7:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:49:36)

Check failure on line 49 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18.0)

directives remark plugin › default behavior for container directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for container directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/containerDirectives.md":7:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:49:36)

Check failure on line 49 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18)

directives remark plugin › default behavior for container directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for container directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/containerDirectives.md":7:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:49:36)

Check failure on line 49 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (20)

directives remark plugin › default behavior for container directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for container directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/containerDirectives.md":7:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:49:36)
});

it('default behavior for leaf directives', async () => {
const result = await processFixture('leafDirectives');

expect(result).toMatchSnapshot();

expect(consoleMock.mock.calls).toMatchSnapshot();

Check failure on line 57 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Windows Tests (18.0)

directives remark plugin › default behavior for leaf directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for leaf directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedLeafDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/leafDirectives.md":1:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:57:36)

Check failure on line 57 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18.0)

directives remark plugin › default behavior for leaf directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for leaf directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedLeafDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/leafDirectives.md":1:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:57:36)

Check failure on line 57 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18)

directives remark plugin › default behavior for leaf directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for leaf directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedLeafDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/leafDirectives.md":1:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:57:36)

Check failure on line 57 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (20)

directives remark plugin › default behavior for leaf directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for leaf directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation unusedLeafDirective "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/leafDirectives.md":1:1", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:57:36)
});

it('default behavior for text directives', async () => {
const result = await processFixture('textDirectives');

expect(result).toMatchSnapshot();

expect(consoleMock.mock.calls).toMatchSnapshot();

Check failure on line 65 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Windows Tests (18.0)

directives remark plugin › default behavior for text directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for text directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation textDirective2 "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/textDirectives.md":7:7", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:65:36)

Check failure on line 65 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18.0)

directives remark plugin › default behavior for text directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for text directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation textDirective2 "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/textDirectives.md":7:7", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:65:36)

Check failure on line 65 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (18)

directives remark plugin › default behavior for text directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for text directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation textDirective2 "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/textDirectives.md":7:7", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:65:36)

Check failure on line 65 in packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Tests (20)

directives remark plugin › default behavior for text directives

expect(received).toMatchSnapshot() Snapshot name: `directives remark plugin default behavior for text directives 2` - Snapshot - 5 + Received + 1 - [ - [ - "[WARNING] We found a potential error in your documentation textDirective2 "packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/__fixtures__/textDirectives.md":7:7", - ], - ] + [] at Object.toMatchSnapshot (packages/docusaurus-mdx-loader/src/remark/unusedDirectives/__tests__/index.test.ts:65:36)
});
});

0 comments on commit 3ea1c74

Please sign in to comment.