forked from hazza/dspace-angular
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 {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
|
||||||
ElementRef,
|
ElementRef,
|
||||||
NO_ERRORS_SCHEMA,
|
NO_ERRORS_SCHEMA,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -129,14 +128,13 @@ describe('CollectionSelectorComponent', () => {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
CollectionSelectorComponent,
|
CollectionSelectorComponent,
|
||||||
// CollectionDropdownComponent,
|
CollectionDropdownComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: CollectionDataService, useValue: collectionDataServiceMock },
|
{ provide: CollectionDataService, useValue: collectionDataServiceMock },
|
||||||
{ provide: ElementRef, useClass: MockElementRef },
|
{ provide: ElementRef, useClass: MockElementRef },
|
||||||
{ provide: NgbActiveModal, useValue: modal },
|
{ provide: NgbActiveModal, useValue: modal },
|
||||||
{ provide: ActivatedRoute, useValue: {} },
|
{ provide: ActivatedRoute, useValue: {} },
|
||||||
{ provide: CollectionDropdownComponent, useClass: CollectionDropdownStubComponent },
|
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
@@ -153,7 +151,7 @@ describe('CollectionSelectorComponent', () => {
|
|||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
fixture = TestBed.overrideComponent(CollectionSelectorComponent, {
|
fixture = TestBed.overrideComponent(CollectionSelectorComponent, {
|
||||||
set: {
|
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);
|
}).createComponent(CollectionSelectorComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
@@ -180,19 +178,3 @@ describe('CollectionSelectorComponent', () => {
|
|||||||
expect((component as any).activeModal.close).toHaveBeenCalled();
|
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,
|
waitForAsync,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
import { RouteService } from '../core/services/route.service';
|
import { RouteService } from '../core/services/route.service';
|
||||||
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||||
import { configureSearchComponentTestingModule } from '../shared/search/search.component.spec';
|
import { configureSearchComponentTestingModule } from '../shared/search/search.component.spec';
|
||||||
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
import { ConfigurationSearchPageComponent } from './configuration-search-page.component';
|
||||||
import createSpy = jasmine.createSpy;
|
import createSpy = jasmine.createSpy;
|
||||||
import { of } from 'rxjs';
|
|
||||||
|
|
||||||
const CONFIGURATION = 'test-configuration';
|
const CONFIGURATION = 'test-configuration';
|
||||||
const QUERY = 'test query';
|
const QUERY = 'test query';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
<ds-configuration-search-page [configuration]="'${CONFIGURATION}'"
|
<ds-base-configuration-search-page [configuration]="'${CONFIGURATION}'"
|
||||||
[fixedFilterQuery]="'${QUERY}'"
|
[fixedFilterQuery]="'${QUERY}'"
|
||||||
#configurationSearchPage>
|
#configurationSearchPage>
|
||||||
</ds-configuration-search-page>
|
</ds-base-configuration-search-page>
|
||||||
`,
|
`,
|
||||||
imports: [
|
imports: [
|
||||||
ConfigurationSearchPageComponent,
|
ConfigurationSearchPageComponent,
|
||||||
|
Reference in New Issue
Block a user