Skip to content

Commit

Permalink
test: improve test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
json-derulo committed Dec 27, 2021
1 parent e292506 commit 720d73c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/rules/deprecation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ ruleTester.run('deprecation', rule, {
getValidTestCase(`
const component = <Component/>;
`),
// Class method with multiple signatures
// Method overloads in classes
getValidTestCase(`
class Class {
method(param: string): void;
Expand All @@ -181,7 +181,7 @@ ruleTester.run('deprecation', rule, {
const obj = new Class();
obj.method('');
`),
// Interface with multiple signatures, extending a class
// Method overloads in interfaces extending a class
// This notation used to be mentioned in the TypeScript handbook
// See https://www.typescriptlang.org/docs/handbook/classes.html#using-a-class-as-an-interface
getValidTestCase(`
Expand All @@ -193,7 +193,7 @@ ruleTester.run('deprecation', rule, {
const obj: Interface = { method(args: any) {} };
obj.method('');
`),
// Class with multiple method signatures, extending an interface
// Method overloads in classes which implement an interface
getValidTestCase(`
interface Interface {}
class Class implements Interface {
Expand Down Expand Up @@ -496,23 +496,27 @@ ruleTester.run('deprecation', rule, {
const def4: Interface1 = {}; // ERROR: Interface1
const component = <Component/> // ERROR: Component
`),
// Method overloads in interfaces
getInvalidTestCase(`
interface Interface {
method(param: string): void;
/** @deprecated */ method(): void;
/** @deprecated */ method(param: number): void;
}
const obj: Interface = { method(args: any) {} };
obj.method('valid');
obj.method(); // ERROR: method
obj.method(1); // ERROR: method
`),
// Method overloads in classes
getInvalidTestCase(`
class Class {
method(param: string): void;
/** @deprecated */ method(): void;
/** @deprecated */ method(param: number): void;
}
const obj = new Class();
obj.method('valid');
obj.method(); // ERROR: method
obj.method(1); // ERROR: method
`),
Expand Down

0 comments on commit 720d73c

Please sign in to comment.