Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding vue support broke tests that are not file based #1058

Merged
merged 3 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 281 additions & 0 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,286 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Use Source attribute only 1`] = `
Array [
Object {
"augments": Array [],
"context": Object {
"loc": SourceLocation {
"end": Position {
"column": 1,
"line": 18,
},
"start": Position {
"column": 0,
"line": 6,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 29,
"line": 1,
"offset": 28,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "This Vue Component is a test",
},
],
"position": Position {
"end": Object {
"column": 29,
"line": 1,
"offset": 28,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 29,
"line": 1,
"offset": 28,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
},
"errors": Array [
Object {
"message": "could not determine @name for hierarchy",
},
],
"examples": Array [],
"loc": SourceLocation {
"end": Position {
"column": 3,
"line": 5,
},
"start": Position {
"column": 0,
"line": 2,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "",
"namespace": "",
"params": Array [],
"path": Array [
Object {
"kind": undefined,
"name": "",
},
],
"properties": Array [],
"returns": Array [
Object {
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 21,
"line": 1,
"offset": 20,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "vue-tested component",
},
],
"position": Position {
"end": Object {
"column": 21,
"line": 1,
"offset": 20,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 21,
"line": 1,
"offset": 20,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
},
"title": "returns",
"type": Object {
"name": "vue-tested",
"type": "NameExpression",
},
},
],
"sees": Array [],
"tags": Array [
Object {
"description": "vue-tested component",
"lineNumber": 2,
"title": "returns",
"type": Object {
"name": "vue-tested",
"type": "NameExpression",
},
},
],
"throws": Array [],
"todos": Array [],
},
Object {
"augments": Array [],
"context": Object {
"loc": SourceLocation {
"end": Position {
"column": 5,
"line": 16,
},
"start": Position {
"column": 4,
"line": 13,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 17,
"line": 1,
"offset": 16,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "This is a number",
},
],
"position": Position {
"end": Object {
"column": 17,
"line": 1,
"offset": 16,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 17,
"line": 1,
"offset": 16,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
},
"errors": Array [],
"examples": Array [],
"loc": SourceLocation {
"end": Position {
"column": 7,
"line": 12,
},
"start": Position {
"column": 4,
"line": 10,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "myNumber",
"namespace": "myNumber",
"params": Array [],
"path": Array [
Object {
"kind": undefined,
"name": "myNumber",
},
],
"properties": Array [],
"returns": Array [],
"sees": Array [],
"tags": Array [],
"throws": Array [],
"todos": Array [],
},
]
`;

exports[`Vue file 1`] = `
Array [
Object {
Expand Down
27 changes: 27 additions & 0 deletions __tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,30 @@ test('Vue file', async function() {
normalize(data);
expect(data).toMatchSnapshot();
});

test('Use Source attribute only', async function() {
await pify(chdir)(__dirname);
const documentationSource = `
/**
* This Vue Component is a test
* @returns {vue-tested} vue-tested component
*/
export default {

props: {

/**
* This is a number
*/
myNumber: {
default: 42,
type: Number
}
}
}`;
const data = await documentation.build([{ source: documentationSource }], {
shallow: true
});
normalize(data);
expect(data).toMatchSnapshot();
});
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ function buildInternal(inputsAndConfig) {
sourceFile.source = fs.readFileSync(sourceFile.file, 'utf8');
}

if (!sourceFile.file) {
sourceFile.file = '';
}

if (path.extname(sourceFile.file) === '.vue') {
return parseVueScript(sourceFile, config).map(buildPipeline);
}
Expand Down