mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix ThumbnailComponent tests
This commit is contained in:
@@ -12,6 +12,7 @@ import { AuthService } from '../core/auth/auth.service';
|
|||||||
import { FileService } from '../core/shared/file.service';
|
import { FileService } from '../core/shared/file.service';
|
||||||
import { VarDirective } from '../shared/utils/var.directive';
|
import { VarDirective } from '../shared/utils/var.directive';
|
||||||
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
// eslint-disable-next-line @angular-eslint/pipe-prefix
|
||||||
@Pipe({
|
@Pipe({
|
||||||
@@ -48,13 +49,24 @@ describe('ThumbnailComponent', () => {
|
|||||||
fileService.retrieveFileDownloadLink.and.callFake((url) => observableOf(`${url}?authentication-token=fake`));
|
fileService.retrieveFileDownloadLink.and.callFake((url) => observableOf(`${url}?authentication-token=fake`));
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ThumbnailComponent, SafeUrlPipe, MockTranslatePipe, VarDirective],
|
imports: [
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
ThumbnailComponent,
|
||||||
|
SafeUrlPipe,
|
||||||
|
MockTranslatePipe,
|
||||||
|
VarDirective
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: AuthService, useValue: authService },
|
{ provide: AuthService, useValue: authService },
|
||||||
{ provide: AuthorizationDataService, useValue: authorizationService },
|
{ provide: AuthorizationDataService, useValue: authorizationService },
|
||||||
{ provide: FileService, useValue: fileService }
|
{ provide: FileService, useValue: fileService }
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).overrideComponent(ThumbnailComponent, {
|
||||||
|
add: {
|
||||||
|
imports: [MockTranslatePipe]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -8,6 +8,8 @@ import {
|
|||||||
platformBrowserDynamicTesting
|
platformBrowserDynamicTesting
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
} from '@angular/platform-browser-dynamic/testing';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { ThemeService } from './app/shared/theme-support/theme.service';
|
||||||
|
import { getMockThemeService } from './app/shared/mocks/theme-service.mock';
|
||||||
|
|
||||||
// First, initialize the Angular testing environment.
|
// First, initialize the Angular testing environment.
|
||||||
getTestBed().initTestEnvironment(
|
getTestBed().initTestEnvironment(
|
||||||
@@ -16,6 +18,10 @@ getTestBed().initTestEnvironment(
|
|||||||
{ teardown: { destroyAfterEach: false } }
|
{ teardown: { destroyAfterEach: false } }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jasmine.getEnv().beforeEach(() => {
|
||||||
|
getTestBed().overrideProvider(ThemeService, { useValue: getMockThemeService() });
|
||||||
|
});
|
||||||
|
|
||||||
jasmine.getEnv().afterEach(() => {
|
jasmine.getEnv().afterEach(() => {
|
||||||
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
||||||
getTestBed().inject(MockStore, null)?.resetSelectors();
|
getTestBed().inject(MockStore, null)?.resetSelectors();
|
||||||
|
Reference in New Issue
Block a user