mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +02:00
test: enable a few jest eslint rules (#6900)
* test: enable a few jest eslint rules * more
This commit is contained in:
parent
1efc6c6091
commit
aa5a2d4c04
155 changed files with 3644 additions and 3478 deletions
|
@ -8,7 +8,7 @@
|
|||
import {replaceMarkdownLinks} from '../markdownLinks';
|
||||
|
||||
describe('replaceMarkdownLinks', () => {
|
||||
test('basic replace', () => {
|
||||
it('does basic replace', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -35,34 +35,10 @@ describe('replaceMarkdownLinks', () => {
|
|||
[nonexistent](hmmm.md)
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [
|
||||
Object {
|
||||
"contentPaths": Object {
|
||||
"contentPath": "docs",
|
||||
"contentPathLocalized": "i18n/docs-localized",
|
||||
},
|
||||
"filePath": "docs/intro.md",
|
||||
"link": "hmmm.md",
|
||||
},
|
||||
],
|
||||
"newContent": "
|
||||
[foo](/doc/foo)
|
||||
[baz](/doc/baz)
|
||||
[foo](/doc/foo)
|
||||
[http](http://github.com/facebook/docusaurus/README.md)
|
||||
[https](https://github.com/facebook/docusaurus/README.md)
|
||||
[asset](./foo.js)
|
||||
[asset as well](@site/docs/_partial.md)
|
||||
[looks like http...](/doc/http)
|
||||
[nonexistent](hmmm.md)
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('reference style Markdown links', () => {
|
||||
it('replaces reference style Markdown links', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -88,25 +64,11 @@ The following operations are defined for [URI]s:
|
|||
[list]: ../api/classes/divine_uri.URI.md#list
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [],
|
||||
"newContent": "
|
||||
The following operations are defined for [URI]s:
|
||||
|
||||
* [info]: Returns metadata about the resource,
|
||||
* [list]: Returns metadata about the resource's children (like getting the content of a local directory).
|
||||
|
||||
[URI]: /docs/api/classes/uri
|
||||
[info]: /docs/api/classes/uri#info
|
||||
[list]: /docs/api/classes/uri#list
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// TODO bad
|
||||
test('links in HTML comments', () => {
|
||||
it('ignores links in HTML comments', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -125,37 +87,10 @@ The following operations are defined for [URI]s:
|
|||
-->
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [
|
||||
Object {
|
||||
"contentPaths": Object {
|
||||
"contentPath": "docs",
|
||||
"contentPathLocalized": "i18n/docs-localized",
|
||||
},
|
||||
"filePath": "docs/intro.md",
|
||||
"link": "./foo.md",
|
||||
},
|
||||
Object {
|
||||
"contentPaths": Object {
|
||||
"contentPath": "docs",
|
||||
"contentPathLocalized": "i18n/docs-localized",
|
||||
},
|
||||
"filePath": "docs/intro.md",
|
||||
"link": "./foo.md",
|
||||
},
|
||||
],
|
||||
"newContent": "
|
||||
<!-- [foo](./foo.md) -->
|
||||
<!--
|
||||
[foo](./foo.md)
|
||||
-->
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('links in fenced blocks', () => {
|
||||
it('ignores links in fenced blocks', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -187,34 +122,11 @@ The following operations are defined for [URI]s:
|
|||
\`\`\`\`
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [],
|
||||
"newContent": "
|
||||
\`\`\`
|
||||
[foo](foo.md)
|
||||
\`\`\`
|
||||
|
||||
\`\`\`\`js
|
||||
[foo](foo.md)
|
||||
\`\`\`
|
||||
[foo](foo.md)
|
||||
\`\`\`
|
||||
[foo](foo.md)
|
||||
\`\`\`\`
|
||||
|
||||
\`\`\`\`js
|
||||
[foo](foo.md)
|
||||
\`\`\`
|
||||
[foo](foo.md)
|
||||
\`\`\`\`
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// TODO bad
|
||||
test('links in inline code', () => {
|
||||
it('ignores links in inline code', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -230,27 +142,11 @@ The following operations are defined for [URI]s:
|
|||
\`[foo](foo.md)\`
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [
|
||||
Object {
|
||||
"contentPaths": Object {
|
||||
"contentPath": "docs",
|
||||
"contentPathLocalized": "i18n/docs-localized",
|
||||
},
|
||||
"filePath": "docs/intro.md",
|
||||
"link": "foo.md",
|
||||
},
|
||||
],
|
||||
"newContent": "
|
||||
\`[foo](foo.md)\`
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// TODO bad
|
||||
test('links with same title as URL', () => {
|
||||
it('replaces links with same title as URL', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -270,20 +166,10 @@ The following operations are defined for [URI]s:
|
|||
[./foo.md](foo.md)
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [],
|
||||
"newContent": "
|
||||
[/docs/foo](foo.md)
|
||||
[/docs/foo](./foo.md)
|
||||
[foo.md](/docs/foo)
|
||||
[.//docs/foo](foo.md)
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('multiple links on same line', () => {
|
||||
it('replaces multiple links on same line', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
|
@ -302,13 +188,6 @@ The following operations are defined for [URI]s:
|
|||
[a](a.md), [a](a.md), [b](b.md), [c](c.md)
|
||||
`,
|
||||
}),
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"brokenMarkdownLinks": Array [],
|
||||
"newContent": "
|
||||
[a](/docs/a), [a](/docs/a), [b](/docs/b), [c](/docs/c)
|
||||
",
|
||||
}
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue