-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix t.arrowFunctionExpression and t.functionExpression builders by ad…
…ding all fields
- Loading branch information
Even Alander
committed
Nov 8, 2020
1 parent
e498bee
commit 53895b3
Showing
6 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/babel-types/test/builders/core/__snapshots__/functionExpression.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`builders core functionExpression accept all parameters 1`] = ` | ||
Object { | ||
"async": true, | ||
"body": Object { | ||
"body": Array [ | ||
Object { | ||
"argument": Object { | ||
"type": "ThisExpression", | ||
}, | ||
"type": "ReturnStatement", | ||
}, | ||
], | ||
"directives": Array [], | ||
"type": "BlockStatement", | ||
}, | ||
"generator": true, | ||
"id": Object { | ||
"name": "foo", | ||
"type": "Identifier", | ||
}, | ||
"params": Array [ | ||
Object { | ||
"name": "bar", | ||
"type": "Identifier", | ||
}, | ||
], | ||
"returnType": Object { | ||
"type": "TSTypeAnnotation", | ||
"typeAnnotation": Object { | ||
"type": "TSStringKeyword", | ||
}, | ||
}, | ||
"type": "FunctionExpression", | ||
"typeParameters": Object { | ||
"params": Array [ | ||
Object { | ||
"constraint": Object { | ||
"type": "TSObjectKeyword", | ||
}, | ||
"default": null, | ||
"name": "bar", | ||
"type": "TSTypeParameter", | ||
}, | ||
], | ||
"type": "TSTypeParameterDeclaration", | ||
}, | ||
} | ||
`; |
22 changes: 22 additions & 0 deletions
22
packages/babel-types/test/builders/core/functionExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as t from "../../.."; | ||
|
||
describe("builders", function () { | ||
describe("core", function () { | ||
describe("functionExpression", function () { | ||
it("accept all parameters", function () { | ||
const functionExpression = t.functionExpression( | ||
t.identifier("foo"), | ||
[t.identifier("bar")], | ||
t.blockStatement([t.returnStatement(t.thisExpression())]), | ||
true, | ||
true, | ||
t.tsTypeAnnotation(t.tsStringKeyword()), | ||
t.tsTypeParameterDeclaration([ | ||
t.tsTypeParameter(t.tsObjectKeyword(), null, "bar"), | ||
]), | ||
); | ||
expect(functionExpression).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/babel-types/test/builders/es2015/__snapshots__/arrowFunctionExpression.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`builders es2015 arrowFunctionExpression accept all parameters 1`] = ` | ||
Object { | ||
"async": true, | ||
"body": Object { | ||
"body": Array [ | ||
Object { | ||
"argument": Object { | ||
"type": "ThisExpression", | ||
}, | ||
"type": "ReturnStatement", | ||
}, | ||
], | ||
"directives": Array [], | ||
"type": "BlockStatement", | ||
}, | ||
"expression": true, | ||
"generator": true, | ||
"params": Array [ | ||
Object { | ||
"name": "foo", | ||
"type": "Identifier", | ||
}, | ||
], | ||
"returnType": Object { | ||
"type": "TSTypeAnnotation", | ||
"typeAnnotation": Object { | ||
"type": "TSStringKeyword", | ||
}, | ||
}, | ||
"type": "ArrowFunctionExpression", | ||
"typeParameters": Object { | ||
"params": Array [ | ||
Object { | ||
"constraint": Object { | ||
"type": "TSObjectKeyword", | ||
}, | ||
"default": null, | ||
"name": "foo", | ||
"type": "TSTypeParameter", | ||
}, | ||
], | ||
"type": "TSTypeParameterDeclaration", | ||
}, | ||
} | ||
`; |
22 changes: 22 additions & 0 deletions
22
packages/babel-types/test/builders/es2015/arrowFunctionExpression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as t from "@babel/types"; | ||
|
||
describe("builders", function () { | ||
describe("es2015", function () { | ||
describe("arrowFunctionExpression", function () { | ||
it("accept all parameters", function () { | ||
const arrowFunctionExpression = t.arrowFunctionExpression( | ||
[t.identifier("foo")], | ||
t.blockStatement([t.returnStatement(t.thisExpression())]), | ||
true, | ||
true, | ||
true, | ||
t.tsTypeAnnotation(t.tsStringKeyword()), | ||
t.tsTypeParameterDeclaration([ | ||
t.tsTypeParameter(t.tsObjectKeyword(), null, "foo"), | ||
]), | ||
); | ||
expect(arrowFunctionExpression).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |