Skip to content

Commit f5e369f

Browse files
committed
fix: adding vue support broke tests that are not file based
fix #1057
1 parent e5cb9fb commit f5e369f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

__tests__/test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,28 @@ test('Vue file', async function() {
241241
normalize(data);
242242
expect(data).toMatchSnapshot();
243243
});
244+
245+
test('Use Source attribute only', async function() {
246+
await pify(chdir)(__dirname);
247+
const documentationSource = `
248+
/**
249+
* This Vue Component is a test
250+
* @returns {vue-tested} vue-tested component
251+
*/
252+
export default {
253+
254+
props: {
255+
256+
/**
257+
* This is a number
258+
*/
259+
myNumber: {
260+
default: 42,
261+
type: Number
262+
}
263+
}
264+
}`;
265+
const data = await documentation.build([{ source: documentationSource }], {});
266+
normalize(data);
267+
expect(data).toMatchSnapshot();
268+
});

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ function buildInternal(inputsAndConfig) {
105105
sourceFile.source = fs.readFileSync(sourceFile.file, 'utf8');
106106
}
107107

108-
if (path.extname(sourceFile.file) === '.vue') {
108+
if (
109+
typeof sourceFile.file === 'string' &&
110+
path.extname(sourceFile.file) === '.vue'
111+
) {
109112
return parseVueScript(sourceFile, config).map(buildPipeline);
110113
}
111114
return parseJavaScript(sourceFile, config).map(buildPipeline);

0 commit comments

Comments
 (0)