mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Manual fix: use base components in unit test templates
`Themed*` components should be used in the actual codebase to ensure we retain theme support. However, in unit tests these components won't work without a fully-functional `ThemeService` & `Store`. For this reason, the lint plugin allows `ds-base-*` selectors in unit test templates.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
ElementRef,
|
||||
NO_ERRORS_SCHEMA,
|
||||
} from '@angular/core';
|
||||
@@ -129,14 +128,13 @@ describe('CollectionSelectorComponent', () => {
|
||||
},
|
||||
}),
|
||||
CollectionSelectorComponent,
|
||||
// CollectionDropdownComponent,
|
||||
CollectionDropdownComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: CollectionDataService, useValue: collectionDataServiceMock },
|
||||
{ provide: ElementRef, useClass: MockElementRef },
|
||||
{ provide: NgbActiveModal, useValue: modal },
|
||||
{ provide: ActivatedRoute, useValue: {} },
|
||||
{ provide: CollectionDropdownComponent, useClass: CollectionDropdownStubComponent },
|
||||
ChangeDetectorRef,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
@@ -153,7 +151,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;
|
||||
@@ -180,19 +178,3 @@ describe('CollectionSelectorComponent', () => {
|
||||
expect((component as any).activeModal.close).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-dropdown',
|
||||
template: `
|
||||
<li
|
||||
(click)="test()"
|
||||
class="dropdown-item collection-item"
|
||||
title="test" >
|
||||
</li>`,
|
||||
standalone: true,
|
||||
})
|
||||
export class CollectionDropdownStubComponent {
|
||||
test() {
|
||||
return 'test';
|
||||
}
|
||||
}
|
||||
|
@@ -8,23 +8,23 @@ import {
|
||||
waitForAsync,
|
||||
} from '@angular/core/testing';
|
||||
import { Router } from '@angular/router';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { RouteService } from '../core/services/route.service';
|
||||
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||
import { configureSearchComponentTestingModule } from '../shared/search/search.component.spec';
|
||||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
||||
import createSpy = jasmine.createSpy;
|
||||
import { of } from 'rxjs';
|
||||
|
||||
const CONFIGURATION = 'test-configuration';
|
||||
const QUERY = 'test query';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
<ds-configuration-search-page [configuration]="'${CONFIGURATION}'"
|
||||
<ds-base-configuration-search-page [configuration]="'${CONFIGURATION}'"
|
||||
[fixedFilterQuery]="'${QUERY}'"
|
||||
#configurationSearchPage>
|
||||
</ds-configuration-search-page>
|
||||
</ds-base-configuration-search-page>
|
||||
`,
|
||||
imports: [
|
||||
ConfigurationSearchPageComponent,
|
||||
|
Reference in New Issue
Block a user