Skip to content

Commit

Permalink
Update fixtures and test data to uncover some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jan 30, 2019
1 parent 7d5fe5c commit 8e3acf0
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 25 deletions.
23 changes: 23 additions & 0 deletions packages/docgen/tests/fixtures/named-identifiers-ir.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"name": "functionDeclaration",
"description": "Function declaration example.",
"params": [],
"return": [],
"tags": []
},
{
"name": "variableDeclaration",
"description": "Variable declaration example.",
"params": [],
"return": [],
"tags": []
},
{
"name": "ClassDeclaration",
"description": "Class declaration example.",
"params": [],
"return": [],
"tags": []
}
]
6 changes: 5 additions & 1 deletion packages/docgen/tests/fixtures/named-import-named.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { myDeclaration } from './named-function';
export {
functionDeclaration,
variableDeclaration,
ClassDeclaration,
} from './named-identifiers';
102 changes: 80 additions & 22 deletions packages/docgen/tests/fixtures/named-import-named.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,110 @@
{
"type": "ExportNamedDeclaration",
"start": 0,
"end": 49,
"end": 101,
"range": [
0,
49
101
],
"declaration": null,
"specifiers": [
{
"type": "ExportSpecifier",
"start": 9,
"end": 22,
"start": 10,
"end": 29,
"range": [
9,
22
10,
29
],
"local": {
"type": "Identifier",
"start": 9,
"end": 22,
"start": 10,
"end": 29,
"range": [
9,
22
10,
29
],
"name": "myDeclaration"
"name": "functionDeclaration"
},
"exported": {
"type": "Identifier",
"start": 9,
"end": 22,
"start": 10,
"end": 29,
"range": [
9,
22
10,
29
],
"name": "myDeclaration"
"name": "functionDeclaration"
}
},
{
"type": "ExportSpecifier",
"start": 32,
"end": 51,
"range": [
32,
51
],
"local": {
"type": "Identifier",
"start": 32,
"end": 51,
"range": [
32,
51
],
"name": "variableDeclaration"
},
"exported": {
"type": "Identifier",
"start": 32,
"end": 51,
"range": [
32,
51
],
"name": "variableDeclaration"
}
},
{
"type": "ExportSpecifier",
"start": 54,
"end": 70,
"range": [
54,
70
],
"local": {
"type": "Identifier",
"start": 54,
"end": 70,
"range": [
54,
70
],
"name": "ClassDeclaration"
},
"exported": {
"type": "Identifier",
"start": 54,
"end": 70,
"range": [
54,
70
],
"name": "ClassDeclaration"
}
}
],
"source": {
"type": "Literal",
"start": 30,
"end": 48,
"start": 79,
"end": 100,
"range": [
30,
48
79,
100
],
"value": "./named-function",
"raw": "'./named-function'"
"value": "./named-identifiers",
"raw": "'./named-identifiers'"
}
}
8 changes: 6 additions & 2 deletions packages/docgen/tests/test-get-intermediate-representation.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,16 @@ test( 'IR - named (JSDoc in module dependency)', function( t ) {
'utf-8'
);
const getModuleImportNamed = () => JSON.parse( fs.readFileSync(
path.join( __dirname, './fixtures/named-function-ir.json' ),
path.join( __dirname, './fixtures/named-identifiers-ir.json' ),
'utf-8'
) );
t.deepEqual(
getIntermediateRepresentation( JSON.parse( tokenImportNamed ), { body: [] }, getModuleImportNamed ),
[ { name: 'myDeclaration', description: 'My declaration example.', params: [], return: [], tags: [] } ]
[
{ name: 'functionDeclaration', description: 'Function declaration example.', params: [], return: [], tags: [] },
{ name: 'variableDeclaration', description: 'Variable declaration example.', params: [], return: [], tags: [] },
{ name: 'ClassDeclaration', description: 'Class declaration example.', params: [], return: [], tags: [] },
]
);
const tokenDefaultExported = fs.readFileSync(
path.join( __dirname, './fixtures/named-default-exported.json' ),
Expand Down

0 comments on commit 8e3acf0

Please sign in to comment.