mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-27 13:38:33 +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
|
@ -1,6 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`inline code should be escaped 1`] = `
|
||||
exports[`toc remark plugin escapes inline code 1`] = `
|
||||
"export const toc = [
|
||||
{
|
||||
value: '<code><Head /></code>',
|
||||
|
@ -48,7 +48,120 @@ exports[`inline code should be escaped 1`] = `
|
|||
"
|
||||
`;
|
||||
|
||||
exports[`non text phrasing content 1`] = `
|
||||
exports[`toc remark plugin exports even with existing name 1`] = `
|
||||
"export const toc = [
|
||||
{
|
||||
value: 'Thanos',
|
||||
id: 'thanos',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Tony Stark',
|
||||
id: 'tony-stark',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Avengers',
|
||||
id: 'avengers',
|
||||
level: 3
|
||||
}
|
||||
];
|
||||
|
||||
## Thanos
|
||||
|
||||
## Tony Stark
|
||||
|
||||
### Avengers
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin exports with custom name 1`] = `
|
||||
"export const customName = [
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi-1',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Yangshun',
|
||||
id: 'yangshun',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'I ♥ unicode.',
|
||||
id: 'i--unicode',
|
||||
level: 2
|
||||
}
|
||||
];
|
||||
|
||||
### Endi
|
||||
|
||||
\`\`\`md
|
||||
## This is ignored
|
||||
\`\`\`
|
||||
|
||||
## Endi
|
||||
|
||||
Lorem ipsum
|
||||
|
||||
### Yangshun
|
||||
|
||||
Some content here
|
||||
|
||||
## I ♥ unicode.
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin handles empty headings 1`] = `
|
||||
"export const toc = [];
|
||||
|
||||
# Ignore this
|
||||
|
||||
##
|
||||
|
||||
## 
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin inserts below imports 1`] = `
|
||||
"import something from 'something';
|
||||
|
||||
import somethingElse from 'something-else';
|
||||
|
||||
export const toc = [
|
||||
{
|
||||
value: 'Title',
|
||||
id: 'title',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Test',
|
||||
id: 'test',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Again',
|
||||
id: 'again',
|
||||
level: 3
|
||||
}
|
||||
];
|
||||
|
||||
## Title
|
||||
|
||||
## Test
|
||||
|
||||
### Again
|
||||
|
||||
Content.
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin works on non text phrasing content 1`] = `
|
||||
"export const toc = [
|
||||
{
|
||||
value: '<em>Emphasis</em>',
|
||||
|
@ -88,3 +201,45 @@ exports[`non text phrasing content 1`] = `
|
|||
## \`inline.code()\`
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin works on text content 1`] = `
|
||||
"export const toc = [
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi-1',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Yangshun',
|
||||
id: 'yangshun',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'I ♥ unicode.',
|
||||
id: 'i--unicode',
|
||||
level: 2
|
||||
}
|
||||
];
|
||||
|
||||
### Endi
|
||||
|
||||
\`\`\`md
|
||||
## This is ignored
|
||||
\`\`\`
|
||||
|
||||
## Endi
|
||||
|
||||
Lorem ipsum
|
||||
|
||||
### Yangshun
|
||||
|
||||
Some content here
|
||||
|
||||
## I ♥ unicode.
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -24,185 +24,42 @@ const processFixture = async (name, options?) => {
|
|||
return result.toString();
|
||||
};
|
||||
|
||||
test('non text phrasing content', async () => {
|
||||
const result = await processFixture('non-text-content');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('inline code should be escaped', async () => {
|
||||
const result = await processFixture('inline-code');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('text content', async () => {
|
||||
const result = await processFixture('just-content');
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
"export const toc = [
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi-1',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Yangshun',
|
||||
id: 'yangshun',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'I ♥ unicode.',
|
||||
id: 'i--unicode',
|
||||
level: 2
|
||||
}
|
||||
];
|
||||
|
||||
### Endi
|
||||
|
||||
\`\`\`md
|
||||
## This is ignored
|
||||
\`\`\`
|
||||
|
||||
## Endi
|
||||
|
||||
Lorem ipsum
|
||||
|
||||
### Yangshun
|
||||
|
||||
Some content here
|
||||
|
||||
## I ♥ unicode.
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test('should export even with existing name', async () => {
|
||||
const result = await processFixture('name-exist');
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
"export const toc = [
|
||||
{
|
||||
value: 'Thanos',
|
||||
id: 'thanos',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Tony Stark',
|
||||
id: 'tony-stark',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Avengers',
|
||||
id: 'avengers',
|
||||
level: 3
|
||||
}
|
||||
];
|
||||
|
||||
## Thanos
|
||||
|
||||
## Tony Stark
|
||||
|
||||
### Avengers
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test('should export with custom name', async () => {
|
||||
const options = {
|
||||
name: 'customName',
|
||||
};
|
||||
const result = await processFixture('just-content', options);
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
"export const customName = [
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'Endi',
|
||||
id: 'endi-1',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Yangshun',
|
||||
id: 'yangshun',
|
||||
level: 3
|
||||
},
|
||||
{
|
||||
value: 'I ♥ unicode.',
|
||||
id: 'i--unicode',
|
||||
level: 2
|
||||
}
|
||||
];
|
||||
|
||||
### Endi
|
||||
|
||||
\`\`\`md
|
||||
## This is ignored
|
||||
\`\`\`
|
||||
|
||||
## Endi
|
||||
|
||||
Lorem ipsum
|
||||
|
||||
### Yangshun
|
||||
|
||||
Some content here
|
||||
|
||||
## I ♥ unicode.
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test('should insert below imports', async () => {
|
||||
const result = await processFixture('insert-below-imports');
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
"import something from 'something';
|
||||
|
||||
import somethingElse from 'something-else';
|
||||
|
||||
export const toc = [
|
||||
{
|
||||
value: 'Title',
|
||||
id: 'title',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Test',
|
||||
id: 'test',
|
||||
level: 2
|
||||
},
|
||||
{
|
||||
value: 'Again',
|
||||
id: 'again',
|
||||
level: 3
|
||||
}
|
||||
];
|
||||
|
||||
## Title
|
||||
|
||||
## Test
|
||||
|
||||
### Again
|
||||
|
||||
Content.
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test('empty headings', async () => {
|
||||
const result = await processFixture('empty-headings');
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
"export const toc = [];
|
||||
|
||||
# Ignore this
|
||||
|
||||
##
|
||||
|
||||
## 
|
||||
"
|
||||
`);
|
||||
describe('toc remark plugin', () => {
|
||||
it('works on non text phrasing content', async () => {
|
||||
const result = await processFixture('non-text-content');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('escapes inline code', async () => {
|
||||
const result = await processFixture('inline-code');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('works on text content', async () => {
|
||||
const result = await processFixture('just-content');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('exports even with existing name', async () => {
|
||||
const result = await processFixture('name-exist');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('exports with custom name', async () => {
|
||||
const options = {
|
||||
name: 'customName',
|
||||
};
|
||||
const result = await processFixture('just-content', options);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('inserts below imports', async () => {
|
||||
const result = await processFixture('insert-below-imports');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('handles empty headings', async () => {
|
||||
const result = await processFixture('empty-headings');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue