Skip to content

Commit 0975871

Browse files
fix: html report, it is return html if output is not defined
Html report should be encapsulated and not return all files to save it.
1 parent 874069c commit 0975871

File tree

15 files changed

+277
-704
lines changed

15 files changed

+277
-704
lines changed

__tests__/__snapshots__/bin.js.snap

Lines changed: 192 additions & 142 deletions
Large diffs are not rendered by default.

__tests__/bin.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import os from 'os';
55
import { exec } from 'child_process';
66
import tmp from 'tmp';
77
import fs from 'fs-extra';
8+
import { fileURLToPath } from 'url';
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
812

913
function documentation(args, options, parseJSON) {
1014
if (!options) {
@@ -44,7 +48,7 @@ function normalize(result) {
4448
return result;
4549
}
4650

47-
test.skip('documentation binary', async function () {
51+
test('documentation binary', async function () {
4852
const data = await documentation(['build fixture/simple.input.js'], {});
4953
expect(data.length).toBe(1);
5054
});
@@ -56,14 +60,14 @@ test.skip('defaults to parsing package.json main', async function () {
5660
expect(data.length).toBeTruthy();
5761
});
5862

59-
test.skip('accepts config file', async function () {
63+
test('accepts config file', async function () {
6064
const data = await documentation([
6165
'build fixture/sorting/input.js -c fixture/config.json'
6266
]);
6367
expect(normalize(data)).toMatchSnapshot();
6468
});
6569

66-
test.skip('accepts config file - reports failures', async function () {
70+
test('accepts config file - reports failures', async function () {
6771
try {
6872
await documentation(
6973
['build fixture/sorting/input.js -c fixture/config-bad.yml'],
@@ -75,7 +79,7 @@ test.skip('accepts config file - reports failures', async function () {
7579
}
7680
});
7781

78-
test.skip('accepts config file - reports parse failures', async function () {
82+
test('accepts config file - reports parse failures', async function () {
7983
try {
8084
await documentation(
8185
['build fixture/sorting/input.js -c fixture/config-malformed.json'],
@@ -87,42 +91,42 @@ test.skip('accepts config file - reports parse failures', async function () {
8791
}
8892
});
8993

90-
test.skip('--shallow option', async function () {
94+
test('--shallow option', async function () {
9195
const data = await documentation([
9296
'build --shallow fixture/internal.input.js'
9397
]);
9498
expect(data.length).toBe(0);
9599
});
96100

97-
test.skip('external modules option', async function () {
101+
test('external modules option', async function () {
98102
const data = await documentation([
99103
'build fixture/external.input.js ' +
100104
'--external=external --external=external/node_modules'
101105
]);
102106
expect(data.length).toBe(2);
103107
});
104108

105-
test.skip('when a file is specified both in a glob and explicitly, it is only documented once', async function () {
109+
test('when a file is specified both in a glob and explicitly, it is only documented once', async function () {
106110
const data = await documentation([
107111
'build fixture/simple.input.js fixture/simple.input.*'
108112
]);
109113
expect(data.length).toBe(1);
110114
});
111115

112-
test.skip('extension option', async function () {
116+
test('extension option', async function () {
113117
const data = await documentation([
114118
'build fixture/extension/index.otherextension ' +
115119
'--requireExtension=otherextension --parseExtension=otherextension'
116120
]);
117121
expect(data.length).toBe(1);
118122
});
119123

120-
test.skip('extension option', function () {
124+
test('extension option', function () {
121125
return documentation(['build fixture/extension.jsx']);
122126
});
123127

124128
describe('invalid arguments', function () {
125-
test.skip('bad -f option', async function () {
129+
test('bad -f option', async function () {
126130
try {
127131
await documentation(
128132
['build -f DOES-NOT-EXIST fixture/internal.input.js'],
@@ -134,7 +138,7 @@ describe('invalid arguments', function () {
134138
}
135139
});
136140

137-
test.skip('html with no destination', async function () {
141+
test('html with no destination', async function () {
138142
try {
139143
await documentation(['build -f html fixture/internal.input.js']);
140144
} catch (err) {
@@ -148,7 +152,7 @@ describe('invalid arguments', function () {
148152
}
149153
});
150154

151-
test.skip('bad command', async function () {
155+
test('bad command', async function () {
152156
try {
153157
await documentation(['-f html fixture/internal.input.js'], {}, false);
154158
} catch (err) {
@@ -159,7 +163,7 @@ describe('invalid arguments', function () {
159163

160164
const semver =
161165
/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
162-
test.skip('--config', async function () {
166+
test('--config', async function () {
163167
const dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
164168
fs.mkdirSync(dst);
165169
const outputIndex = path.join(dst, 'index.html');
@@ -172,18 +176,18 @@ test.skip('--config', async function () {
172176
false
173177
);
174178
let output = fs.readFileSync(outputIndex, 'utf8');
175-
const version = require('../package.json').version;
179+
const version = (await import('../package.json')).default.version;
176180
output = output.replace(new RegExp(version.replace(/\./g, '\\.'), 'g'), '');
177181
expect(output).toMatchSnapshot();
178182
});
179183

180-
test.skip('--version', async function () {
184+
test('--version', async function () {
181185
const output = await documentation(['--version'], {}, false);
182186
expect(output).toBeTruthy();
183187
});
184188

185189
describe('lint command', function () {
186-
test.skip('generates lint output', async function () {
190+
test('generates lint output', async function () {
187191
try {
188192
await documentation(['lint fixture/lint/lint.input.js'], {}, false);
189193
} catch (err) {
@@ -192,7 +196,7 @@ describe('lint command', function () {
192196
}
193197
});
194198

195-
test.skip('generates no output on a good file', async function () {
199+
test('generates no output on a good file', async function () {
196200
const data = await documentation(
197201
['lint fixture/simple.input.js'],
198202
{},
@@ -201,7 +205,7 @@ describe('lint command', function () {
201205
expect(data).toBe('');
202206
});
203207

204-
test.skip('exposes syntax error on a bad file', async function () {
208+
test('exposes syntax error on a bad file', async function () {
205209
try {
206210
await documentation(
207211
['lint fixture/bad/syntax.input', '--parseExtension input'],
@@ -213,7 +217,7 @@ describe('lint command', function () {
213217
}
214218
});
215219

216-
test.skip('lint with no inputs', async function () {
220+
test('lint with no inputs', async function () {
217221
try {
218222
await documentation(
219223
['lint'],
@@ -227,7 +231,7 @@ describe('lint command', function () {
227231
}
228232
});
229233

230-
test.skip('generates lint output with shallow', async function () {
234+
test('generates lint output with shallow', async function () {
231235
const data = await documentation(
232236
['lint fixture/lint/lint.input.shallow.js --shallow'],
233237
{},
@@ -237,7 +241,7 @@ describe('lint command', function () {
237241
});
238242
});
239243

240-
test.skip('given no files', async function () {
244+
test('given no files', async function () {
241245
try {
242246
await documentation(['build']);
243247
} catch (err) {
@@ -251,7 +255,7 @@ test.skip('given no files', async function () {
251255
}
252256
});
253257

254-
test.skip('with an invalid command', async function () {
258+
test('with an invalid command', async function () {
255259
try {
256260
await documentation(['invalid'], {}, false);
257261
} catch (err) {

__tests__/test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,9 @@ describe('html', function () {
106106
const result = await documentation.build([file], options);
107107
const html = await outputHtml(result, {});
108108
const clean = html
109-
.sort((a, b) => a.path > b.path)
110-
.filter(r => r.path.match(/(html)$/))
111-
.map(r =>
112-
r.contents
113-
.toString()
114-
.replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '')
115-
.replace(/<code>\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, '')
116-
)
117-
.join('\n');
109+
.replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '')
110+
.replace(/<code>\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, '');
111+
118112
expect(clean).toMatchSnapshot();
119113
});
120114
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy