Skip to content

Commit

Permalink
Make test fixtures more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
soda0289 committed Jun 5, 2017
1 parent b008b83 commit be7bd0d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
@@ -1,6 +1,4 @@

/**
* Parser: typescript-eslint-parser v2.0.0 (TS 2.2.1)
* Source code:
* function foo(a: number=0): Foo { }
*/
Expand Down Expand Up @@ -110,7 +108,7 @@ exports.parse = () => ({
22
],
"typeAnnotation": {
"type": "TSNumberKeyword",
"type": "NumberKeyword",
"range": [
16,
22
Expand Down Expand Up @@ -184,7 +182,7 @@ exports.parse = () => ({
30
],
"typeAnnotation": {
"type": "TSTypeReference",
"type": "TypeReference",
"range": [
27,
30
Expand Down
@@ -1,5 +1,4 @@
/**
* Parser: typescript-eslint-parser v2.0.0 (TS 2.2.1)
* Source code:
* const foo = function(a: number = 0): Bar { };
*/
Expand Down Expand Up @@ -141,7 +140,7 @@ exports.parse = () => ({
30
],
"typeAnnotation": {
"type": "TSNumberKeyword",
"type": "NumberKeyword",
"range": [
24,
30
Expand Down Expand Up @@ -217,7 +216,7 @@ exports.parse = () => ({
40
],
"typeAnnotation": {
"type": "TSTypeReference",
"type": "TypeReference",
"range": [
37,
40
Expand Down
@@ -1,6 +1,9 @@
/**
* Source code:
* function foo(a: number = 0) { }
*/

exports.parse = function() {
return {
exports.parse = () => ({
"type": "Program",
"loc": {
"source": null,
Expand Down Expand Up @@ -387,5 +390,4 @@ exports.parse = function() {
]
}
]
};
};
});
@@ -1,5 +1,4 @@
/**
* Parser: typescript-eslint-parser v2.0.0 (TS 2.2.1)
* Source code:
* function foo(): Bar { }
*/
Expand Down Expand Up @@ -94,7 +93,7 @@ exports.parse = () => ({
19
],
"typeAnnotation": {
"type": "TSTypeReference",
"type": "TypeReference",
"range": [
16,
19
Expand Down
@@ -1,5 +1,4 @@
/**
* Parser: typescript-eslint-parser v2.0.0 (TS 2.2.1)
* Source code:
* var a: Foo= b;
*/
Expand Down Expand Up @@ -88,7 +87,7 @@ exports.parse = () => ({
10
],
"typeAnnotation": {
"type": "TSTypeReference",
"type": "TypeReference",
"range": [
7,
10
Expand Down
@@ -1,7 +1,4 @@
"use strict";

/**
* Parser: typescript-eslint-parser v2.0.0 (TS 2.2.1)
* Source code:
* var foo: Bar = '';
*/
Expand Down Expand Up @@ -90,7 +87,7 @@ exports.parse = () => ({
12
],
"typeAnnotation": {
"type": "TSTypeReference",
"type": "TypeReference",
"range": [
9,
12
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/rules/space-infix-ops.js
Expand Up @@ -35,10 +35,10 @@ ruleTester.run("space-infix-ops", rule, {
{ code: "a |0", options: [{ int32Hint: true }] },

// Type Annotations
{ code: "function foo(a: number = 0) { }", parser: parser("flow-stub-parser"), parserOptions: { ecmaVersion: 6 } },
{ code: "function foo(): Bar { }", parser: parser("typescript-parsers/function-declaration-type-annotation"), parserOptions: { ecmaVersion: 6 } },
{ code: "var foo: Bar = '';", parser: parser("typescript-parsers/variable-declaration-init-type-annotation"), parserOptions: { ecmaVersion: 6 } },
{ code: "const foo = function(a: number = 0): Bar { };", parser: parser("typescript-parsers/function-expression-type-annotation"), parserOptions: { ecmaVersion: 6 } }
{ code: "function foo(a: number = 0) { }", parser: parser("type-annotations/function-parameter-type-annotation"), parserOptions: { ecmaVersion: 6 } },
{ code: "function foo(): Bar { }", parser: parser("type-annotations/function-return-type-annotation"), parserOptions: { ecmaVersion: 6 } },
{ code: "var foo: Bar = '';", parser: parser("type-annotations/variable-declaration-init-type-annotation"), parserOptions: { ecmaVersion: 6 } },
{ code: "const foo = function(a: number = 0): Bar { };", parser: parser("type-annotations/function-expression-type-annotation"), parserOptions: { ecmaVersion: 6 } }
],
invalid: [
{
Expand Down Expand Up @@ -359,7 +359,7 @@ ruleTester.run("space-infix-ops", rule, {
{
code: "var a: Foo= b;",
output: "var a: Foo = b;",
parser: parser("typescript-parsers/variable-declaration-init-type-annotation-no-space"),
parser: parser("type-annotations/variable-declaration-init-type-annotation-no-space"),
errors: [{
message: "Infix operators must be spaced.",
type: "VariableDeclarator",
Expand All @@ -370,7 +370,7 @@ ruleTester.run("space-infix-ops", rule, {
{
code: "function foo(a: number=0): Foo { }",
output: "function foo(a: number = 0): Foo { }",
parser: parser("typescript-parsers/function-declaration-type-annotation-no-space"),
parser: parser("type-annotations/function-declaration-type-annotation-no-space"),
parserOptions: { ecmaVersion: 6 },
errors: [{
message: "Infix operators must be spaced.",
Expand Down

0 comments on commit be7bd0d

Please sign in to comment.