Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(eslint-plugin): refactor test case layout to help with doc gen (#…
…613)
- Loading branch information
1 parent
dfb19ec
commit 8106486
Showing
81 changed files
with
4,447 additions
and
4,449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 0 additions & 118 deletions
118
packages/eslint-plugin/tests/rules/component-class-suffix.test.ts
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
packages/eslint-plugin/tests/rules/component-class-suffix/cases.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { convertAnnotatedSourceToFailureCase } from '@angular-eslint/utils'; | ||
import type { MessageIds } from '../../../src/rules/component-class-suffix'; | ||
|
||
const messageId: MessageIds = 'componentClassSuffix'; | ||
|
||
export const valid = [ | ||
` | ||
@Component({ | ||
selector: 'sg-foo-bar', | ||
template: '<foo-bar [foo]="bar">{{baz + 42}}</foo-bar>' | ||
}) | ||
class TestComponent {} | ||
`, | ||
` | ||
@Directive({ | ||
selector: '[myHighlight]' | ||
}) | ||
class TestDirective {} | ||
`, | ||
` | ||
@Pipe({ | ||
selector: 'sg-test-pipe' | ||
}) | ||
class TestPipe {} | ||
`, | ||
` | ||
@Injectable() | ||
class TestService {} | ||
`, | ||
` | ||
class TestEmpty {} | ||
`, | ||
{ | ||
code: ` | ||
@Component({ | ||
selector: 'sgBarFoo' | ||
}) | ||
class TestPage {} | ||
`, | ||
options: [{ suffixes: ['Page'] }], | ||
}, | ||
{ | ||
code: ` | ||
@Component({ | ||
selector: 'sgBarFoo' | ||
}) | ||
class TestPage {} | ||
`, | ||
options: [{ suffixes: ['Page', 'View'] }], | ||
}, | ||
]; | ||
|
||
export const invalid = [ | ||
convertAnnotatedSourceToFailureCase({ | ||
description: 'it should fail when component class is with the wrong suffix', | ||
annotatedSource: ` | ||
@Component({ | ||
selector: 'sg-foo-bar' | ||
}) | ||
class Test {} | ||
~~~~ | ||
`, | ||
messageId, | ||
data: { suffixes: '"Component"' }, | ||
}), | ||
convertAnnotatedSourceToFailureCase({ | ||
description: `it should fail when a different list of suffixes is set and doesn't match`, | ||
annotatedSource: ` | ||
@Component({ | ||
selector: 'sgBarFoo' | ||
}) | ||
class TestPage {} | ||
~~~~~~~~ | ||
`, | ||
messageId, | ||
options: [{ suffixes: ['Component', 'View'] }], | ||
data: { suffixes: '"Component" or "View"' }, | ||
}), | ||
convertAnnotatedSourceToFailureCase({ | ||
description: `it should fail when a different list of suffixes is set and doesn't match`, | ||
annotatedSource: ` | ||
@Component({ | ||
selector: 'sgBarFoo' | ||
}) | ||
class TestPage {} | ||
~~~~~~~~ | ||
`, | ||
messageId, | ||
options: [{ suffixes: ['Component'] }], | ||
data: { suffixes: '"Component"' }, | ||
}), | ||
convertAnnotatedSourceToFailureCase({ | ||
description: `it should fail when a different list of suffixes is set and doesn't match`, | ||
annotatedSource: ` | ||
@Component({ | ||
selector: 'sgBarFoo' | ||
}) | ||
class TestDirective {} | ||
~~~~~~~~~~~~~ | ||
`, | ||
messageId, | ||
options: [{ suffixes: ['Page'] }], | ||
data: { suffixes: '"Page"' }, | ||
}), | ||
]; |
12 changes: 12 additions & 0 deletions
12
packages/eslint-plugin/tests/rules/component-class-suffix/spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { RuleTester } from '@angular-eslint/utils'; | ||
import rule, { RULE_NAME } from '../../../src/rules/component-class-suffix'; | ||
import { invalid, valid } from './cases'; | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
}); | ||
|
||
ruleTester.run(RULE_NAME, rule, { | ||
valid, | ||
invalid, | ||
}); |
Oops, something went wrong.