Skip to content

Commit

Permalink
Don't enforce ThemedComponent selectors in test HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
ybnd committed Mar 14, 2024
1 parent d15327c commit 82b630a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lint/src/rules/html/themed-component-usages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
}
},
create(context: any) {
if (context.getFilename().endsWith('.spec.ts')) {
return {};
}

return {
[`Element$1[name = /^${DISALLOWED_THEME_SELECTORS}/]`](node: any) {
context.report({
Expand Down
30 changes: 30 additions & 0 deletions lint/test/rules/themed-component-usages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,36 @@ describe('themed-component-usages (HTML)', () => {
<ds-test-themeable [test]="something"></ds-test-themeable>
`,
},
{
name: fixture('src/test.ts'),
code: `
@Component({
template: '<ds-test-themeable></ds-test-themeable>'
})
class Test {
}
`,
},
{
name: fixture('src/test.spec.ts'),
code: `
@Component({
template: '<ds-test-themeable></ds-test-themeable>'
})
class Test {
}
`,
},
{
filename: fixture('src/test.spec.ts'),
code: `
@Component({
template: '<ds-base-test-themeable></ds-base-test-themeable>'
})
class Test {
}
`,
},
],
invalid: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('CollectionSelectorComponent', () => {
scheduler = getTestScheduler();
fixture = TestBed.overrideComponent(CollectionSelectorComponent, {
set: {
template: '<ds-collection-dropdown (selectionChange)="selectObject($event)"></ds-collection-dropdown>',
template: '<ds-base-collection-dropdown (selectionChange)="selectObject($event)"></ds-base-collection-dropdown>',
},
}).createComponent(CollectionSelectorComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const QUERY = 'test query';

@Component({
template: `
<ds-configuration-search-page [configuration]="'${CONFIGURATION}'"
<ds-base-configuration-search-page [configuration]="'${CONFIGURATION}'"

Check failure on line 23 in src/app/search-page/configuration-search-page.component.spec.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Themeable components should be used via their ThemedComponent wrapper's selector

Check failure on line 23 in src/app/search-page/configuration-search-page.component.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Themeable components should be used via their ThemedComponent wrapper's selector
[fixedFilterQuery]="'${QUERY}'"
#configurationSearchPage>
</ds-configuration-search-page>
</ds-base-configuration-search-page>
`,
})
class HostComponent {
Expand Down

0 comments on commit 82b630a

Please sign in to comment.