Skip to content

Commit

Permalink
chore: add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Jul 31, 2019
1 parent 71b37c1 commit 04288f7
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions packages/eslint-plugin/tests/rules/typedef.test.ts
Expand Up @@ -101,14 +101,21 @@ ruleTester.run('typedef', rule, {
},
],
},
// Parameters
// Function parameters
`function receivesNumber(a: number): void { }`,
`function receivesStrings(a: string, b: string): void { }`,
`function receivesNumber([a]: [number]): void { }`,
`function receivesNumbers([a, b]: number[]): void { }`,
`function receivesString({ a }: { a: string }): void { }`,
`function receivesStrings({ a, b }: { [i: string ]: string }): void { }`,
`function receivesNumber(a: number = 123): void { }`,
// Method parameters
`class Test {
public method(x: number): number { return x; }
}`,
`class Test {
public method(x: number = 123): number { return x; }
}`,
// Property declarations
`type Test = {
member: number;
Expand Down Expand Up @@ -292,7 +299,7 @@ ruleTester.run('typedef', rule, {
},
],
},
// Parameters
// Function parameters
{
code: `function receivesNumber(a): void { }`,
errors: [
Expand Down Expand Up @@ -351,6 +358,29 @@ ruleTester.run('typedef', rule, {
},
],
},
// Method parameters
{
code: `class Test {
public method(x): number { return x; }
}`,
errors: [
{
column: 23,
messageId: 'expectedTypedefNamed',
},
],
},
{
code: `class Test {
public method(x = 123): number { return x; }
}`,
errors: [
{
column: 23,
messageId: 'expectedTypedef',
},
],
},
// Property declarations
{
code: `type Test = {
Expand Down

0 comments on commit 04288f7

Please sign in to comment.