Skip to content

Commit cba8eaa

Browse files
authored
Merge pull request #122 from docsbydoxdox/feature/snapshot-tests
[hotfix] Added snapshot tests.
2 parents 320b200 + 9b30c0e commit cba8eaa

File tree

4 files changed

+255
-0
lines changed

4 files changed

+255
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`bootstrap render 1`] = `
4+
"<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset=\\"utf-8\\" />
8+
<meta name=\\"viewport\\" content=\\"initial-scale=1\\" />
9+
<title>doxdox-example - doxdox example description</title>
10+
<link
11+
href=\\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css\\"
12+
rel=\\"stylesheet\\"
13+
integrity=\\"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3\\"
14+
crossorigin=\\"anonymous\\"
15+
/>
16+
<link
17+
rel=\\"stylesheet\\"
18+
href=\\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/github.min.css\\"
19+
integrity=\\"sha512-0aPQyyeZrWj9sCA46UlmWgKOP0mUipLQ6OZXu8l4IcAmD2u31EPEy9VcIMvl7SoAaKe8bLXZhYoMaE/in+gcgA==\\"
20+
crossorigin=\\"anonymous\\"
21+
referrerpolicy=\\"no-referrer\\"
22+
/>
23+
<style>
24+
.pkg-name {
25+
font-size: 3.5rem;
26+
}
27+
28+
.pkg-description {
29+
font-size: 1.5rem;
30+
font-weight: 200;
31+
}
32+
33+
.method-name {
34+
position: relative;
35+
}
36+
37+
.method-permalink {
38+
position: absolute;
39+
margin-left: -1em;
40+
font-weight: normal;
41+
color: #eee;
42+
text-decoration: none;
43+
}
44+
</style>
45+
</head>
46+
<body>
47+
<div class=\\"bg-dark text-white\\">
48+
<div class=\\"container p-5\\">
49+
<h1 class=\\"pkg-name\\">doxdox-example</h1>
50+
51+
<p class=\\"pkg-description\\">doxdox example description</p>
52+
</div>
53+
</div>
54+
55+
<div class=\\"container\\">
56+
<div class=\\"row\\">
57+
<div class=\\"p-5 col-md-3\\">
58+
<p><b>directory/index.js</b></p>
59+
<ul class=\\"list-unstyled ml-0\\">
60+
<li><a href=\\"#index-js-methodname\\">methodName</a></li>
61+
</ul>
62+
</div>
63+
64+
<div class=\\"p-5 col-md-9\\">
65+
<div class=\\"mb-5\\"><a name=\\"index-js-methodname\\" />
66+
67+
<h2 class=\\"method-name\\">
68+
<a href=\\"#index-js-methodname\\" class=\\"method-permalink\\" aria-label=\\"Permalink\\">#</a>
69+
methodName(param)
70+
</h2>
71+
72+
<p>Method description</p>
73+
74+
75+
<h3>Parameters</h3>
76+
77+
<div class=\\"table-responsive\\">
78+
<table class=\\"table\\">
79+
<thead>
80+
<tr>
81+
<th>Name</th>
82+
<th>Types</th>
83+
<th>Description</th>
84+
</tr>
85+
</thead>
86+
<tbody>
87+
<tr>
88+
<td>param</td>
89+
<td><code>string</code></td>
90+
<td>Param description</td>
91+
</tr>
92+
</tbody>
93+
</table>
94+
95+
</div>
96+
97+
<h3>Returns</h3>
98+
99+
<p><code>void</code></p>
100+
101+
<p>Return description</p>
102+
103+
</div>
104+
105+
</div>
106+
</div>
107+
</div>
108+
109+
<footer>
110+
<div class=\\"container p-5 text-center text-muted\\">
111+
<p>
112+
Documentation generated with
113+
<a href=\\"https://github.com/docsbydoxdox/doxdox\\">doxdox</a>.
114+
</p>
115+
<p>
116+
Generated on
117+
Mock Date Mock Time
118+
</p>
119+
</div>
120+
</footer>
121+
</body>
122+
</html>
123+
"
124+
`;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import renderer from './index';
2+
3+
describe('bootstrap', () => {
4+
beforeAll(() => {
5+
global.Date = class extends Date {
6+
toDateString() {
7+
return 'Mock Date';
8+
}
9+
10+
toTimeString() {
11+
return 'Mock Time';
12+
}
13+
} as DateConstructor;
14+
});
15+
16+
it('render', async () => {
17+
expect(
18+
await renderer({
19+
name: 'doxdox-example',
20+
description: 'doxdox example description',
21+
version: '1.0.0',
22+
files: [
23+
{
24+
path: 'directory/index.js',
25+
methods: [
26+
{
27+
slug: 'index-js-methodname',
28+
name: 'methodName',
29+
fullName: 'methodName(param)',
30+
description: 'Method description',
31+
params: [
32+
{
33+
name: 'param',
34+
description: 'Param description',
35+
types: ['string']
36+
}
37+
],
38+
returns: [
39+
{
40+
description: 'Return description',
41+
types: ['void']
42+
}
43+
],
44+
private: false
45+
}
46+
]
47+
}
48+
]
49+
})
50+
).toMatchSnapshot();
51+
});
52+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`markdown render 1`] = `
4+
"# doxdox-example
5+
6+
> doxdox example description
7+
8+
## methodName(param)
9+
10+
Method description
11+
12+
### Parameters
13+
14+
| Name | Types | Description |
15+
| ----- | ------ | ----------------- |
16+
| param | string | Param description |
17+
18+
### Returns
19+
20+
void
21+
Return description
22+
23+
Documentation generated with [doxdox](https://github.com/docsbydoxdox/doxdox)
24+
25+
Generated on Mock Date Mock Time
26+
"
27+
`;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import renderer from './index';
2+
3+
describe('markdown', () => {
4+
beforeAll(() => {
5+
global.Date = class extends Date {
6+
toDateString() {
7+
return 'Mock Date';
8+
}
9+
10+
toTimeString() {
11+
return 'Mock Time';
12+
}
13+
} as DateConstructor;
14+
});
15+
16+
it('render', async () => {
17+
expect(
18+
await renderer({
19+
name: 'doxdox-example',
20+
description: 'doxdox example description',
21+
version: '1.0.0',
22+
files: [
23+
{
24+
path: 'directory/index.js',
25+
methods: [
26+
{
27+
slug: 'index-js-methodname',
28+
name: 'methodName',
29+
fullName: 'methodName(param)',
30+
description: 'Method description',
31+
params: [
32+
{
33+
name: 'param',
34+
description: 'Param description',
35+
types: ['string']
36+
}
37+
],
38+
returns: [
39+
{
40+
description: 'Return description',
41+
types: ['void']
42+
}
43+
],
44+
private: false
45+
}
46+
]
47+
}
48+
]
49+
})
50+
).toMatchSnapshot();
51+
});
52+
});

0 commit comments

Comments
 (0)