-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathindex.test.mjs
More file actions
75 lines (73 loc) · 2.34 KB
/
index.test.mjs
File metadata and controls
75 lines (73 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { compileSync } from '@mdx-js/mdx';
import CleanupReadme from './index.mjs';
describe('cleanup readme', () => {
it('should clean up div[align="center"] block without paragraph', () => {
const mdxText = `
<div align="center">
<a href="https://github.com/babel/babel">
<img src="https://rawgit.com/babel/logo/master/babel.svg" alt="Babel logo" width="200" height="200" />
</a>
<a href="https://github.com/webpack/webpack">
<img src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack logo" width="200" height="200" />
</a>
</div>
`;
const vfile = compileSync(mdxText, {
remarkPlugins: [CleanupReadme],
});
expect(vfile.value).toMatchSnapshot();
});
it('should clean up div[align="center"] block with paragraph', () => {
const mdxText = `
<div align="center">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200" hspace="10"
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg" />
</a>
<h1>Imagemin Webpack</h1>
<p>
Plugin and Loader for <a href="http://webpack.js.org/">webpack</a> to optimize (compress) all images using <a href="https://github.com/imagemin/imagemin">imagemin</a>.
Do not worry about size of images, now they are always optimized/compressed.
</p>
</div>
`;
const vfile = compileSync(mdxText, {
remarkPlugins: [CleanupReadme],
});
expect(vfile.value).toMatchSnapshot();
});
it('should clean up nested div[align="center"] block ', () => {
// see https://github.com/webpack/postcss-loader/blob/master/README.md
const mdxText = `
<div align="center">
<img
width="180"
height="180"
hspace="10"
alt="PostCSS Logo"
src="https://api.postcss.org/logo.svg" />
<a href="https://github.com/webpack/webpack">
<img
width="200"
height="200"
hspace="10"
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg" />
</a>
<div align="center">
<a href="https://evilmartians.com/?utm_source=postcss">
<img
src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians"
width="236"
height="54"
vspace="10" />
</a>
</div>
</div>
`;
const vfile = compileSync(mdxText, {
remarkPlugins: [CleanupReadme],
});
expect(vfile.value).toMatchSnapshot();
});
});