Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Update: Add tests to check the issue #18 #40

Merged
merged 1 commit into from
Dec 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions tests/object-curly-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ ruleTester.run('babel/object-curly-spacing', rule, {
// Babel test cases.
{ code: "export * as x from \"mod\";", parser: "babel-eslint", ecmaFeatures: { modules: true } },
{ code: "export x from \"mod\";", parser: "babel-eslint", ecmaFeatures: { modules: true } },

// always - destructuring typed object param
{ code: "function fn({ a,b }:Object){}", options: ["always"], parser: "babel-eslint", ecmaFeatures: { destructuring: true } },

// never - destructuring typed object param
{ code: "function fn({a,b}: Object){}", options: ["never"], parser: "babel-eslint", ecmaFeatures: { destructuring: true } },
],

invalid: [
Expand Down Expand Up @@ -780,6 +786,58 @@ ruleTester.run('babel/object-curly-spacing', rule, {
type: "ObjectExpression"
}
]
},

// Babel test cases.

// always - destructuring typed object param
{
code: "function fn({a,b}: Object){}",
output: "function fn({ a,b }: Object){}",
options: ["always"],
parser: "babel-eslint",
ecmaFeatures: {
destructuring: true
},
errors: [
{
message: "A space is required after '{'",
type: "ObjectPattern",
line: 1,
column: 14
},
{
message: "A space is required before '}'",
type: "ObjectPattern",
line: 1,
column: 17
}
]
},

// never - destructuring typed object param
{
code: "function fn({ a,b }: Object){}",
output: "function fn({a,b}: Object){}",
options: ["never"],
parser: "babel-eslint",
ecmaFeatures: {
destructuring: true
},
errors: [
{
message: "There should be no space after '{'",
type: "ObjectPattern",
line: 1,
column: 14
},
{
message: "There should be no space before '}'",
type: "ObjectPattern",
line: 1,
column: 19
}
]
}
]
});