Skip to content

Commit 9986d9e

Browse files
yeonjuanbtmills
authored andcommitted
Chore: add object option test cases in yield-star-spacing (#12679)
1 parent 1713d07 commit 9986d9e

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/lib/rules/yield-star-spacing.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ ruleTester.run("yield-star-spacing", rule, {
137137
{
138138
code: "function *foo(){ var result = yield*foo(); }",
139139
options: ["neither"]
140+
},
141+
142+
// object option
143+
{
144+
code: "function *foo(){ yield* foo; }",
145+
options: [{ before: false, after: true }]
146+
},
147+
{
148+
code: "function *foo(){ yield *foo; }",
149+
options: [{ before: true, after: false }]
150+
},
151+
{
152+
code: "function *foo(){ yield * foo; }",
153+
options: [{ before: true, after: true }]
154+
},
155+
{
156+
code: "function *foo(){ yield*foo; }",
157+
options: [{ before: false, after: false }]
140158
}
141159
],
142160

@@ -227,6 +245,32 @@ ruleTester.run("yield-star-spacing", rule, {
227245
output: "function *foo(){ yield*foo; }",
228246
options: ["neither"],
229247
errors: [unexpectedBeforeError, unexpectedAfterError]
248+
},
249+
250+
// object option
251+
{
252+
code: "function *foo(){ yield*foo; }",
253+
output: "function *foo(){ yield* foo; }",
254+
options: [{ before: false, after: true }],
255+
errors: [missingAfterError]
256+
},
257+
{
258+
code: "function *foo(){ yield * foo; }",
259+
output: "function *foo(){ yield *foo; }",
260+
options: [{ before: true, after: false }],
261+
errors: [unexpectedAfterError]
262+
},
263+
{
264+
code: "function *foo(){ yield*foo; }",
265+
output: "function *foo(){ yield * foo; }",
266+
options: [{ before: true, after: true }],
267+
errors: [missingBeforeError, missingAfterError]
268+
},
269+
{
270+
code: "function *foo(){ yield * foo; }",
271+
output: "function *foo(){ yield*foo; }",
272+
options: [{ before: false, after: false }],
273+
errors: [unexpectedBeforeError, unexpectedAfterError]
230274
}
231275
]
232276

0 commit comments

Comments
 (0)