Skip to content

Commit

Permalink
test: add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
json-derulo committed Dec 15, 2021
1 parent b551184 commit 94c5f6c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/rules/deprecation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@ ruleTester.run('deprecation', rule, {
getValidTestCase(`
const component = <Component/>;
`),
getValidTestCase(`
class Class {
method(param: string): void;
/** @deprecated */ method(param: number): void;
method(param: any): void {}
}
new Class().method('');
const obj = new Class();
obj.method('');
`),
getValidTestCase(`
class Class {}
interface Interface extends Class {
method(param: string): void;
/** @deprecated */ method(param: number): void;
}
const obj: Interface = { method(args: any) {} };
obj.method('');
`),
getValidTestCase(`
interface Interface {}
class Class implements Interface {
method(param: string): void;
/** @deprecated */ method(param: number): void;
method(param: any): void {}
}
new Class().method('');
const obj = new Class();
obj.method('');
`),
],
// Error cases. `// ERROR: x` marks the spot where the error occurs.
invalid: [
Expand Down Expand Up @@ -459,6 +491,26 @@ ruleTester.run('deprecation', rule, {
const def4: Interface1 = {}; // ERROR: Interface1
const component = <Component/> // ERROR: Component
`),
getInvalidTestCase(`
interface Interface {
method(param: string): void;
/** @deprecated */ method(): void;
/** @deprecated */ method(param: number): void;
}
const obj: Interface = { method(args: any) {} };
obj.method(); // ERROR: method
obj.method(1); // ERROR: method
`),
getInvalidTestCase(`
class Class {
method(param: string): void;
/** @deprecated */ method(): void;
/** @deprecated */ method(param: number): void;
}
const obj = new Class();
obj.method(); // ERROR: method
obj.method(1); // ERROR: method
`),
],
});

Expand Down

0 comments on commit 94c5f6c

Please sign in to comment.