Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun committed Dec 7, 2019
1 parent 47e9e49 commit 3427ae3
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 87 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ packages/docusaurus-plugin-content-docs/lib/
packages/docusaurus-plugin-content-pages/lib/
packages/docusaurus-plugin-sitemap/lib/
packages/docusaurus-plugin-ideal-image/lib/
__fixtures__
4 changes: 2 additions & 2 deletions docs/api-doc-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ print('Hello, world!')
#include <stdio.h>

int main() {
printf("Hello World!");
return 0;
printf("Hello World!");
return 0;
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ print('Hello, world!')
#include <stdio.h>

int main() {
printf("Hello World!");
return 0;
printf("Hello World!");
return 0;
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
1. Doc

- Hello

<!--DOCUSAURUS_CODE_TABS-->
<!--JavaScript-->

```js
console.log('Hello, world!');
```

<!--Python-->

```py
print('Hello, world!')
```

<!--C-->

```C
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
```

<!--Pascal-->

```Pascal
program HelloWorld;
begin
WriteLn('Hello, world!');
end.
```

<!--END_DOCUSAURUS_CODE_TABS-->

1. Do that
* Hello
<!--DOCUSAURUS_CODE_TABS-->
<!--JavaScript-->
```js
console.log('Hello, world!');
```
<!--Python-->
```py
print('Hello, world!')
```

<!--C-->
```C
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
```

<!--Pascal-->
```Pascal
program HelloWorld;
begin
WriteLn('Hello, world!');
end.
```

<!--END_DOCUSAURUS_CODE_TABS-->
1. Do that
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,39 @@ Array [

exports[`insertTOC AUTOGENERATED_TABLE_OF_CONTENTS does not exist 1`] = `
"## foo
### foo
### foo 1
## foo 1
## foo 2
### foo
#### 4th level headings
All 4th level headings should not be shown by default
## bar
### bar
#### bar
4th level heading should be ignored by default, but is should be always taken
into account, when generating slugs
4th level heading should be ignored by default, but is should be always taken into account, when generating slugs
### \`bar\`
#### \`bar\`
## bar
### bar
#### bar
## bar
"
`;
Expand Down Expand Up @@ -237,5 +252,6 @@ Alias: \`bag\`
### \`pokemon-rename\`
Alias: \`rename\`"
Alias: \`rename\`
"
`;
42 changes: 21 additions & 21 deletions packages/docusaurus-1.x/lib/core/__tests__/split-tab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,33 @@ describe('when code tabs are used correctly', () => {
it('renders tabs correctly', () => {
const node = page.getDOMNode();
const firstTab = node.querySelector('[data-tab$="-content-2"]').textContent;
expect('JavaScript').toEqual(firstTab);
expect(firstTab).toEqual('JavaScript');
const secondTab = node.querySelector('[data-tab$="-content-3"]')
.textContent;
expect('Python').toEqual(secondTab);
expect(secondTab).toEqual('Python');
const thirdTab = node.querySelector('[data-tab$="-content-4"]').textContent;
expect('C').toEqual(thirdTab);
expect(thirdTab).toEqual('C');
const fourthTab = node.querySelector('[data-tab$="-content-5"]')
.textContent;
expect('Pascal').toEqual(fourthTab);
expect(fourthTab).toEqual('Pascal');
});
it('renders content correctly', () => {
const node = page.getDOMNode();
const firstContent = node.querySelector('[id$="-content-2"] code')
.textContent;
expect("console.log('Hello, world!');").toEqual(firstContent);
expect(firstContent).toEqual("console.log('Hello, world!');");
const secondContent = node.querySelector('[id$="-content-3"] code')
.textContent;
expect("print('Hello, world!')").toEqual(secondContent);
expect(secondContent).toEqual("print('Hello, world!')");
const thirdContent = node.querySelector('[id$="-content-4"] code')
.textContent;
expect(
'#include <stdio.h>int main() { printf("Hello World!"); return 0;}',
).toEqual(thirdContent);
expect(thirdContent).toEqual(
'#include <stdio.h>int main() { printf("Hello World!"); return 0;}',
);
const fourthContent = node.querySelector('[id$="-content-5"] code')
.textContent;
expect("program HelloWorld;begin WriteLn('Hello, world!');end.").toEqual(
fourthContent,
expect(fourthContent).toEqual(
"program HelloWorld;begin WriteLn('Hello, world!');end.",
);
});
});
Expand All @@ -92,33 +92,33 @@ describe('when code tab is used in a list', () => {
it('renders tabs correctly', () => {
const node = page.getDOMNode();
const firstTab = node.querySelector('[data-tab$="-content-2"]').textContent;
expect('JavaScript').toEqual(firstTab);
expect(firstTab).toEqual('JavaScript');
const secondTab = node.querySelector('[data-tab$="-content-3"]')
.textContent;
expect('Python').toEqual(secondTab);
expect(secondTab).toEqual('Python');
const thirdTab = node.querySelector('[data-tab$="-content-4"]').textContent;
expect('C').toEqual(thirdTab);
expect(thirdTab).toEqual('C');
const fourthTab = node.querySelector('[data-tab$="-content-5"]')
.textContent;
expect('Pascal').toEqual(fourthTab);
expect(fourthTab).toEqual('Pascal');
});
it('renders content correctly', () => {
const node = page.getDOMNode();
const firstContent = node.querySelector('[id$="-content-2"] code')
.textContent;
expect("console.log('Hello, world!');").toEqual(firstContent);
expect(firstContent).toEqual("console.log('Hello, world!');");
const secondContent = node.querySelector('[id$="-content-3"] code')
.textContent;
expect("print('Hello, world!')").toEqual(secondContent);
expect(secondContent).toEqual("print('Hello, world!')");
const thirdContent = node.querySelector('[id$="-content-4"] code')
.textContent;
expect(
expect(thirdContent).toEqual(
'#include <stdio.h>int main() { printf("Hello World!"); return 0;}',
).toEqual(thirdContent);
);
const fourthContent = node.querySelector('[id$="-content-5"] code')
.textContent;
expect("program HelloWorld;begin WriteLn('Hello, world!');end.").toEqual(
fourthContent,
expect(fourthContent).toEqual(
"program HelloWorld;begin WriteLn('Hello, world!');end.",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Docusaurus is the best :)
console.log('Docusaurus');
```

![image2](assets/image2.jpg) ![image3](assets/image3.gif)
![image2](assets/image2.jpg)

![image3](assets/image3.gif)

Don't replace the one below

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Object {
"content": "
![Docusaurus](/img/slash-introducing.png)
We are very happy to introduce [Docusaurus](https://github.com/facebook/docusaurus) to help you manage one or many open source websites.",
We are very happy to introduce [Docusaurus](https://github.com/facebook/docusaurus) to help you manage one or many open source websites.
",
"id": "Docusaurus",
"path": "2018/08/17/docusaurus.html",
"title": "Docusaurus",
Expand All @@ -33,15 +34,17 @@ exports[`replaceAssetsLink does not transform document without valid assets link
- [doc2](./doc2.md)
## Do not replace this
\`\`\`md
![image1](assets/image1.png)
\`\`\`
\`\`\`js
const doc1 = foo();
console.log(\\"[image2](assets/image2.jpg)\\");
console.log('[image2](assets/image2.jpg)');
const testStr = \`![image3](assets/image3.gif)\`;
\`\`\`"
\`\`\`
"
`;
exports[`replaceAssetsLink transform document with valid assets link 1`] = `
Expand All @@ -51,15 +54,17 @@ Docusaurus is the best :)
![image1](/blog/assets/image1.png)
\`\`\`js
console.log(\\"Docusaurus\\");
console.log('Docusaurus');
\`\`\`
![image2](/blog/assets/image2.jpg)
![image3](/blog/assets/image3.gif)
Don't replace the one below
\`\`\`md
\`\`\`md
![image4](assets/image4.bmp)
\`\`\`"
\`\`\`
"
`;
Loading

0 comments on commit 3427ae3

Please sign in to comment.