diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index a578c0d8c1..9e24790fa1 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -25,28 +25,28 @@ import { HostWindowResizeAction } from './shared/host-window.actions'; import { MetadataService } from './core/metadata/metadata.service'; -import { GLOBAL_CONFIG, ENV_CONFIG } from '../config'; import { NativeWindowRef, NativeWindowService } from './core/services/window.service'; -import { MockTranslateLoader } from './shared/mocks/mock-translate-loader'; -import { MockMetadataService } from './shared/mocks/mock-metadata-service'; +import { TranslateLoaderMock } from './shared/mocks/translate-loader.mock'; +import { MetadataServiceMock } from './shared/mocks/metadata-service.mock'; import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; -import { AngularticsMock } from './shared/mocks/mock-angulartics.service'; -import { AuthServiceMock } from './shared/mocks/mock-auth.service'; +import { AngularticsMock } from './shared/mocks/angulartics.service.mock'; +import { AuthServiceMock } from './shared/mocks/auth.service.mock'; import { AuthService } from './core/auth/auth.service'; import { MenuService } from './shared/menu/menu.service'; import { CSSVariableService } from './shared/sass-helper/sass-helper.service'; -import { CSSVariableServiceStub } from './shared/testing/css-variable-service-stub'; -import { MenuServiceStub } from './shared/testing/menu-service-stub'; +import { CSSVariableServiceStub } from './shared/testing/css-variable-service.stub'; +import { MenuServiceStub } from './shared/testing/menu-service.stub'; import { HostWindowService } from './shared/host-window.service'; -import { HostWindowServiceStub } from './shared/testing/host-window-service-stub'; +import { HostWindowServiceStub } from './shared/testing/host-window-service.stub'; import { ActivatedRoute, Router } from '@angular/router'; import { RouteService } from './core/services/route.service'; -import { MockActivatedRoute } from './shared/mocks/mock-active-router'; -import { MockRouter } from './shared/mocks/mock-router'; -import { MockCookieService } from './shared/mocks/mock-cookie.service'; +import { MockActivatedRoute } from './shared/mocks/active-router.mock'; +import { RouterMock } from './shared/mocks/router.mock'; +import { CookieServiceMock } from './shared/mocks/cookie.service.mock'; import { CookieService } from './core/services/cookie.service'; import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider'; +import { storeModuleConfig } from './app.reducer'; let comp: AppComponent; let fixture: ComponentFixture; @@ -61,33 +61,32 @@ describe('App component', () => { return TestBed.configureTestingModule({ imports: [ CommonModule, - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), ], declarations: [AppComponent], // declare the test component providers: [ - { provide: GLOBAL_CONFIG, useValue: ENV_CONFIG }, { provide: NativeWindowService, useValue: new NativeWindowRef() }, - { provide: MetadataService, useValue: new MockMetadataService() }, + { provide: MetadataService, useValue: new MetadataServiceMock() }, { provide: Angulartics2GoogleAnalytics, useValue: new AngularticsMock() }, { provide: Angulartics2DSpace, useValue: new AngularticsMock() }, { provide: AuthService, useValue: new AuthServiceMock() }, - { provide: Router, useValue: new MockRouter() }, + { provide: Router, useValue: new RouterMock() }, { provide: ActivatedRoute, useValue: new MockActivatedRoute() }, { provide: MenuService, useValue: menuService }, { provide: CSSVariableService, useClass: CSSVariableServiceStub }, { provide: HostWindowService, useValue: new HostWindowServiceStub(800) }, - { provide: CookieService, useValue: new MockCookieService()}, + { provide: CookieService, useValue: new CookieServiceMock()}, AppComponent, RouteService ], schemas: [CUSTOM_ELEMENTS_SCHEMA] - }) + }); })); // synchronous beforeEach diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4e029af8ca..832a7b642f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,8 +6,6 @@ import { select, Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import { GLOBAL_CONFIG, GlobalConfig } from '../config'; - import { MetadataService } from './core/metadata/metadata.service'; import { HostWindowResizeAction } from './shared/host-window.actions'; import { HostWindowState } from './shared/search/host-window.reducer'; @@ -26,6 +24,8 @@ import { Theme } from '../config/theme.inferface'; import { isNotEmpty } from './shared/empty.util'; import { CookieService } from './core/services/cookie.service'; import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider'; +import { environment } from '../environments/environment'; +import { models } from './core/core.module'; export const LANG_COOKIE = 'language_cookie'; @@ -44,9 +44,10 @@ export class AppComponent implements OnInit, AfterViewInit { collapsedSidebarWidth: Observable; totalSidebarWidth: Observable; theme: Observable = of({} as any); + notificationOptions = environment.notifications; + models; constructor( - @Inject(GLOBAL_CONFIG) public config: GlobalConfig, @Inject(NativeWindowService) private _window: NativeWindowRef, private translate: TranslateService, private store: Store, @@ -60,11 +61,13 @@ export class AppComponent implements OnInit, AfterViewInit { private windowService: HostWindowService, private cookie: CookieService ) { + /* Use models object so all decorators are actually called */ + this.models = models; // Load all the languages that are defined as active from the config file - translate.addLangs(config.languages.filter((LangConfig) => LangConfig.active === true).map((a) => a.code)); + translate.addLangs(environment.languages.filter((LangConfig) => LangConfig.active === true).map((a) => a.code)); // Load the default language from the config file - translate.setDefaultLang(config.defaultLanguage); + translate.setDefaultLang(environment.defaultLanguage); // Attempt to get the language from a cookie const lang = cookie.get(LANG_COOKIE); @@ -78,7 +81,7 @@ export class AppComponent implements OnInit, AfterViewInit { if (translate.getLangs().includes(translate.getBrowserLang())) { translate.use(translate.getBrowserLang()); } else { - translate.use(config.defaultLanguage); + translate.use(environment.defaultLanguage); } } @@ -87,16 +90,15 @@ export class AppComponent implements OnInit, AfterViewInit { metadata.listenForRouteChange(); - if (config.debug) { - console.info(config); + if (environment.debug) { + console.info(environment); } this.storeCSSVariables(); } ngOnInit() { - - const env: string = this.config.production ? 'Production' : 'Development'; - const color: string = this.config.production ? 'red' : 'green'; + const env: string = environment.production ? 'Production' : 'Development'; + const color: string = environment.production ? 'red' : 'green'; console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`); this.dispatchWindowSize(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight); @@ -118,10 +120,18 @@ export class AppComponent implements OnInit, AfterViewInit { } private storeCSSVariables() { - const vars = variables.locals || {}; - Object.keys(vars).forEach((name: string) => { - this.cssService.addCSSVariable(name, vars[name]); - }) + this.cssService.addCSSVariable('xlMin', '1200px'); + this.cssService.addCSSVariable('mdMin', '768px'); + this.cssService.addCSSVariable('lgMin', '576px'); + this.cssService.addCSSVariable('smMin', '0'); + this.cssService.addCSSVariable('adminSidebarActiveBg', '#0f1b28'); + this.cssService.addCSSVariable('sidebarItemsWidth', '250px'); + this.cssService.addCSSVariable('collapsedSidebarWidth', '53.234px'); + this.cssService.addCSSVariable('totalSidebarWidth', '303.234px'); + // const vars = variables.locals || {}; + // Object.keys(vars).forEach((name: string) => { + // this.cssService.addCSSVariable(name, vars[name]); + // }) } ngAfterViewInit() { @@ -142,7 +152,7 @@ export class AppComponent implements OnInit, AfterViewInit { } @HostListener('window:resize', ['$event']) - private onResize(event): void { + public onResize(event): void { this.dispatchWindowSize(event.target.innerWidth, event.target.innerHeight); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index aaad66adf6..ced019a6f9 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,7 +11,6 @@ import { DYNAMIC_MATCHER_PROVIDERS } from '@ng-dynamic-forms/core'; import { TranslateModule } from '@ngx-translate/core'; import { ScrollToModule } from '@nicky-lenaers/ngx-scroll-to'; -import { ENV_CONFIG, GLOBAL_CONFIG, GlobalConfig } from '../config'; import { AdminSidebarSectionComponent } from './+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component'; import { AdminSidebarComponent } from './+admin/admin-sidebar/admin-sidebar.component'; import { ExpandableAdminSidebarSectionComponent } from './+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component'; @@ -21,7 +20,7 @@ import { AppComponent } from './app.component'; import { appEffects } from './app.effects'; import { appMetaReducers, debugMetaReducers } from './app.metareducers'; -import { appReducers, AppState } from './app.reducer'; +import { appReducers, AppState, storeModuleConfig } from './app.reducer'; import { CoreModule } from './core/core.module'; import { ClientCookieService } from './core/services/client-cookie.service'; @@ -39,17 +38,15 @@ import { NotificationComponent } from './shared/notifications/notification/notif import { NotificationsBoardComponent } from './shared/notifications/notifications-board/notifications-board.component'; import { SharedModule } from './shared/shared.module'; import { BreadcrumbsComponent } from './breadcrumbs/breadcrumbs.component'; - -export function getConfig() { - return ENV_CONFIG; -} +import { environment } from '../environments/environment'; +import { BrowserModule } from '@angular/platform-browser'; export function getBase() { - return ENV_CONFIG.ui.nameSpace; + return environment.ui.nameSpace; } -export function getMetaReducers(config: GlobalConfig): Array> { - return config.debug ? [...appMetaReducers, ...debugMetaReducers] : appMetaReducers; +export function getMetaReducers(): Array> { + return environment.debug ? [...appMetaReducers, ...debugMetaReducers] : appMetaReducers; } const IMPORTS = [ @@ -63,7 +60,7 @@ const IMPORTS = [ NgbModule, TranslateModule.forRoot(), EffectsModule.forRoot(appEffects), - StoreModule.forRoot(appReducers), + StoreModule.forRoot(appReducers, storeModuleConfig), StoreRouterConnectingModule.forRoot(), ]; @@ -75,15 +72,11 @@ const ENTITY_IMPORTS = [ IMPORTS.push( StoreDevtoolsModule.instrument({ maxAge: 1000, - logOnly: ENV_CONFIG.production, + logOnly: environment.production, }) ); const PROVIDERS = [ - { - provide: GLOBAL_CONFIG, - useFactory: (getConfig) - }, { provide: APP_BASE_HREF, useFactory: (getBase) @@ -91,7 +84,6 @@ const PROVIDERS = [ { provide: USER_PROVIDED_META_REDUCERS, useFactory: getMetaReducers, - deps: [GLOBAL_CONFIG] }, { provide: RouterStateSerializer, @@ -121,6 +113,7 @@ const EXPORTS = [ @NgModule({ imports: [ + BrowserModule.withServerTransition({ appId: 'serverApp' }), ...IMPORTS, ...ENTITY_IMPORTS ], diff --git a/src/app/app.reducer.ts b/src/app/app.reducer.ts index e25ddcd44d..813b8d0f4f 100644 --- a/src/app/app.reducer.ts +++ b/src/app/app.reducer.ts @@ -85,3 +85,10 @@ export function keySelector(key: string, selector): MemoizedSelector { imports: [RouterTestingModule.withRoutes([]), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } })], providers: [ diff --git a/src/app/community-list-page/community-list-page.component.spec.ts b/src/app/community-list-page/community-list-page.component.spec.ts index 0aa4afce7f..346d414528 100644 --- a/src/app/community-list-page/community-list-page.component.spec.ts +++ b/src/app/community-list-page/community-list-page.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing' import { CommunityListPageComponent } from './community-list-page.component'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; -import { MockTranslateLoader } from '../shared/mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; describe('CommunityListPageComponent', () => { @@ -15,7 +15,7 @@ describe('CommunityListPageComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock }, }), ], diff --git a/src/app/community-list-page/community-list-service.spec.ts b/src/app/community-list-page/community-list-service.spec.ts index c3cfef35a0..6b7ab2bd77 100644 --- a/src/app/community-list-page/community-list-service.spec.ts +++ b/src/app/community-list-page/community-list-service.spec.ts @@ -2,7 +2,7 @@ import { of as observableOf } from 'rxjs'; import { TestBed, inject, async } from '@angular/core/testing'; import { Store } from '@ngrx/store'; import { AppState } from '../app.reducer'; -import { MockStore } from '../shared/testing/mock-store'; +import { StoreMock } from '../shared/testing/store.mock'; import { CommunityListService, FlatNode, toFlatNode } from './community-list-service'; import { CollectionDataService } from '../core/data/collection-data.service'; import { PaginatedList } from '../core/data/paginated-list'; @@ -11,110 +11,121 @@ import { CommunityDataService } from '../core/data/community-data.service'; import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ -} from '../shared/testing/utils'; +} from '../shared/remote-data.utils'; import { Community } from '../core/shared/community.model'; import { Collection } from '../core/shared/collection.model'; import { take } from 'rxjs/operators'; import { FindListOptions } from '../core/data/request.models'; describe('CommunityListService', () => { - let store: MockStore; + let store: StoreMock; const standardElementsPerPage = 2; let collectionDataServiceStub: any; let communityDataServiceStub: any; - const mockSubcommunities1Page1 = [Object.assign(new Community(), { - id: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', - uuid: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', - }), - Object.assign(new Community(), { - id: '59ee713b-ee53-4220-8c3f-9860dc84fe33', - uuid: '59ee713b-ee53-4220-8c3f-9860dc84fe33', - }) - ]; - const mockCollectionsPage1 = [ - Object.assign(new Collection(), { - id: 'e9dbf393-7127-415f-8919-55be34a6e9ed', - uuid: 'e9dbf393-7127-415f-8919-55be34a6e9ed', - name: 'Collection 1' - }), - Object.assign(new Collection(), { - id: '59da2ff0-9bf4-45bf-88be-e35abd33f304', - uuid: '59da2ff0-9bf4-45bf-88be-e35abd33f304', - name: 'Collection 2' - }) - ]; - const mockCollectionsPage2 = [ - Object.assign(new Collection(), { - id: 'a5159760-f362-4659-9e81-e3253ad91ede', - uuid: 'a5159760-f362-4659-9e81-e3253ad91ede', - name: 'Collection 3' - }), - Object.assign(new Collection(), { - id: 'a392e16b-fcf2-400a-9a88-53ef7ecbdcd3', - uuid: 'a392e16b-fcf2-400a-9a88-53ef7ecbdcd3', - name: 'Collection 4' - }) - ]; - const mockListOfTopCommunitiesPage1 = [ - Object.assign(new Community(), { - id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), mockSubcommunities1Page1)), - collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - }), - Object.assign(new Community(), { - id: '9076bd16-e69a-48d6-9e41-0238cb40d863', - uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', - subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [...mockCollectionsPage1, ...mockCollectionsPage2])), - }), - Object.assign(new Community(), { - id: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', - uuid: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', - subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - }), - ]; - const mockListOfTopCommunitiesPage2 = [ - Object.assign(new Community(), { - id: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', - uuid: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', - subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - }), - ]; - const mockTopCommunitiesWithChildrenArraysPage1 = [ - { - id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', - subcommunities: mockSubcommunities1Page1, - collections: [], - }, - { - id: '9076bd16-e69a-48d6-9e41-0238cb40d863', - uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', - subcommunities: [], - collections: [...mockCollectionsPage1, ...mockCollectionsPage2], - }, - { - id: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', - uuid: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', - subcommunities: [], - collections: [], - }]; - const mockTopCommunitiesWithChildrenArraysPage2 = [ - { - id: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', - uuid: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', - subcommunities: [], - collections: [], - }]; - - const allCommunities = [...mockTopCommunitiesWithChildrenArraysPage1, ...mockTopCommunitiesWithChildrenArraysPage2, ...mockSubcommunities1Page1]; let service: CommunityListService; + let mockSubcommunities1Page1; + let mockCollectionsPage1; + let mockCollectionsPage2; + let mockListOfTopCommunitiesPage1; + let mockListOfTopCommunitiesPage2; + let mockTopCommunitiesWithChildrenArraysPage1; + let mockTopCommunitiesWithChildrenArraysPage2; + let allCommunities; + function init() { + mockSubcommunities1Page1 = [Object.assign(new Community(), { + id: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', + uuid: 'ce64f48e-2c9b-411a-ac36-ee429c0e6a88', + }), + Object.assign(new Community(), { + id: '59ee713b-ee53-4220-8c3f-9860dc84fe33', + uuid: '59ee713b-ee53-4220-8c3f-9860dc84fe33', + }) + ]; + mockCollectionsPage1 = [ + Object.assign(new Collection(), { + id: 'e9dbf393-7127-415f-8919-55be34a6e9ed', + uuid: 'e9dbf393-7127-415f-8919-55be34a6e9ed', + name: 'Collection 1' + }), + Object.assign(new Collection(), { + id: '59da2ff0-9bf4-45bf-88be-e35abd33f304', + uuid: '59da2ff0-9bf4-45bf-88be-e35abd33f304', + name: 'Collection 2' + }) + ]; + mockCollectionsPage2 = [ + Object.assign(new Collection(), { + id: 'a5159760-f362-4659-9e81-e3253ad91ede', + uuid: 'a5159760-f362-4659-9e81-e3253ad91ede', + name: 'Collection 3' + }), + Object.assign(new Collection(), { + id: 'a392e16b-fcf2-400a-9a88-53ef7ecbdcd3', + uuid: 'a392e16b-fcf2-400a-9a88-53ef7ecbdcd3', + name: 'Collection 4' + }) + ]; + mockListOfTopCommunitiesPage1 = [ + Object.assign(new Community(), { + id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', + uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', + subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), mockSubcommunities1Page1)), + collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + }), + Object.assign(new Community(), { + id: '9076bd16-e69a-48d6-9e41-0238cb40d863', + uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', + subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [...mockCollectionsPage1, ...mockCollectionsPage2])), + }), + Object.assign(new Community(), { + id: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', + uuid: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', + subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + }), + ]; + mockListOfTopCommunitiesPage2 = [ + Object.assign(new Community(), { + id: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', + uuid: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', + subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + }), + ]; + mockTopCommunitiesWithChildrenArraysPage1 = [ + { + id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', + uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', + subcommunities: mockSubcommunities1Page1, + collections: [], + }, + { + id: '9076bd16-e69a-48d6-9e41-0238cb40d863', + uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', + subcommunities: [], + collections: [...mockCollectionsPage1, ...mockCollectionsPage2], + }, + { + id: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', + uuid: 'efbf25e1-2d8c-4c28-8f3e-2e04c215be24', + subcommunities: [], + collections: [], + }]; + mockTopCommunitiesWithChildrenArraysPage2 = [ + { + id: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', + uuid: 'c2e04392-3b8a-4dfa-976d-d76fb1b8a4b6', + subcommunities: [], + collections: [], + }]; - beforeEach(async(() => { + allCommunities = [...mockTopCommunitiesWithChildrenArraysPage1, ...mockTopCommunitiesWithChildrenArraysPage2, ...mockSubcommunities1Page1]; + + } + beforeEach(() => { + init(); communityDataServiceStub = { findTop(options: FindListOptions = {}) { const allTopComs = [...mockListOfTopCommunitiesPage1, ...mockListOfTopCommunitiesPage2]; @@ -183,12 +194,12 @@ describe('CommunityListService', () => { providers: [CommunityListService, { provide: CollectionDataService, useValue: collectionDataServiceStub }, { provide: CommunityDataService, useValue: communityDataServiceStub }, - { provide: Store, useValue: MockStore }, + { provide: Store, useValue: StoreMock }, ], }); store = TestBed.get(Store); service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store); - })); + }); it('should create', inject([CommunityListService], (serviceIn: CommunityListService) => { expect(serviceIn).toBeTruthy(); @@ -316,7 +327,10 @@ describe('CommunityListService', () => { describe('transformListOfCommunities', () => { describe('should transform list of communities in a list of flatnodes with possible subcoms and collections as subflatnodes if they\'re expanded', () => { describe('list of communities with possible children', () => { - const listOfCommunities = mockListOfTopCommunitiesPage1; + let listOfCommunities; + beforeEach(() => { + listOfCommunities = mockListOfTopCommunitiesPage1; + }); let flatNodeList; describe('None expanded: should return list containing only flatnodes of the communities in the test list', () => { beforeEach(() => { @@ -469,18 +483,19 @@ describe('CommunityListService', () => { }); describe('topcommunity with collections, expanded, on second page of collections', () => { describe('should return list containing flatnodes of that community, its collections of the first two pages', () => { - const communityWithCollections = Object.assign(new Community(), { - id: '9076bd16-e69a-48d6-9e41-0238cb40d863', - uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', - subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), - collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [...mockCollectionsPage1, ...mockCollectionsPage2])), - metadata: { - 'dc.description': [{ language: 'en_US', value: '2 subcoms, no coll' }], - 'dc.title': [{ language: 'en_US', value: 'Community 1' }] - } - }); + let communityWithCollections; let flatNodeList; beforeEach(() => { + communityWithCollections = Object.assign(new Community(), { + id: '9076bd16-e69a-48d6-9e41-0238cb40d863', + uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', + subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), + collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [...mockCollectionsPage1, ...mockCollectionsPage2])), + metadata: { + 'dc.description': [{ language: 'en_US', value: '2 subcoms, no coll' }], + 'dc.title': [{ language: 'en_US', value: 'Community 1' }] + } + }); const communityFlatNode = toFlatNode(communityWithCollections, observableOf(true), 0, true, null); communityFlatNode.currentCollectionPage = 2; communityFlatNode.currentCommunityPage = 1; diff --git a/src/app/community-list-page/community-list.reducer.spec.ts b/src/app/community-list-page/community-list.reducer.spec.ts index 63eaaccc03..23999e6166 100644 --- a/src/app/community-list-page/community-list.reducer.spec.ts +++ b/src/app/community-list-page/community-list.reducer.spec.ts @@ -2,7 +2,7 @@ import { of as observableOf } from 'rxjs/internal/observable/of'; import { PaginatedList } from '../core/data/paginated-list'; import { Community } from '../core/shared/community.model'; import { PageInfo } from '../core/shared/page-info.model'; -import { createSuccessfulRemoteDataObject$ } from '../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils'; import { toFlatNode } from './community-list-service'; import { CommunityListSaveAction } from './community-list.actions'; import { CommunityListReducer } from './community-list.reducer'; diff --git a/src/app/community-list-page/community-list/community-list.component.spec.ts b/src/app/community-list-page/community-list/community-list.component.spec.ts index c04aadda37..a91c5fa057 100644 --- a/src/app/community-list-page/community-list/community-list.component.spec.ts +++ b/src/app/community-list-page/community-list/community-list.component.spec.ts @@ -9,11 +9,11 @@ import { } from '../community-list-service'; import { CdkTreeModule } from '@angular/cdk/tree'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; -import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { RouterTestingModule } from '@angular/router/testing'; import { Community } from '../../core/shared/community.model'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { PaginatedList } from '../../core/data/paginated-list'; import { PageInfo } from '../../core/shared/page-info.model'; import { Collection } from '../../core/shared/collection.model'; @@ -199,7 +199,7 @@ describe('CommunityListComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock }, }), CdkTreeModule, diff --git a/src/app/core/auth/auth-request.service.ts b/src/app/core/auth/auth-request.service.ts index e5c9210769..465fb69dd2 100644 --- a/src/app/core/auth/auth-request.service.ts +++ b/src/app/core/auth/auth-request.service.ts @@ -3,7 +3,6 @@ import { distinctUntilChanged, filter, map, mergeMap, tap } from 'rxjs/operators import { Inject, Injectable } from '@angular/core'; import { HALEndpointService } from '../shared/hal-endpoint.service'; import { RequestService } from '../data/request.service'; -import { GLOBAL_CONFIG } from '../../../config'; import { GlobalConfig } from '../../../config/global-config.interface'; import { isNotEmpty } from '../../shared/empty.util'; import { AuthGetRequest, AuthPostRequest, GetRequest, PostRequest, RestRequest } from '../data/request.models'; @@ -17,8 +16,7 @@ export class AuthRequestService { protected linkName = 'authn'; protected browseEndpoint = ''; - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - protected halService: HALEndpointService, + constructor(protected halService: HALEndpointService, protected requestService: RequestService, private http: HttpClient) { } @@ -69,5 +67,4 @@ export class AuthRequestService { mergeMap((request: GetRequest) => this.fetchRequest(request)), distinctUntilChanged()); } - } diff --git a/src/app/core/auth/auth-response-parsing.service.spec.ts b/src/app/core/auth/auth-response-parsing.service.spec.ts index 3b18d925bf..924c60535d 100644 --- a/src/app/core/auth/auth-response-parsing.service.spec.ts +++ b/src/app/core/auth/auth-response-parsing.service.spec.ts @@ -3,12 +3,13 @@ import { async, TestBed } from '@angular/core/testing'; import { Store, StoreModule } from '@ngrx/store'; import { GlobalConfig } from '../../../config/global-config.interface'; -import { MockStore } from '../../shared/testing/mock-store'; +import { StoreMock } from '../../shared/testing/store.mock'; import { ObjectCacheService } from '../cache/object-cache.service'; import { AuthStatusResponse } from '../cache/response.models'; import { AuthGetRequest, AuthPostRequest } from '../data/request.models'; import { AuthResponseParsingService } from './auth-response-parsing.service'; import { AuthStatus } from './models/auth-status.model'; +import { storeModuleConfig } from '../../app.reducer'; describe('AuthResponseParsingService', () => { let service: AuthResponseParsingService; @@ -21,10 +22,10 @@ describe('AuthResponseParsingService', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), ], providers: [ - { provide: Store, useClass: MockStore } + { provide: Store, useClass: StoreMock } ] }).compileComponents(); })); @@ -35,7 +36,7 @@ describe('AuthResponseParsingService', () => { removeResolvedLinks: {} }); objectCacheService = new ObjectCacheService(store as any, linkServiceStub); - service = new AuthResponseParsingService(EnvConfig, objectCacheService); + service = new AuthResponseParsingService(objectCacheService); }); describe('parse', () => { diff --git a/src/app/core/auth/auth-response-parsing.service.ts b/src/app/core/auth/auth-response-parsing.service.ts index 9ef523ca14..8c77770974 100644 --- a/src/app/core/auth/auth-response-parsing.service.ts +++ b/src/app/core/auth/auth-response-parsing.service.ts @@ -3,8 +3,6 @@ import { Inject, Injectable } from '@angular/core'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; import { AuthStatusResponse, RestResponse } from '../cache/response.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { isNotEmpty } from '../../shared/empty.util'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ResponseParsingService } from '../data/parsing.service'; @@ -16,8 +14,7 @@ export class AuthResponseParsingService extends BaseResponseParsingService imple protected toCache = true; - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - protected objectCache: ObjectCacheService) { + constructor(protected objectCache: ObjectCacheService) { super(); } diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index 1f6fa51afd..e231857159 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -27,11 +27,12 @@ import { RetrieveAuthMethodsSuccessAction, RetrieveTokenAction } from './auth.actions'; -import { authMethodsMock, AuthServiceStub } from '../../shared/testing/auth-service-stub'; +import { authMethodsMock, AuthServiceStub } from '../../shared/testing/auth-service.stub'; import { AuthService } from './auth.service'; import { AuthState } from './auth.reducer'; -import { EPersonMock } from '../../shared/testing/eperson-mock'; + import { AuthStatus } from './models/auth-status.model'; +import { EPersonMock } from '../../shared/testing/eperson.mock'; describe('AuthEffects', () => { let authEffects: AuthEffects; diff --git a/src/app/core/auth/auth.interceptor.spec.ts b/src/app/core/auth/auth.interceptor.spec.ts index 72b0cc2616..f5ac0c4361 100644 --- a/src/app/core/auth/auth.interceptor.spec.ts +++ b/src/app/core/auth/auth.interceptor.spec.ts @@ -9,9 +9,9 @@ import { of as observableOf } from 'rxjs'; import { AuthInterceptor } from './auth.interceptor'; import { AuthService } from './auth.service'; import { DSpaceRESTv2Service } from '../dspace-rest-v2/dspace-rest-v2.service'; -import { RouterStub } from '../../shared/testing/router-stub'; +import { RouterStub } from '../../shared/testing/router.stub'; import { TruncatablesState } from '../../shared/truncatable/truncatable.reducer'; -import { AuthServiceStub } from '../../shared/testing/auth-service-stub'; +import { AuthServiceStub } from '../../shared/testing/auth-service.stub'; import { RestRequestMethod } from '../data/rest-request-method'; describe(`AuthInterceptor`, () => { diff --git a/src/app/core/auth/auth.reducer.spec.ts b/src/app/core/auth/auth.reducer.spec.ts index 7a39ef3da4..1606ed9185 100644 --- a/src/app/core/auth/auth.reducer.spec.ts +++ b/src/app/core/auth/auth.reducer.spec.ts @@ -26,7 +26,7 @@ import { SetRedirectUrlAction } from './auth.actions'; import { AuthTokenInfo } from './models/auth-token-info.model'; -import { EPersonMock } from '../../shared/testing/eperson-mock'; +import { EPersonMock } from '../../shared/testing/eperson.mock'; import { AuthStatus } from './models/auth-status.model'; import { AuthMethod } from './models/auth.method'; import { AuthMethodType } from './models/auth.method-type'; diff --git a/src/app/core/auth/auth.service.spec.ts b/src/app/core/auth/auth.service.spec.ts index 03759987bf..89d8cdce4e 100644 --- a/src/app/core/auth/auth.service.spec.ts +++ b/src/app/core/auth/auth.service.spec.ts @@ -9,25 +9,26 @@ import { of as observableOf } from 'rxjs'; import { authReducer, AuthState } from './auth.reducer'; import { NativeWindowRef, NativeWindowService } from '../services/window.service'; import { AuthService } from './auth.service'; -import { RouterStub } from '../../shared/testing/router-stub'; -import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; +import { RouterStub } from '../../shared/testing/router.stub'; +import { ActivatedRouteStub } from '../../shared/testing/active-router.stub'; + import { CookieService } from '../services/cookie.service'; -import { AuthRequestServiceStub } from '../../shared/testing/auth-request-service-stub'; +import { AuthRequestServiceStub } from '../../shared/testing/auth-request-service.stub'; import { AuthRequestService } from './auth-request.service'; import { AuthStatus } from './models/auth-status.model'; import { AuthTokenInfo } from './models/auth-token-info.model'; import { EPerson } from '../eperson/models/eperson.model'; -import { EPersonMock } from '../../shared/testing/eperson-mock'; +import { EPersonMock } from '../../shared/testing/eperson.mock'; import { AppState } from '../../app.reducer'; import { ClientCookieService } from '../services/client-cookie.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; -import { routeServiceStub } from '../../shared/testing/route-service-stub'; +import { routeServiceStub } from '../../shared/testing/route-service.stub'; import { RouteService } from '../services/route.service'; import { Observable } from 'rxjs/internal/Observable'; import { RemoteData } from '../data/remote-data'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; import { EPersonDataService } from '../eperson/eperson-data.service'; -import { authMethodsMock } from '../../shared/testing/auth-service-stub'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { authMethodsMock } from '../../shared/testing/auth-service.stub'; import { AuthMethod } from './models/auth.method'; describe('AuthService test', () => { @@ -81,7 +82,12 @@ describe('AuthService test', () => { TestBed.configureTestingModule({ imports: [ CommonModule, - StoreModule.forRoot({ authReducer }), + StoreModule.forRoot({ authReducer }, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), ], declarations: [], providers: [ @@ -174,7 +180,12 @@ describe('AuthService test', () => { init(); TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({ authReducer }) + StoreModule.forRoot({ authReducer }, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }) ], providers: [ { provide: AuthRequestService, useValue: authRequest }, @@ -226,7 +237,12 @@ describe('AuthService test', () => { init(); TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({ authReducer }) + StoreModule.forRoot({ authReducer }, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }) ], providers: [ { provide: AuthRequestService, useValue: authRequest }, diff --git a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts index 2a0005f548..92a50058db 100644 --- a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts +++ b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.spec.ts @@ -1,6 +1,6 @@ import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver'; import { Collection } from '../shared/collection.model'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { getTestScheduler } from 'jasmine-marbles'; import { CollectionBreadcrumbResolver } from './collection-breadcrumb.resolver'; diff --git a/src/app/core/breadcrumbs/dso-breadcrumbs.service.spec.ts b/src/app/core/breadcrumbs/dso-breadcrumbs.service.spec.ts index 101545cb14..5c31e40362 100644 --- a/src/app/core/breadcrumbs/dso-breadcrumbs.service.spec.ts +++ b/src/app/core/breadcrumbs/dso-breadcrumbs.service.spec.ts @@ -1,9 +1,9 @@ import { async, TestBed } from '@angular/core/testing'; import { DSOBreadcrumbsService } from './dso-breadcrumbs.service'; -import { getMockLinkService } from '../../shared/mocks/mock-link-service'; +import { getMockLinkService } from '../../shared/mocks/link-service.mock'; import { LinkService } from '../cache/builders/link.service'; import { Item } from '../shared/item.model'; -import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { DSpaceObject } from '../shared/dspace-object.model'; import { of as observableOf } from 'rxjs'; import { Community } from '../shared/community.model'; diff --git a/src/app/core/browse/browse.service.spec.ts b/src/app/core/browse/browse.service.spec.ts index 6dafa4cf0a..58796636e2 100644 --- a/src/app/core/browse/browse.service.spec.ts +++ b/src/app/core/browse/browse.service.spec.ts @@ -1,9 +1,9 @@ import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { of as observableOf } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { BrowseEndpointRequest, BrowseEntriesRequest, BrowseItemsRequest } from '../data/request.models'; import { RequestEntry } from '../data/request.reducer'; diff --git a/src/app/core/cache/builders/build-decorators.ts b/src/app/core/cache/builders/build-decorators.ts index 4ba04bfa55..06a955cb00 100644 --- a/src/app/core/cache/builders/build-decorators.ts +++ b/src/app/core/cache/builders/build-decorators.ts @@ -1,6 +1,4 @@ -import 'reflect-metadata'; import { hasNoValue, hasValue } from '../../../shared/empty.util'; -import { DataService } from '../../data/data.service'; import { GenericConstructor } from '../../shared/generic-constructor'; import { HALResource } from '../../shared/hal-resource.model'; @@ -98,7 +96,7 @@ export const link = ( let targetMap = linkMap.get(target.constructor); if (hasNoValue(targetMap)) { - targetMap = new Map>(); + targetMap = new Map>(); } if (hasNoValue(linkName)) { diff --git a/src/app/core/cache/builders/link.service.spec.ts b/src/app/core/cache/builders/link.service.spec.ts index e9b8447c22..95a7570207 100644 --- a/src/app/core/cache/builders/link.service.spec.ts +++ b/src/app/core/cache/builders/link.service.spec.ts @@ -40,10 +40,10 @@ class TestModel implements HALResource { @Injectable() class TestDataService { findAllByHref(href: string, findListOptions: FindListOptions = {}, ...linksToFollow: Array>) { - return 'findAllByHref' + return 'findAllByHref'; } findByHref(href: string, ...linksToFollow: Array>) { - return 'findByHref' + return 'findByHref'; } } @@ -169,7 +169,7 @@ describe('LinkService', () => { describe('resolveLinks', () => { beforeEach(() => { spyOn(service, 'resolveLink'); - service.resolveLinks(testModel, followLink('predecessor'), followLink('successor')) + result = service.resolveLinks(testModel, followLink('predecessor'), followLink('successor')) }); it('should call resolveLink with the model for each of the provided links', () => { diff --git a/src/app/core/cache/builders/remote-data-build.service.spec.ts b/src/app/core/cache/builders/remote-data-build.service.spec.ts index 85267d7f4c..8bf689d794 100644 --- a/src/app/core/cache/builders/remote-data-build.service.spec.ts +++ b/src/app/core/cache/builders/remote-data-build.service.spec.ts @@ -1,5 +1,5 @@ import { of as observableOf } from 'rxjs'; -import { createSuccessfulRemoteDataObject } from '../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils'; import { PaginatedList } from '../../data/paginated-list'; import { RemoteData } from '../../data/remote-data'; import { Item } from '../../shared/item.model'; diff --git a/src/app/core/cache/builders/remote-data-build.service.ts b/src/app/core/cache/builders/remote-data-build.service.ts index df895e11a2..88d1890de2 100644 --- a/src/app/core/cache/builders/remote-data-build.service.ts +++ b/src/app/core/cache/builders/remote-data-build.service.ts @@ -8,7 +8,7 @@ import { isNotEmpty, isNotUndefined } from '../../../shared/empty.util'; -import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils'; import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model'; import { PaginatedList } from '../../data/paginated-list'; import { RemoteData } from '../../data/remote-data'; diff --git a/src/app/core/cache/server-sync-buffer.effects.spec.ts b/src/app/core/cache/server-sync-buffer.effects.spec.ts index c2aa7b14f9..245b6f67d8 100644 --- a/src/app/core/cache/server-sync-buffer.effects.spec.ts +++ b/src/app/core/cache/server-sync-buffer.effects.spec.ts @@ -5,10 +5,9 @@ import { cold, hot } from 'jasmine-marbles'; import { Observable, of as observableOf } from 'rxjs'; import * as operators from 'rxjs/operators'; -import { GLOBAL_CONFIG } from '../../../config'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { MockStore } from '../../shared/testing/mock-store'; -import { spyOnOperator } from '../../shared/testing/utils'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { StoreMock } from '../../shared/testing/store.mock'; +import { spyOnOperator } from '../../shared/testing/utils.test'; import { RequestService } from '../data/request.service'; import { RestRequestMethod } from '../data/rest-request-method'; import { DSpaceObject } from '../shared/dspace-object.model'; @@ -17,6 +16,7 @@ import { ObjectCacheService } from './object-cache.service'; import { CommitSSBAction, EmptySSBAction, ServerSyncBufferActionTypes } from './server-sync-buffer.actions'; import { ServerSyncBufferEffects } from './server-sync-buffer.effects'; +import { storeModuleConfig } from '../../app.reducer'; describe('ServerSyncBufferEffects', () => { let ssbEffects: ServerSyncBufferEffects; @@ -37,12 +37,11 @@ describe('ServerSyncBufferEffects', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), ], providers: [ ServerSyncBufferEffects, provideMockActions(() => actions), - { provide: GLOBAL_CONFIG, useValue: testConfig }, { provide: RequestService, useValue: getMockRequestService() }, { provide: ObjectCacheService, useValue: { @@ -62,7 +61,7 @@ describe('ServerSyncBufferEffects', () => { } } }, - { provide: Store, useClass: MockStore } + { provide: Store, useClass: StoreMock } // other providers ], }); diff --git a/src/app/core/cache/server-sync-buffer.effects.ts b/src/app/core/cache/server-sync-buffer.effects.ts index 84f0312385..7d57bb4433 100644 --- a/src/app/core/cache/server-sync-buffer.effects.ts +++ b/src/app/core/cache/server-sync-buffer.effects.ts @@ -1,15 +1,8 @@ import { delay, exhaustMap, map, switchMap, take } from 'rxjs/operators'; -import { Inject, Injectable } from '@angular/core'; +import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { coreSelector } from '../core.selectors'; -import { - AddToSSBAction, - CommitSSBAction, - EmptySSBAction, - ServerSyncBufferActionTypes -} from './server-sync-buffer.actions'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; +import { AddToSSBAction, CommitSSBAction, EmptySSBAction, ServerSyncBufferActionTypes } from './server-sync-buffer.actions'; import { CoreState } from '../core.reducers'; import { Action, createSelector, MemoizedSelector, select, Store } from '@ngrx/store'; import { ServerSyncBufferEntry, ServerSyncBufferState } from './server-sync-buffer.reducer'; @@ -21,6 +14,7 @@ import { ApplyPatchObjectCacheAction } from './object-cache.actions'; import { hasValue, isNotEmpty, isNotUndefined } from '../../shared/empty.util'; import { Observable } from 'rxjs/internal/Observable'; import { RestRequestMethod } from '../data/rest-request-method'; +import { environment } from '../../../environments/environment'; import { ObjectCacheEntry } from './object-cache.reducer'; import { Operation } from 'fast-json-patch'; @@ -37,7 +31,7 @@ export class ServerSyncBufferEffects { .pipe( ofType(ServerSyncBufferActionTypes.ADD), exhaustMap((action: AddToSSBAction) => { - const autoSyncConfig = this.EnvConfig.cache.autoSync; + const autoSyncConfig = environment.cache.autoSync; const timeoutInSeconds = autoSyncConfig.timePerMethod[action.payload.method] || autoSyncConfig.defaultTime; return observableOf(new CommitSSBAction(action.payload.method)).pipe( delay(timeoutInSeconds * 1000), @@ -85,7 +79,7 @@ export class ServerSyncBufferEffects { return observableOf({ type: 'NO_ACTION' }); } }) - ) + ); }) ); @@ -114,8 +108,7 @@ export class ServerSyncBufferEffects { constructor(private actions$: Actions, private store: Store, private requestService: RequestService, - private objectCache: ObjectCacheService, - @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { + private objectCache: ObjectCacheService) { } } diff --git a/src/app/core/config/config-response-parsing.service.spec.ts b/src/app/core/config/config-response-parsing.service.spec.ts index 87a7057078..c0bc8b3212 100644 --- a/src/app/core/config/config-response-parsing.service.spec.ts +++ b/src/app/core/config/config-response-parsing.service.spec.ts @@ -1,5 +1,4 @@ import { Store } from '@ngrx/store'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ConfigSuccessResponse, ErrorResponse } from '../cache/response.models'; import { CoreState } from '../core.reducers'; @@ -13,12 +12,11 @@ import { SubmissionSectionModel } from './models/config-submission-section.model describe('ConfigResponseParsingService', () => { let service: ConfigResponseParsingService; - const EnvConfig = {} as GlobalConfig; const store = {} as Store; const objectCacheService = new ObjectCacheService(store, undefined); let validResponse; beforeEach(() => { - service = new ConfigResponseParsingService(EnvConfig, objectCacheService); + service = new ConfigResponseParsingService(objectCacheService); validResponse = { payload: { id: 'traditional', diff --git a/src/app/core/config/config-response-parsing.service.ts b/src/app/core/config/config-response-parsing.service.ts index d674445d54..a603de291a 100644 --- a/src/app/core/config/config-response-parsing.service.ts +++ b/src/app/core/config/config-response-parsing.service.ts @@ -8,8 +8,6 @@ import { isNotEmpty } from '../../shared/empty.util'; import { ConfigObject } from './models/config.model'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; @Injectable() @@ -18,7 +16,6 @@ export class ConfigResponseParsingService extends BaseResponseParsingService imp protected shouldDirectlyAttachEmbeds = true; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/config/config.service.spec.ts b/src/app/core/config/config.service.spec.ts index 402ee88b81..80febb711f 100644 --- a/src/app/core/config/config.service.spec.ts +++ b/src/app/core/config/config.service.spec.ts @@ -1,11 +1,11 @@ import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { ConfigService } from './config.service'; import { RequestService } from '../data/request.service'; import { ConfigRequest, FindListOptions } from '../data/request.models'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; const LINK_NAME = 'test'; const BROWSE = 'search/findByCollection'; diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 783b169291..356dad5ed8 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -4,10 +4,10 @@ import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core import { DynamicFormLayoutService, DynamicFormService, DynamicFormValidationService } from '@ng-dynamic-forms/core'; import { EffectsModule } from '@ngrx/effects'; -import { StoreModule } from '@ngrx/store'; +import { Action, StoreConfig, StoreModule } from '@ngrx/store'; import { MyDSpaceGuard } from '../+my-dspace-page/my-dspace.guard'; -import { ENV_CONFIG, GLOBAL_CONFIG, GlobalConfig } from '../../config'; + import { isNotEmpty } from '../shared/empty.util'; import { FormBuilderService } from '../shared/form/builder/form-builder.service'; import { FormService } from '../shared/form/form.service'; @@ -16,9 +16,9 @@ import { MenuService } from '../shared/menu/menu.service'; import { EndpointMockingRestService } from '../shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service'; import { MOCK_RESPONSE_MAP, - MockResponseMap, + ResponseMapMock, mockResponseMap -} from '../shared/mocks/dspace-rest-v2/mocks/mock-response-map'; +} from '../shared/mocks/dspace-rest-v2/mocks/response-map.mock'; import { NotificationsService } from '../shared/notifications/notifications.service'; import { SelectableListService } from '../shared/object-list/selectable-list/selectable-list.service'; import { ObjectSelectService } from '../shared/object-select/object-select.service'; @@ -44,7 +44,7 @@ import { SubmissionDefinitionsConfigService } from './config/submission-definiti import { SubmissionFormsConfigService } from './config/submission-forms-config.service'; import { SubmissionSectionsConfigService } from './config/submission-sections-config.service'; import { coreEffects } from './core.effects'; -import { coreReducers } from './core.reducers'; +import { coreReducers, CoreState } from './core.reducers'; import { BitstreamFormatDataService } from './data/bitstream-format-data.service'; import { BrowseEntriesResponseParsingService } from './data/browse-entries-response-parsing.service'; import { BrowseItemsResponseParsingService } from './data/browse-items-response-parsing-service'; @@ -137,6 +137,8 @@ import { PoolTaskDataService } from './tasks/pool-task-data.service'; import { TaskResponseParsingService } from './tasks/task-response-parsing.service'; import { ArrayMoveChangeAnalyzer } from './data/array-move-change-analyzer.service'; import { BitstreamDataService } from './data/bitstream-data.service'; +import { environment } from '../../environments/environment'; +import { storeModuleConfig } from '../app.reducer'; import { VersionDataService } from './data/version-data.service'; import { VersionHistoryDataService } from './data/version-history-data.service'; import { Version } from './shared/version.model'; @@ -148,17 +150,17 @@ import { WorkflowAction } from './tasks/models/workflow-action-object.model'; * When not in production, endpoint responses can be mocked for testing purposes * If there is no mock version available for the endpoint, the actual REST response will be used just like in production mode */ -export const restServiceFactory = (cfg: GlobalConfig, mocks: MockResponseMap, http: HttpClient) => { - if (ENV_CONFIG.production) { +export const restServiceFactory = (mocks: ResponseMapMock, http: HttpClient) => { + if (environment.production) { return new DSpaceRESTv2Service(http); } else { - return new EndpointMockingRestService(cfg, mocks, http); + return new EndpointMockingRestService(mocks, http); } }; const IMPORTS = [ CommonModule, - StoreModule.forFeature('core', coreReducers, {}), + StoreModule.forFeature('core', coreReducers, storeModuleConfig as StoreConfig), EffectsModule.forFeature(coreEffects) ]; @@ -176,11 +178,7 @@ const PROVIDERS = [ SiteDataService, DSOResponseParsingService, { provide: MOCK_RESPONSE_MAP, useValue: mockResponseMap }, - { - provide: DSpaceRESTv2Service, - useFactory: restServiceFactory, - deps: [GLOBAL_CONFIG, MOCK_RESPONSE_MAP, HttpClient] - }, + { provide: DSpaceRESTv2Service, useFactory: restServiceFactory, deps: [MOCK_RESPONSE_MAP, HttpClient]}, DynamicFormLayoutService, DynamicFormService, DynamicFormValidationService, diff --git a/src/app/core/data/base-response-parsing.service.spec.ts b/src/app/core/data/base-response-parsing.service.spec.ts index a1d602dc65..85f531e0ea 100644 --- a/src/app/core/data/base-response-parsing.service.spec.ts +++ b/src/app/core/data/base-response-parsing.service.spec.ts @@ -1,5 +1,4 @@ import { BaseResponseParsingService } from './base-response-parsing.service'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { CacheableObject } from '../cache/object-cache.reducer'; import { GetRequest, RestRequest } from './request.models'; @@ -9,8 +8,7 @@ import { DSpaceObject } from '../shared/dspace-object.model'; class TestService extends BaseResponseParsingService { toCache = true; - constructor(protected EnvConfig: GlobalConfig, - protected objectCache: ObjectCacheService) { + constructor(protected objectCache: ObjectCacheService) { super(); } @@ -26,24 +24,22 @@ class TestService extends BaseResponseParsingService { describe('BaseResponseParsingService', () => { let service: TestService; - let config: GlobalConfig; let objectCache: ObjectCacheService; const requestUUID = 'request-uuid'; const requestHref = 'request-href'; const request = new GetRequest(requestUUID, requestHref); + let obj: CacheableObject; beforeEach(() => { - config = Object.assign({}); + obj = undefined; objectCache = jasmine.createSpyObj('objectCache', { add: {} }); - service = new TestService(config, objectCache); + service = new TestService(objectCache); }); describe('cache', () => { - let obj: CacheableObject; - describe('when the object is undefined', () => { it('should not throw an error', () => { expect(() => { service.cache(obj, request, {}) }).not.toThrow(); diff --git a/src/app/core/data/base-response-parsing.service.ts b/src/app/core/data/base-response-parsing.service.ts index efbe838d82..d69ebfbed5 100644 --- a/src/app/core/data/base-response-parsing.service.ts +++ b/src/app/core/data/base-response-parsing.service.ts @@ -4,11 +4,11 @@ import { CacheableObject } from '../cache/object-cache.reducer'; import { Serializer } from '../serializer'; import { PageInfo } from '../shared/page-info.model'; import { ObjectCacheService } from '../cache/object-cache.service'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { GenericConstructor } from '../shared/generic-constructor'; import { PaginatedList } from './paginated-list'; import { getClassForType } from '../cache/builders/build-decorators'; import { RestRequest } from './request.models'; +import { environment } from '../../../environments/environment'; /* tslint:disable:max-classes-per-file */ /** @@ -35,7 +35,6 @@ export function isRestPaginatedList(halObj: any): boolean { } export abstract class BaseResponseParsingService { - protected abstract EnvConfig: GlobalConfig; protected abstract objectCache: ObjectCacheService; protected abstract toCache: boolean; protected shouldDirectlyAttachEmbeds = false; @@ -147,7 +146,7 @@ export abstract class BaseResponseParsingService { console.warn(`Can't cache incomplete ${type}: ${JSON.stringify(co)}, parsed from (partial) response: ${dataJSON}`); return; } - this.objectCache.add(co, hasValue(request.responseMsToLive) ? request.responseMsToLive : this.EnvConfig.cache.msToLive.default, request.uuid); + this.objectCache.add(co, hasValue(request.responseMsToLive) ? request.responseMsToLive : environment.cache.msToLive.default, request.uuid); } processPageInfo(payload: any): PageInfo { @@ -157,7 +156,7 @@ export abstract class BaseResponseParsingService { if (pageInfoObject.currentPage >= 0) { Object.assign(pageInfoObject, { currentPage: pageInfoObject.currentPage + 1 }); } - return pageInfoObject + return pageInfoObject; } else { return undefined; } diff --git a/src/app/core/data/bitstream-data.service.spec.ts b/src/app/core/data/bitstream-data.service.spec.ts index fca0f6b650..b328141d7b 100644 --- a/src/app/core/data/bitstream-data.service.spec.ts +++ b/src/app/core/data/bitstream-data.service.spec.ts @@ -2,14 +2,14 @@ import { BitstreamDataService } from './bitstream-data.service'; import { ObjectCacheService } from '../cache/object-cache.service'; import { RequestService } from './request.service'; import { Bitstream } from '../shared/bitstream.model'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; import { HALEndpointService } from '../shared/hal-endpoint.service'; import { BitstreamFormatDataService } from './bitstream-format-data.service'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { BitstreamFormat } from '../shared/bitstream-format.model'; import { BitstreamFormatSupportLevel } from '../shared/bitstream-format-support-level'; import { PutRequest } from './request.models'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; describe('BitstreamDataService', () => { let service: BitstreamDataService; diff --git a/src/app/core/data/browse-entries-response-parsing.service.spec.ts b/src/app/core/data/browse-entries-response-parsing.service.spec.ts index ef9a833765..3c7319d5cf 100644 --- a/src/app/core/data/browse-entries-response-parsing.service.spec.ts +++ b/src/app/core/data/browse-entries-response-parsing.service.spec.ts @@ -1,4 +1,4 @@ -import { getMockObjectCacheService } from '../../shared/mocks/mock-object-cache.service'; +import { getMockObjectCacheService } from '../../shared/mocks/object-cache.service.mock'; import { ErrorResponse, GenericSuccessResponse } from '../cache/response.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { BrowseEntriesResponseParsingService } from './browse-entries-response-parsing.service'; @@ -8,7 +8,7 @@ describe('BrowseEntriesResponseParsingService', () => { let service: BrowseEntriesResponseParsingService; beforeEach(() => { - service = new BrowseEntriesResponseParsingService(undefined, getMockObjectCacheService()); + service = new BrowseEntriesResponseParsingService(getMockObjectCacheService()); }); describe('parse', () => { diff --git a/src/app/core/data/browse-entries-response-parsing.service.ts b/src/app/core/data/browse-entries-response-parsing.service.ts index ec35b8cc75..98385f0237 100644 --- a/src/app/core/data/browse-entries-response-parsing.service.ts +++ b/src/app/core/data/browse-entries-response-parsing.service.ts @@ -1,6 +1,4 @@ import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { isNotEmpty } from '../../shared/empty.util'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ErrorResponse, GenericSuccessResponse, RestResponse } from '../cache/response.models'; @@ -17,7 +15,6 @@ export class BrowseEntriesResponseParsingService extends BaseResponseParsingServ protected toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/browse-items-response-parsing-service.spec.ts b/src/app/core/data/browse-items-response-parsing-service.spec.ts index 50b3be5de7..a1b1a14bff 100644 --- a/src/app/core/data/browse-items-response-parsing-service.spec.ts +++ b/src/app/core/data/browse-items-response-parsing-service.spec.ts @@ -1,4 +1,4 @@ -import { getMockObjectCacheService } from '../../shared/mocks/mock-object-cache.service'; +import { getMockObjectCacheService } from '../../shared/mocks/object-cache.service.mock'; import { ErrorResponse, GenericSuccessResponse } from '../cache/response.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { BrowseEntriesResponseParsingService } from './browse-entries-response-parsing.service'; @@ -9,7 +9,7 @@ describe('BrowseItemsResponseParsingService', () => { let service: BrowseItemsResponseParsingService; beforeEach(() => { - service = new BrowseItemsResponseParsingService(undefined, getMockObjectCacheService()); + service = new BrowseItemsResponseParsingService(getMockObjectCacheService()); }); describe('parse', () => { diff --git a/src/app/core/data/browse-items-response-parsing-service.ts b/src/app/core/data/browse-items-response-parsing-service.ts index 08ade5772d..2b7ec647c9 100644 --- a/src/app/core/data/browse-items-response-parsing-service.ts +++ b/src/app/core/data/browse-items-response-parsing-service.ts @@ -1,7 +1,5 @@ import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ErrorResponse, GenericSuccessResponse, RestResponse } from '../cache/response.models'; @@ -20,7 +18,6 @@ export class BrowseItemsResponseParsingService extends BaseResponseParsingServic protected toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/collection-data.service.spec.ts b/src/app/core/data/collection-data.service.spec.ts index 96141d6a8a..eb3dabf195 100644 --- a/src/app/core/data/collection-data.service.spec.ts +++ b/src/app/core/data/collection-data.service.spec.ts @@ -1,10 +1,10 @@ import { CollectionDataService } from './collection-data.service'; import { RequestService } from './request.service'; import { TranslateService } from '@ngx-translate/core'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub'; -import { getMockTranslateService } from '../../shared/mocks/mock-translate.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; +import { getMockTranslateService } from '../../shared/mocks/translate.service.mock'; import { fakeAsync, tick } from '@angular/core/testing'; import { ContentSourceRequest, GetRequest, RequestError, UpdateContentSourceRequest } from './request.models'; import { ContentSource } from '../shared/content-source.model'; diff --git a/src/app/core/data/comcol-data.service.spec.ts b/src/app/core/data/comcol-data.service.spec.ts index fc487527b9..1ba19df18c 100644 --- a/src/app/core/data/comcol-data.service.spec.ts +++ b/src/app/core/data/comcol-data.service.spec.ts @@ -3,8 +3,7 @@ import { Store } from '@ngrx/store'; import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { Observable, of as observableOf } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { GlobalConfig } from '../../../config'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { ObjectCacheService } from '../cache/object-cache.service'; @@ -27,7 +26,6 @@ class TestService extends ComColDataService { protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected store: Store, - protected EnvConfig: GlobalConfig, protected cds: CommunityDataService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, @@ -55,7 +53,6 @@ describe('ComColDataService', () => { const rdbService = {} as RemoteDataBuildService; const store = {} as Store; - const EnvConfig = {} as GlobalConfig; const notificationsService = {} as NotificationsService; const http = {} as HttpClient; const comparator = {} as any; @@ -67,7 +64,7 @@ describe('ComColDataService', () => { const getRequestEntry$ = (successful: boolean) => { return observableOf({ response: { isSuccessful: successful } as any - } as RequestEntry) + } as RequestEntry); }; const communitiesEndpoint = 'https://rest.api/core/communities'; @@ -106,7 +103,6 @@ describe('ComColDataService', () => { requestService, rdbService, store, - EnvConfig, cds, objectCache, halService, diff --git a/src/app/core/data/data.service.spec.ts b/src/app/core/data/data.service.spec.ts index f776dfea63..a99fc54269 100644 --- a/src/app/core/data/data.service.spec.ts +++ b/src/app/core/data/data.service.spec.ts @@ -3,22 +3,21 @@ import { Store } from '@ngrx/store'; import { compare, Operation } from 'fast-json-patch'; import { Observable, of as observableOf } from 'rxjs'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; -import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; +import { followLink } from '../../shared/utils/follow-link-config.model'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { SortDirection, SortOptions } from '../cache/models/sort-options.model'; import { ObjectCacheService } from '../cache/object-cache.service'; import { CoreState } from '../core.reducers'; -import { Collection } from '../shared/collection.model'; import { DSpaceObject } from '../shared/dspace-object.model'; import { HALEndpointService } from '../shared/hal-endpoint.service'; import { Item } from '../shared/item.model'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { ChangeAnalyzer } from './change-analyzer'; import { DataService } from './data.service'; import { FindListOptions, PatchRequest } from './request.models'; import { RequestService } from './request.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; const endpoint = 'https://rest.api/core'; @@ -54,23 +53,32 @@ class DummyChangeAnalyzer implements ChangeAnalyzer { describe('DataService', () => { let service: TestService; let options: FindListOptions; - const requestService = getMockRequestService(); - const halService = new HALEndpointServiceStub('url') as any; - const rdbService = {} as RemoteDataBuildService; - const notificationsService = {} as NotificationsService; - const http = {} as HttpClient; - const comparator = new DummyChangeAnalyzer() as any; - const objectCache = { - addPatch: () => { - /* empty */ - }, - getObjectBySelfLink: () => { - /* empty */ - } - } as any; - const store = {} as Store; + let requestService; + let halService; + let rdbService; + let notificationsService; + let http; + let comparator; + let objectCache; + let store; function initTestService(): TestService { + requestService = getMockRequestService(); + halService = new HALEndpointServiceStub('url') as any; + rdbService = {} as RemoteDataBuildService; + notificationsService = {} as NotificationsService; + http = {} as HttpClient; + comparator = new DummyChangeAnalyzer() as any; + objectCache = { + + addPatch: () => { + /* empty */ + }, + getObjectBySelfLink: () => { + /* empty */ + } + } as any; + store = {} as Store; return new TestService( requestService, rdbService, @@ -84,7 +92,9 @@ describe('DataService', () => { ); } - service = initTestService(); + beforeEach(() => { + service = initTestService(); + }) describe('getFindAllHref', () => { @@ -151,67 +161,33 @@ describe('DataService', () => { }); it('should include single linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); const expected = `${endpoint}?embed=bundles`; - (service as any).getFindAllHref({}, null, mockFollowLinkConfig).subscribe((value) => { + (service as any).getFindAllHref({}, null, followLink('bundles')).subscribe((value) => { expect(value).toBe(expected); }); }); it('should include multiple linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${endpoint}?embed=bundles&embed=owningCollection&embed=templateItemOf`; - (service as any).getFindAllHref({}, null, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3).subscribe((value) => { + (service as any).getFindAllHref({}, null, followLink('bundles'), followLink('owningCollection'), followLink('templateItemOf')).subscribe((value) => { expect(value).toBe(expected); }); }); it('should not include linksToFollow with shouldEmbed = false', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${endpoint}?embed=templateItemOf`; - (service as any).getFindAllHref({}, null, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3).subscribe((value) => { + (service as any).getFindAllHref({}, null, followLink('bundles', undefined, false), followLink('owningCollection', undefined, false), followLink('templateItemOf')).subscribe((value) => { expect(value).toBe(expected); }); }); it('should include nested linksToFollow 3lvl', () => { - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'relationships' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'itemtemplate' as any, - linksToFollow: mockFollowLinkConfig3, - }); - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - linksToFollow: mockFollowLinkConfig2, - }); const expected = `${endpoint}?embed=owningCollection/itemtemplate/relationships`; - (service as any).getFindAllHref({}, null, mockFollowLinkConfig).subscribe((value) => { + (service as any).getFindAllHref({}, null, followLink('owningCollection', undefined, true, followLink('itemtemplate', undefined, true, followLink('relationships')))).subscribe((value) => { expect(value).toBe(expected); }); }); @@ -227,60 +203,26 @@ describe('DataService', () => { }); it('should include single linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); const expected = `${endpointMock}/${resourceIdMock}?embed=bundles`; - const result = (service as any).getIDHref(endpointMock, resourceIdMock, mockFollowLinkConfig); + const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('bundles')); expect(result).toEqual(expected); }); it('should include multiple linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${endpointMock}/${resourceIdMock}?embed=bundles&embed=owningCollection&embed=templateItemOf`; - const result = (service as any).getIDHref(endpointMock, resourceIdMock, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3); + const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('bundles'), followLink('owningCollection'), followLink('templateItemOf')); expect(result).toEqual(expected); }); it('should not include linksToFollow with shouldEmbed = false', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${endpointMock}/${resourceIdMock}?embed=templateItemOf`; - const result = (service as any).getIDHref(endpointMock, resourceIdMock, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3); + const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('bundles', undefined, false), followLink('owningCollection', undefined, false), followLink('templateItemOf')); expect(result).toEqual(expected); }); it('should include nested linksToFollow 3lvl', () => { - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'relationships' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'itemtemplate' as any, - linksToFollow: mockFollowLinkConfig3, - }); - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - linksToFollow: mockFollowLinkConfig2, - }); const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection/itemtemplate/relationships`; - const result = (service as any).getIDHref(endpointMock, resourceIdMock, mockFollowLinkConfig); + const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('owningCollection', undefined, true, followLink('itemtemplate', undefined, true, followLink('relationships')))); expect(result).toEqual(expected); }); }); diff --git a/src/app/core/data/dso-redirect-data.service.spec.ts b/src/app/core/data/dso-redirect-data.service.spec.ts index 4ef5bcb8b4..ca62347883 100644 --- a/src/app/core/data/dso-redirect-data.service.spec.ts +++ b/src/app/core/data/dso-redirect-data.service.spec.ts @@ -3,13 +3,11 @@ import { Store } from '@ngrx/store'; import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; +import { followLink } from '../../shared/utils/follow-link-config.model'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { ObjectCacheService } from '../cache/object-cache.service'; import { CoreState } from '../core.reducers'; -import { Collection } from '../shared/collection.model'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { Item } from '../shared/item.model'; import { DsoRedirectDataService } from './dso-redirect-data.service'; import { FindByIDRequest, IdentifierType } from './request.models'; import { RequestService } from './request.service'; @@ -34,12 +32,12 @@ describe('DsoRedirectDataService', () => { const http = {} as HttpClient; const comparator = {} as any; const objectCache = {} as ObjectCacheService; - let setup; + beforeEach(() => { scheduler = getTestScheduler(); halService = jasmine.createSpyObj('halService', { - getEndpoint: cold('a', {a: pidLink}) + getEndpoint: cold('a', { a: pidLink }) }); requestService = jasmine.createSpyObj('requestService', { generateRequestId: requestUUID, @@ -60,29 +58,26 @@ describe('DsoRedirectDataService', () => { } }; - setup = () => { - rdbService = jasmine.createSpyObj('rdbService', { - buildSingle: cold('a', { - a: remoteData - }) - }); - service = new DsoRedirectDataService( - requestService, - rdbService, - store, - objectCache, - halService, - notificationsService, - http, - comparator, - router - ); - } + rdbService = jasmine.createSpyObj('rdbService', { + buildSingle: cold('a', { + a: remoteData + }) + }); + service = new DsoRedirectDataService( + requestService, + rdbService, + store, + objectCache, + halService, + notificationsService, + http, + comparator, + router + ); }); describe('findById', () => { it('should call HALEndpointService with the path to the pid endpoint', () => { - setup(); scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE)); scheduler.flush(); @@ -90,7 +85,6 @@ describe('DsoRedirectDataService', () => { }); it('should call HALEndpointService with the path to the dso endpoint', () => { - setup(); scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID)); scheduler.flush(); @@ -98,7 +92,6 @@ describe('DsoRedirectDataService', () => { }); it('should call HALEndpointService with the path to the dso endpoint when identifier type not specified', () => { - setup(); scheduler.schedule(() => service.findByIdAndIDType(dsoUUID)); scheduler.flush(); @@ -106,7 +99,6 @@ describe('DsoRedirectDataService', () => { }); it('should configure the proper FindByIDRequest for uuid', () => { - setup(); scheduler.schedule(() => service.findByIdAndIDType(dsoUUID, IdentifierType.UUID)); scheduler.flush(); @@ -114,7 +106,6 @@ describe('DsoRedirectDataService', () => { }); it('should configure the proper FindByIDRequest for handle', () => { - setup(); scheduler.schedule(() => service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE)); scheduler.flush(); @@ -123,7 +114,6 @@ describe('DsoRedirectDataService', () => { it('should navigate to item route', () => { remoteData.payload.type = 'item'; - setup(); const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE); // The framework would normally subscribe but do it here so we can test navigation. redir.subscribe(); @@ -134,7 +124,6 @@ describe('DsoRedirectDataService', () => { it('should navigate to collections route', () => { remoteData.payload.type = 'collection'; - setup(); const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE); redir.subscribe(); scheduler.schedule(() => redir); @@ -144,7 +133,6 @@ describe('DsoRedirectDataService', () => { it('should navigate to communities route', () => { remoteData.payload.type = 'community'; - setup(); const redir = service.findByIdAndIDType(dsoHandle, IdentifierType.HANDLE); redir.subscribe(); scheduler.schedule(() => redir); @@ -160,60 +148,26 @@ describe('DsoRedirectDataService', () => { }); it('should include single linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); const expected = `${requestUUIDURL}&embed=bundles`; - const result = (service as any).getIDHref(pidLink, dsoUUID, mockFollowLinkConfig); + const result = (service as any).getIDHref(pidLink, dsoUUID, followLink('bundles')); expect(result).toEqual(expected); }); it('should include multiple linksToFollow as embed', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${requestUUIDURL}&embed=bundles&embed=owningCollection&embed=templateItemOf`; - const result = (service as any).getIDHref(pidLink, dsoUUID, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3); + const result = (service as any).getIDHref(pidLink, dsoUUID, followLink('bundles'), followLink('owningCollection'), followLink('templateItemOf')); expect(result).toEqual(expected); }); it('should not include linksToFollow with shouldEmbed = false', () => { - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'bundles' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - shouldEmbed: false, - }); - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'templateItemOf' as any, - }); const expected = `${requestUUIDURL}&embed=templateItemOf`; - const result = (service as any).getIDHref(pidLink, dsoUUID, mockFollowLinkConfig, mockFollowLinkConfig2, mockFollowLinkConfig3); + const result = (service as any).getIDHref(pidLink, dsoUUID, followLink('bundles', undefined, false), followLink('owningCollection', undefined, false), followLink('templateItemOf')); expect(result).toEqual(expected); }); it('should include nested linksToFollow 3lvl', () => { - const mockFollowLinkConfig3: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'relationships' as any, - }); - const mockFollowLinkConfig2: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'itemtemplate' as any, - linksToFollow: mockFollowLinkConfig3, - }); - const mockFollowLinkConfig: FollowLinkConfig = Object.assign(new FollowLinkConfig(), { - name: 'owningCollection' as any, - linksToFollow: mockFollowLinkConfig2, - }); const expected = `${requestUUIDURL}&embed=owningCollection/itemtemplate/relationships`; - const result = (service as any).getIDHref(pidLink, dsoUUID, mockFollowLinkConfig); + const result = (service as any).getIDHref(pidLink, dsoUUID, followLink('owningCollection', undefined, true, followLink('itemtemplate', undefined, true, followLink('relationships')))); expect(result).toEqual(expected); }); }); diff --git a/src/app/core/data/dso-response-parsing.service.ts b/src/app/core/data/dso-response-parsing.service.ts index 83676ce105..a4d4941bc8 100644 --- a/src/app/core/data/dso-response-parsing.service.ts +++ b/src/app/core/data/dso-response-parsing.service.ts @@ -1,8 +1,6 @@ import { Inject, Injectable } from '@angular/core'; import { ObjectCacheService } from '../cache/object-cache.service'; -import { GlobalConfig } from '../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../config'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { RestResponse, DSOSuccessResponse } from '../cache/response.models'; import { RestRequest } from './request.models'; @@ -17,7 +15,6 @@ export class DSOResponseParsingService extends BaseResponseParsingService implem protected toCache = true; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); diff --git a/src/app/core/data/endpoint-map-response-parsing.service.ts b/src/app/core/data/endpoint-map-response-parsing.service.ts index 080c665ccf..5516e83c07 100644 --- a/src/app/core/data/endpoint-map-response-parsing.service.ts +++ b/src/app/core/data/endpoint-map-response-parsing.service.ts @@ -1,6 +1,4 @@ import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ErrorResponse, RestResponse, EndpointMapSuccessResponse } from '../cache/response.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { ResponseParsingService } from './parsing.service'; @@ -9,10 +7,6 @@ import { isNotEmpty } from '../../shared/empty.util'; @Injectable() export class EndpointMapResponseParsingService implements ResponseParsingService { - constructor( - @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig, - ) { - } parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) { diff --git a/src/app/core/data/external-source.service.spec.ts b/src/app/core/data/external-source.service.spec.ts index f891b46883..7c7d676bc7 100644 --- a/src/app/core/data/external-source.service.spec.ts +++ b/src/app/core/data/external-source.service.spec.ts @@ -1,5 +1,6 @@ import { ExternalSourceService } from './external-source.service'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { createPaginatedList } from '../../shared/testing/utils.test'; import { ExternalSourceEntry } from '../shared/external-source-entry.model'; import { of as observableOf } from 'rxjs'; import { GetRequest } from './request.models'; diff --git a/src/app/core/data/facet-config-response-parsing.service.ts b/src/app/core/data/facet-config-response-parsing.service.ts index 3fc14b6495..0a552365f6 100644 --- a/src/app/core/data/facet-config-response-parsing.service.ts +++ b/src/app/core/data/facet-config-response-parsing.service.ts @@ -1,6 +1,4 @@ -import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; +import { Injectable } from '@angular/core'; import { SearchFilterConfig } from '../../shared/search/search-filter-config.model'; import { ObjectCacheService } from '../cache/object-cache.service'; import { FacetConfigSuccessResponse, RestResponse } from '../cache/response.models'; @@ -14,7 +12,6 @@ import { RestRequest } from './request.models'; export class FacetConfigResponseParsingService extends BaseResponseParsingService implements ResponseParsingService { toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/facet-value-map-response-parsing.service.ts b/src/app/core/data/facet-value-map-response-parsing.service.ts index 8c8c12dff7..7845e44e57 100644 --- a/src/app/core/data/facet-value-map-response-parsing.service.ts +++ b/src/app/core/data/facet-value-map-response-parsing.service.ts @@ -1,14 +1,7 @@ -import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; +import { Injectable } from '@angular/core'; import { FacetValue } from '../../shared/search/facet-value.model'; import { ObjectCacheService } from '../cache/object-cache.service'; -import { - FacetValueMap, - FacetValueMapSuccessResponse, - FacetValueSuccessResponse, - RestResponse -} from '../cache/response.models'; +import { FacetValueMap, FacetValueMapSuccessResponse, FacetValueSuccessResponse, RestResponse } from '../cache/response.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { DSpaceSerializer } from '../dspace-rest-v2/dspace.serializer'; import { BaseResponseParsingService } from './base-response-parsing.service'; @@ -20,7 +13,6 @@ export class FacetValueMapResponseParsingService extends BaseResponseParsingServ toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/facet-value-response-parsing.service.ts b/src/app/core/data/facet-value-response-parsing.service.ts index c9ff93a1ae..b56bedd1bb 100644 --- a/src/app/core/data/facet-value-response-parsing.service.ts +++ b/src/app/core/data/facet-value-response-parsing.service.ts @@ -1,6 +1,4 @@ import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { FacetValue } from '../../shared/search/facet-value.model'; import { ObjectCacheService } from '../cache/object-cache.service'; import { FacetValueSuccessResponse, RestResponse } from '../cache/response.models'; @@ -14,7 +12,6 @@ import { RestRequest } from './request.models'; export class FacetValueResponseParsingService extends BaseResponseParsingService implements ResponseParsingService { toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/filtered-discovery-page-response-parsing.service.spec.ts b/src/app/core/data/filtered-discovery-page-response-parsing.service.spec.ts index d81ce4b6bd..1934afba27 100644 --- a/src/app/core/data/filtered-discovery-page-response-parsing.service.spec.ts +++ b/src/app/core/data/filtered-discovery-page-response-parsing.service.spec.ts @@ -1,5 +1,5 @@ import { FilteredDiscoveryPageResponseParsingService } from './filtered-discovery-page-response-parsing.service'; -import { getMockObjectCacheService } from '../../shared/mocks/mock-object-cache.service'; +import { getMockObjectCacheService } from '../../shared/mocks/object-cache.service.mock'; import { GenericConstructor } from '../shared/generic-constructor'; import { ResponseParsingService } from './parsing.service'; import { GetRequest } from './request.models'; @@ -10,7 +10,7 @@ describe('FilteredDiscoveryPageResponseParsingService', () => { let service: FilteredDiscoveryPageResponseParsingService; beforeEach(() => { - service = new FilteredDiscoveryPageResponseParsingService(undefined, getMockObjectCacheService()); + service = new FilteredDiscoveryPageResponseParsingService(getMockObjectCacheService()); }); describe('parse', () => { diff --git a/src/app/core/data/filtered-discovery-page-response-parsing.service.ts b/src/app/core/data/filtered-discovery-page-response-parsing.service.ts index 166a915b16..02ce102ca6 100644 --- a/src/app/core/data/filtered-discovery-page-response-parsing.service.ts +++ b/src/app/core/data/filtered-discovery-page-response-parsing.service.ts @@ -4,8 +4,6 @@ import { RestRequest } from './request.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { BaseResponseParsingService } from './base-response-parsing.service'; import { ObjectCacheService } from '../cache/object-cache.service'; -import { GlobalConfig } from '../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../config'; import { FilteredDiscoveryQueryResponse, RestResponse } from '../cache/response.models'; /** @@ -17,7 +15,6 @@ export class FilteredDiscoveryPageResponseParsingService extends BaseResponsePar objectFactory = {}; toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); } diff --git a/src/app/core/data/item-data.service.spec.ts b/src/app/core/data/item-data.service.spec.ts index 2519c90973..282a43ec61 100644 --- a/src/app/core/data/item-data.service.spec.ts +++ b/src/app/core/data/item-data.service.spec.ts @@ -3,7 +3,7 @@ import { Store } from '@ngrx/store'; import { cold, getTestScheduler } from 'jasmine-marbles'; import { Observable, of as observableOf } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { BrowseService } from '../browse/browse.service'; import { ObjectCacheService } from '../cache/object-cache.service'; diff --git a/src/app/core/data/lookup-relation.service.spec.ts b/src/app/core/data/lookup-relation.service.spec.ts index c9fc7fc50d..ffeb6f9128 100644 --- a/src/app/core/data/lookup-relation.service.spec.ts +++ b/src/app/core/data/lookup-relation.service.spec.ts @@ -1,7 +1,8 @@ import { LookupRelationService } from './lookup-relation.service'; import { ExternalSourceService } from './external-source.service'; import { SearchService } from '../shared/search/search.service'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { createPaginatedList } from '../../shared/testing/utils.test'; import { PaginatedList } from './paginated-list'; import { PageInfo } from '../shared/page-info.model'; import { PaginatedSearchOptions } from '../../shared/search/paginated-search-options.model'; diff --git a/src/app/core/data/relationship-type.service.spec.ts b/src/app/core/data/relationship-type.service.spec.ts index 0a86b4bc61..751d28bf90 100644 --- a/src/app/core/data/relationship-type.service.spec.ts +++ b/src/app/core/data/relationship-type.service.spec.ts @@ -1,8 +1,8 @@ import { of as observableOf } from 'rxjs'; -import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ItemType } from '../shared/item-relationships/item-type.model'; import { RelationshipType } from '../shared/item-relationships/relationship-type.model'; diff --git a/src/app/core/data/relationship.service.spec.ts b/src/app/core/data/relationship.service.spec.ts index 247dce1619..c8ce2c5c45 100644 --- a/src/app/core/data/relationship.service.spec.ts +++ b/src/app/core/data/relationship.service.spec.ts @@ -1,10 +1,11 @@ import { Observable } from 'rxjs/internal/Observable'; import { of as observableOf } from 'rxjs/internal/observable/of'; import * as ItemRelationshipsUtils from '../../+item-page/simple/item-types/shared/item-relationships-utils'; -import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/mock-remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { createSuccessfulRemoteDataObject$, spyOnOperator } from '../../shared/testing/utils'; +import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { spyOnOperator } from '../../shared/testing/utils.test'; import { followLink } from '../../shared/utils/follow-link-config.model'; import { ObjectCacheService } from '../cache/object-cache.service'; import { RelationshipType } from '../shared/item-relationships/relationship-type.model'; diff --git a/src/app/core/data/request.effects.ts b/src/app/core/data/request.effects.ts index a9052aa8dc..7f793f4ac4 100644 --- a/src/app/core/data/request.effects.ts +++ b/src/app/core/data/request.effects.ts @@ -3,7 +3,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Observable, of as observableOf } from 'rxjs'; import { catchError, filter, flatMap, map, take } from 'rxjs/operators'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { StoreActionTypes } from '../../store.actions'; import { getClassForType } from '../cache/builders/build-decorators'; @@ -22,11 +21,11 @@ import { RequestError, RestRequest } from './request.models'; import { RequestEntry } from './request.reducer'; import { RequestService } from './request.service'; -export const addToResponseCacheAndCompleteAction = (request: RestRequest, envConfig: GlobalConfig) => +export const addToResponseCacheAndCompleteAction = (request: RestRequest) => (source: Observable): Observable => source.pipe( map((response: RestResponse) => { - return new RequestCompleteAction(request.uuid, response) + return new RequestCompleteAction(request.uuid, response); }) ); @@ -50,9 +49,9 @@ export class RequestEffects { } return this.restApi.request(request.method, request.href, body, request.options).pipe( map((data: DSpaceRESTV2Response) => this.injector.get(request.getResponseParser()).parse(request, data)), - addToResponseCacheAndCompleteAction(request, this.EnvConfig), + addToResponseCacheAndCompleteAction(request), catchError((error: RequestError) => observableOf(new ErrorResponse(error)).pipe( - addToResponseCacheAndCompleteAction(request, this.EnvConfig) + addToResponseCacheAndCompleteAction(request) )) ); }) @@ -72,7 +71,6 @@ export class RequestEffects { ); constructor( - @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig, private actions$: Actions, private restApi: DSpaceRESTv2Service, private injector: Injector, diff --git a/src/app/core/data/request.service.spec.ts b/src/app/core/data/request.service.spec.ts index cfb3611fc6..253577a701 100644 --- a/src/app/core/data/request.service.spec.ts +++ b/src/app/core/data/request.service.spec.ts @@ -4,8 +4,8 @@ import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { BehaviorSubject, EMPTY, of as observableOf } from 'rxjs'; import { TestScheduler } from 'rxjs/testing'; -import { getMockObjectCacheService } from '../../shared/mocks/mock-object-cache.service'; -import { defaultUUID, getMockUUIDService } from '../../shared/mocks/mock-uuid.service'; +import { getMockObjectCacheService } from '../../shared/mocks/object-cache.service.mock'; +import { defaultUUID, getMockUUIDService } from '../../shared/mocks/uuid.service.mock'; import { ObjectCacheService } from '../cache/object-cache.service'; import { CoreState } from '../core.reducers'; import { UUIDService } from '../shared/uuid.service'; diff --git a/src/app/core/data/version-history-data.service.spec.ts b/src/app/core/data/version-history-data.service.spec.ts index 6728df71f1..1a9c402482 100644 --- a/src/app/core/data/version-history-data.service.spec.ts +++ b/src/app/core/data/version-history-data.service.spec.ts @@ -2,9 +2,9 @@ import { RequestService } from './request.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { ObjectCacheService } from '../cache/object-cache.service'; import { VersionHistoryDataService } from './version-history-data.service'; -import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { GetRequest } from './request.models'; const url = 'fake-url'; diff --git a/src/app/core/eperson/eperson-data.service.spec.ts b/src/app/core/eperson/eperson-data.service.spec.ts index cd7bc72884..d83a376da9 100644 --- a/src/app/core/eperson/eperson-data.service.spec.ts +++ b/src/app/core/eperson/eperson-data.service.spec.ts @@ -8,16 +8,7 @@ import { of as observableOf } from 'rxjs'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { Observable } from 'rxjs/internal/Observable'; import { TestScheduler } from 'rxjs/testing'; -import { - EPeopleRegistryCancelEPersonAction, - EPeopleRegistryEditEPersonAction -} from '../../+admin/admin-access-control/epeople-registry/epeople-registry.actions'; -import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/mock-remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; -import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson-mock'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { EPeopleRegistryCancelEPersonAction, EPeopleRegistryEditEPersonAction } from '../../+admin/admin-access-control/epeople-registry/epeople-registry.actions'; import { SearchParam } from '../cache/models/search-param.model'; import { CoreState } from '../core.reducers'; import { ChangeAnalyzer } from '../data/change-analyzer'; @@ -31,6 +22,12 @@ import { Item } from '../shared/item.model'; import { PageInfo } from '../shared/page-info.model'; import { EPersonDataService } from './eperson-data.service'; import { EPerson } from './models/eperson.model'; +import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock'; +import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; describe('EPersonDataService', () => { let service: EPersonDataService; @@ -82,7 +79,7 @@ describe('EPersonDataService', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), ], diff --git a/src/app/core/eperson/eperson-response-parsing.service.ts b/src/app/core/eperson/eperson-response-parsing.service.ts index 76222323ae..e1270e130e 100644 --- a/src/app/core/eperson/eperson-response-parsing.service.ts +++ b/src/app/core/eperson/eperson-response-parsing.service.ts @@ -6,8 +6,6 @@ import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response. import { EpersonSuccessResponse, ErrorResponse, RestResponse } from '../cache/response.models'; import { isNotEmpty } from '../../shared/empty.util'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { DSpaceObject } from '../shared/dspace-object.model'; @@ -20,7 +18,6 @@ export class EpersonResponseParsingService extends BaseResponseParsingService im protected toCache = false; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); diff --git a/src/app/core/eperson/group-data.service.spec.ts b/src/app/core/eperson/group-data.service.spec.ts index 138cf547f2..28d10cfcf1 100644 --- a/src/app/core/eperson/group-data.service.spec.ts +++ b/src/app/core/eperson/group-data.service.spec.ts @@ -10,13 +10,7 @@ import { GroupRegistryCancelGroupAction, GroupRegistryEditGroupAction } from '../../+admin/admin-access-control/group-registry/group-registry.actions'; -import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/mock-remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; -import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson-mock'; import { GroupMock, GroupMock2 } from '../../shared/testing/group-mock'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; import { SearchParam } from '../cache/models/search-param.model'; import { CoreState } from '../core.reducers'; import { ChangeAnalyzer } from '../data/change-analyzer'; @@ -28,6 +22,12 @@ import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service'; import { Item } from '../shared/item.model'; import { PageInfo } from '../shared/page-info.model'; import { GroupDataService } from './group-data.service'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; +import { TranslateLoaderMock } from '../../shared/testing/translate-loader.mock'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock'; describe('GroupDataService', () => { let service: GroupDataService; @@ -63,7 +63,7 @@ describe('GroupDataService', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), ], diff --git a/src/app/core/integration/integration-response-parsing.service.spec.ts b/src/app/core/integration/integration-response-parsing.service.spec.ts index 8cc139744c..b5cb8c4dc4 100644 --- a/src/app/core/integration/integration-response-parsing.service.spec.ts +++ b/src/app/core/integration/integration-response-parsing.service.spec.ts @@ -1,5 +1,4 @@ import { Store } from '@ngrx/store'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ErrorResponse, IntegrationSuccessResponse } from '../cache/response.models'; @@ -13,7 +12,6 @@ import { AuthorityValue } from './models/authority.value'; describe('IntegrationResponseParsingService', () => { let service: IntegrationResponseParsingService; - const EnvConfig = {} as GlobalConfig; const store = {} as Store; const objectCacheService = new ObjectCacheService(store, undefined); const name = 'type'; @@ -198,7 +196,7 @@ describe('IntegrationResponseParsingService', () => { } beforeEach(() => { initVars(); - service = new IntegrationResponseParsingService(EnvConfig, objectCacheService); + service = new IntegrationResponseParsingService(objectCacheService); }); describe('parse', () => { diff --git a/src/app/core/integration/integration-response-parsing.service.ts b/src/app/core/integration/integration-response-parsing.service.ts index 0609cd804e..2719669bae 100644 --- a/src/app/core/integration/integration-response-parsing.service.ts +++ b/src/app/core/integration/integration-response-parsing.service.ts @@ -6,8 +6,6 @@ import { ErrorResponse, IntegrationSuccessResponse, RestResponse } from '../cach import { isNotEmpty } from '../../shared/empty.util'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { IntegrationModel } from './models/integration.model'; import { AuthorityValue } from './models/authority.value'; @@ -19,7 +17,6 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic protected toCache = true; constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, protected objectCache: ObjectCacheService, ) { super(); diff --git a/src/app/core/integration/integration.service.spec.ts b/src/app/core/integration/integration.service.spec.ts index 02fff950ed..148a5df7b8 100644 --- a/src/app/core/integration/integration.service.spec.ts +++ b/src/app/core/integration/integration.service.spec.ts @@ -1,15 +1,15 @@ import { cold, getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { RequestService } from '../data/request.service'; import { IntegrationRequest } from '../data/request.models'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { IntegrationService } from './integration.service'; import { IntegrationSearchOptions } from './models/integration-options.model'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; -import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; +import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock'; const LINK_NAME = 'authorities'; const ENTRIES = 'entries'; diff --git a/src/app/core/json-patch/json-patch-operations.service.spec.ts b/src/app/core/json-patch/json-patch-operations.service.spec.ts index 4ecc215dc7..583b90a01f 100644 --- a/src/app/core/json-patch/json-patch-operations.service.spec.ts +++ b/src/app/core/json-patch/json-patch-operations.service.spec.ts @@ -5,12 +5,12 @@ import { TestScheduler } from 'rxjs/testing'; import { of as observableOf } from 'rxjs'; import { Store, StoreModule } from '@ngrx/store'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { RequestService } from '../data/request.service'; import { SubmissionPatchRequest } from '../data/request.models'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; -import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; +import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock'; import { JsonPatchOperationsService } from './json-patch-operations.service'; import { SubmitDataResponseDefinitionObject } from '../shared/submit-data-response-definition.model'; import { CoreState } from '../core.reducers'; @@ -21,9 +21,10 @@ import { RollbacktPatchOperationsAction, StartTransactionPatchOperationsAction } from './json-patch-operations.actions'; -import { MockStore } from '../../shared/testing/mock-store'; +import { StoreMock } from '../../shared/testing/store.mock'; import { RequestEntry } from '../data/request.reducer'; import { catchError } from 'rxjs/operators'; +import { storeModuleConfig } from '../../app.reducer'; class TestService extends JsonPatchOperationsService { protected linkPath = ''; @@ -101,10 +102,10 @@ describe('JsonPatchOperationsService test suite', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), ], providers: [ - { provide: Store, useClass: MockStore } + { provide: Store, useClass: StoreMock } ] }).compileComponents(); })); diff --git a/src/app/core/metadata/metadata.service.spec.ts b/src/app/core/metadata/metadata.service.spec.ts index e3f6c3401c..c21cf50512 100644 --- a/src/app/core/metadata/metadata.service.spec.ts +++ b/src/app/core/metadata/metadata.service.spec.ts @@ -11,9 +11,6 @@ import { Store, StoreModule } from '@ngrx/store'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { EmptyError } from 'rxjs/internal-compatibility'; -import { ENV_CONFIG, GLOBAL_CONFIG } from '../../../config'; - -import { GlobalConfig } from '../../../config/global-config.interface'; import { RemoteData } from '../../core/data/remote-data'; import { Item } from '../../core/shared/item.model'; @@ -23,11 +20,11 @@ import { MockBitstream2, MockBitstreamFormat1, MockBitstreamFormat2, - MockItem -} from '../../shared/mocks/mock-item'; -import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; + ItemMock +} from '../../shared/mocks/item.mock'; +import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { AuthService } from '../auth/auth.service'; import { BrowseService } from '../browse/browse.service'; @@ -53,6 +50,8 @@ import { PageInfo } from '../shared/page-info.model'; import { UUIDService } from '../shared/uuid.service'; import { MetadataService } from './metadata.service'; +import { environment } from '../../../environments/environment'; +import { storeModuleConfig } from '../../app.reducer'; /* tslint:disable:max-classes-per-file */ @Component({ @@ -97,8 +96,6 @@ describe('MetadataService', () => { let tagStore: Map; - let envConfig: GlobalConfig; - beforeEach(() => { store = new Store(undefined, undefined, undefined); @@ -110,7 +107,7 @@ describe('MetadataService', () => { remoteDataBuildService = new RemoteDataBuildService(objectCacheService, undefined, requestService); const mockBitstreamDataService = { findAllByItemAndBundleName(item: Item, bundleName: string, options?: FindListOptions, ...linksToFollow: Array>): Observable>> { - if (item.equals(MockItem)) { + if (item.equals(ItemMock)) { return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [MockBitstream1, MockBitstream2])); } else { return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])); @@ -135,11 +132,11 @@ describe('MetadataService', () => { TestBed.configureTestingModule({ imports: [ CommonModule, - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), RouterTestingModule.withRoutes([ @@ -160,7 +157,6 @@ describe('MetadataService', () => { { provide: ObjectCacheService, useValue: objectCacheService }, { provide: RequestService, useValue: requestService }, { provide: RemoteDataBuildService, useValue: remoteDataBuildService }, - { provide: GLOBAL_CONFIG, useValue: ENV_CONFIG }, { provide: HALEndpointService, useValue: {} }, { provide: AuthService, useValue: {} }, { provide: NotificationsService, useValue: {} }, @@ -184,8 +180,6 @@ describe('MetadataService', () => { metadataService = TestBed.get(MetadataService); authService = TestBed.get(AuthService); - envConfig = TestBed.get(GLOBAL_CONFIG); - router = TestBed.get(Router); location = TestBed.get(Location); @@ -195,7 +189,7 @@ describe('MetadataService', () => { }); it('items page should set meta tags', fakeAsync(() => { - spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(MockItem)); + spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(ItemMock)); router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']); tick(); expect(title.getTitle()).toEqual('Test PowerPoint Document'); @@ -208,24 +202,24 @@ describe('MetadataService', () => { })); it('items page should set meta tags as published Thesis', fakeAsync(() => { - spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockPublisher(mockType(MockItem, 'Thesis')))); + spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockPublisher(mockType(ItemMock, 'Thesis')))); router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']); tick(); expect(tagStore.get('citation_dissertation_name')[0].content).toEqual('Test PowerPoint Document'); expect(tagStore.get('citation_dissertation_institution')[0].content).toEqual('Mock Publisher'); - expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual([envConfig.ui.baseUrl, router.url].join('')); + expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual([environment.ui.baseUrl, router.url].join('')); expect(tagStore.get('citation_pdf_url')[0].content).toEqual('https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/content'); })); it('items page should set meta tags as published Technical Report', fakeAsync(() => { - spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockPublisher(mockType(MockItem, 'Technical Report')))); + spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(mockPublisher(mockType(ItemMock, 'Technical Report')))); router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']); tick(); expect(tagStore.get('citation_technical_report_institution')[0].content).toEqual('Mock Publisher'); })); it('other navigation should title and description', fakeAsync(() => { - spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(MockItem)); + spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(ItemMock)); router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']); tick(); expect(tagStore.size).toBeGreaterThan(0); @@ -245,7 +239,7 @@ describe('MetadataService', () => { }); it('processRemoteData should not produce an EmptyError', fakeAsync(() => { - spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(MockItem)); + spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(ItemMock)); spyOn(metadataService, 'processRemoteData').and.callThrough(); router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']); tick(); @@ -255,7 +249,7 @@ describe('MetadataService', () => { }); const mockRemoteData = (mockItem: Item): Observable> => { - return createSuccessfulRemoteDataObject$(MockItem); + return createSuccessfulRemoteDataObject$(ItemMock); }; const mockType = (mockItem: Item, type: string): Item => { diff --git a/src/app/core/metadata/metadata.service.ts b/src/app/core/metadata/metadata.service.ts index dbba9d83f6..02d2b0c86b 100644 --- a/src/app/core/metadata/metadata.service.ts +++ b/src/app/core/metadata/metadata.service.ts @@ -8,7 +8,6 @@ import { TranslateService } from '@ngx-translate/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { catchError, distinctUntilKeyChanged, filter, first, map, take } from 'rxjs/operators'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { DSONameService } from '../breadcrumbs/dso-name.service'; import { CacheableObject } from '../cache/object-cache.reducer'; @@ -21,6 +20,7 @@ import { Bitstream } from '../shared/bitstream.model'; import { DSpaceObject } from '../shared/dspace-object.model'; import { Item } from '../shared/item.model'; import { getFirstSucceededRemoteDataPayload, getFirstSucceededRemoteListPayload } from '../shared/operators'; +import { environment } from '../../../environments/environment'; @Injectable() export class MetadataService { @@ -39,7 +39,6 @@ export class MetadataService { private dsoNameService: DSONameService, private bitstreamDataService: BitstreamDataService, private bitstreamFormatDataService: BitstreamFormatDataService, - @Inject(GLOBAL_CONFIG) private envConfig: GlobalConfig ) { // TODO: determine what open graph meta tags are needed and whether // the differ per route. potentially add image based on DSpaceObject @@ -255,7 +254,7 @@ export class MetadataService { */ private setCitationAbstractUrlTag(): void { if (this.currentObject.value instanceof Item) { - const value = [this.envConfig.ui.baseUrl, this.router.url].join(''); + const value = [environment.ui.baseUrl, this.router.url].join(''); this.addMetaTag('citation_abstract_html_url', value); } } @@ -272,7 +271,7 @@ export class MetadataService { first((files) => isNotEmpty(files)), catchError((error) => { console.debug(error.message); - return [] + return []; })) .subscribe((bitstreams: Bitstream[]) => { for (const bitstream of bitstreams) { diff --git a/src/app/core/registry/registry.service.spec.ts b/src/app/core/registry/registry.service.spec.ts index b466693649..d1d817ff36 100644 --- a/src/app/core/registry/registry.service.spec.ts +++ b/src/app/core/registry/registry.service.spec.ts @@ -17,12 +17,12 @@ import { MetadataRegistrySelectFieldAction, MetadataRegistrySelectSchemaAction } from '../../+admin/admin-registries/metadata-registry/metadata-registry.actions'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; -import { MockStore } from '../../shared/testing/mock-store'; -import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { StoreMock } from '../../shared/testing/store.mock'; +import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { @@ -40,6 +40,7 @@ import { PageInfo } from '../shared/page-info.model'; import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model'; import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model'; import { RegistryService } from './registry.service'; +import { storeModuleConfig } from '../../app.reducer'; @Component({ template: '' }) class DummyComponent { @@ -151,7 +152,7 @@ describe('RegistryService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [CommonModule, StoreModule.forRoot({}), TranslateModule.forRoot()], + imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot()], declarations: [ DummyComponent ], @@ -159,7 +160,7 @@ describe('RegistryService', () => { { provide: RequestService, useValue: getMockRequestService() }, { provide: RemoteDataBuildService, useValue: rdbStub }, { provide: HALEndpointService, useValue: halServiceStub }, - { provide: Store, useClass: MockStore }, + { provide: Store, useClass: StoreMock }, { provide: NotificationsService, useValue: new NotificationsServiceStub() }, RegistryService ] diff --git a/src/app/core/services/route.service.spec.ts b/src/app/core/services/route.service.spec.ts index 07ff56d879..1c92931b05 100644 --- a/src/app/core/services/route.service.spec.ts +++ b/src/app/core/services/route.service.spec.ts @@ -6,7 +6,7 @@ import { Store } from '@ngrx/store'; import { getTestScheduler, hot } from 'jasmine-marbles'; import { RouteService } from './route.service'; -import { MockRouter } from '../../shared/mocks/mock-router'; +import { RouterMock } from '../../shared/mocks/router.mock'; import { TestScheduler } from 'rxjs/testing'; import { AddUrlToHistoryAction } from '../history/history.actions'; @@ -29,7 +29,7 @@ describe('RouteService', () => { select: jasmine.createSpy('select') }); - const router = new MockRouter(); + const router = new RouterMock(); router.setParams(convertToParamMap(paramObject)); paramObject[paramName1] = paramValue1; diff --git a/src/app/core/shared/generic-constructor.ts b/src/app/core/shared/generic-constructor.ts index 095fbfcb7a..49a488dc9a 100644 --- a/src/app/core/shared/generic-constructor.ts +++ b/src/app/core/shared/generic-constructor.ts @@ -4,5 +4,5 @@ * https://github.com/Microsoft/TypeScript/issues/204#issuecomment-257722306 */ /* tslint:disable:interface-over-type-literal */ -export type GenericConstructor = { new(...args: any[]): T }; +export type GenericConstructor = new (...args: any[]) => T ; /* tslint:enable:interface-over-type-literal */ diff --git a/src/app/core/shared/hal-endpoint.service.spec.ts b/src/app/core/shared/hal-endpoint.service.spec.ts index cd03b6ec71..5f5c31f29d 100644 --- a/src/app/core/shared/hal-endpoint.service.spec.ts +++ b/src/app/core/shared/hal-endpoint.service.spec.ts @@ -1,18 +1,17 @@ import { cold, getTestScheduler, hot } from 'jasmine-marbles'; -import { GlobalConfig } from '../../../config/global-config.interface'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { RequestService } from '../data/request.service'; import { HALEndpointService } from './hal-endpoint.service'; import { EndpointMapRequest } from '../data/request.models'; import { RequestEntry } from '../data/request.reducer'; import { of as observableOf } from 'rxjs'; +import { environment } from '../../../environments/environment'; describe('HALEndpointService', () => { let service: HALEndpointService; let requestService: RequestService; - let envConfig: GlobalConfig; let requestEntry; - + let envConfig; const endpointMap = { test: 'https://rest.api/test', foo: 'https://rest.api/foo', @@ -55,16 +54,14 @@ describe('HALEndpointService', () => { } as any; service = new HALEndpointService( - requestService, - envConfig + requestService ); }); describe('getRootEndpointMap', () => { - it('should configure a new EndpointMapRequest', () => { (service as any).getRootEndpointMap(); - const expected = new EndpointMapRequest(requestService.generateRequestId(), envConfig.rest.baseUrl); + const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl); expect(requestService.configure).toHaveBeenCalledWith(expected); }); @@ -149,8 +146,7 @@ describe('HALEndpointService', () => { describe('isEnabledOnRestApi', () => { beforeEach(() => { service = new HALEndpointService( - requestService, - envConfig + requestService ); }); diff --git a/src/app/core/shared/hal-endpoint.service.ts b/src/app/core/shared/hal-endpoint.service.ts index 530ac086d1..d8b1d8931f 100644 --- a/src/app/core/shared/hal-endpoint.service.ts +++ b/src/app/core/shared/hal-endpoint.service.ts @@ -1,20 +1,10 @@ -import { Observable, of as observableOf, combineLatest as observableCombineLatest } from 'rxjs'; -import { - distinctUntilChanged, first, - map, - mergeMap, - startWith, - switchMap, take, - tap -} from 'rxjs/operators'; -import { RequestEntry } from '../data/request.reducer'; +import { Observable } from 'rxjs'; +import { distinctUntilChanged, map, startWith, switchMap, take } from 'rxjs/operators'; import { RequestService } from '../data/request.service'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { EndpointMapRequest } from '../data/request.models'; -import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; +import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { RESTURLCombiner } from '../url-combiner/rest-url-combiner'; -import { Inject, Injectable } from '@angular/core'; -import { GLOBAL_CONFIG } from '../../../config'; +import { Injectable } from '@angular/core'; import { EndpointMap, EndpointMapSuccessResponse } from '../cache/response.models'; import { getResponseFromEntry } from './operators'; import { URLCombiner } from '../url-combiner/url-combiner'; @@ -22,12 +12,11 @@ import { URLCombiner } from '../url-combiner/url-combiner'; @Injectable() export class HALEndpointService { - constructor(private requestService: RequestService, - @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { + constructor(private requestService: RequestService) { } protected getRootHref(): string { - return new RESTURLCombiner(this.EnvConfig, '/').toString(); + return new RESTURLCombiner('/').toString(); } protected getRootEndpointMap(): Observable { @@ -60,7 +49,7 @@ export class HALEndpointService { */ private getEndpointAt(href: string, ...halNames: string[]): Observable { if (isEmpty(halNames)) { - throw new Error('cant\'t fetch the URL without the HAL link names') + throw new Error('cant\'t fetch the URL without the HAL link names'); } const nextHref$ = this.getEndpointMapAt(href).pipe( @@ -91,7 +80,7 @@ export class HALEndpointService { map((endpointMap: EndpointMap) => isNotEmpty(endpointMap[linkPath])), startWith(undefined), distinctUntilChanged() - ) + ); } } diff --git a/src/app/core/shared/item.model.spec.ts b/src/app/core/shared/item.model.spec.ts index 9a4e11e6fd..732ae5b19c 100644 --- a/src/app/core/shared/item.model.spec.ts +++ b/src/app/core/shared/item.model.spec.ts @@ -1,4 +1,5 @@ -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { createPaginatedList } from '../../shared/testing/utils.test'; import { Item } from './item.model'; diff --git a/src/app/core/shared/operators.spec.ts b/src/app/core/shared/operators.spec.ts index ec069772f8..a19419259d 100644 --- a/src/app/core/shared/operators.spec.ts +++ b/src/app/core/shared/operators.spec.ts @@ -1,6 +1,6 @@ import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { GetRequest } from '../data/request.models'; import { RequestEntry } from '../data/request.reducer'; import { RequestService } from '../data/request.service'; @@ -21,7 +21,7 @@ import { of as observableOf } from 'rxjs'; import { createFailedRemoteDataObject, createSuccessfulRemoteDataObject -} from '../../shared/testing/utils'; +} from '../../shared/remote-data.utils'; describe('Core Module - RxJS Operators', () => { let scheduler: TestScheduler; diff --git a/src/app/core/shared/search/search-configuration.service.spec.ts b/src/app/core/shared/search/search-configuration.service.spec.ts index b5423e0df0..ef275f3a50 100644 --- a/src/app/core/shared/search/search-configuration.service.spec.ts +++ b/src/app/core/shared/search/search-configuration.service.spec.ts @@ -1,5 +1,5 @@ import { SearchConfigurationService } from './search-configuration.service'; -import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub'; +import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub'; import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../cache/models/sort-options.model'; import { PaginatedSearchOptions } from '../../../shared/search/paginated-search-options.model'; diff --git a/src/app/core/shared/search/search-configuration.service.ts b/src/app/core/shared/search/search-configuration.service.ts index 8ae0855cae..c2bb5082c7 100644 --- a/src/app/core/shared/search/search-configuration.service.ts +++ b/src/app/core/shared/search/search-configuration.service.ts @@ -13,7 +13,7 @@ import { SortDirection, SortOptions } from '../../cache/models/sort-options.mode import { RouteService } from '../../services/route.service'; import { getSucceededRemoteData } from '../operators'; import { hasNoValue, hasValue, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util'; -import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils'; /** * Service that performs all actions that have to do with the current search configuration diff --git a/src/app/core/shared/search/search-filter.service.spec.ts b/src/app/core/shared/search/search-filter.service.spec.ts index 91f53da898..04fa4fbce0 100644 --- a/src/app/core/shared/search/search-filter.service.spec.ts +++ b/src/app/core/shared/search/search-filter.service.spec.ts @@ -12,7 +12,7 @@ import { import { SearchFiltersState } from '../../../shared/search/search-filters/search-filter/search-filter.reducer'; import { SearchFilterConfig } from '../../../shared/search/search-filter-config.model'; import { FilterType } from '../../../shared/search/filter-type.model'; -import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub'; +import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub'; import { of as observableOf } from 'rxjs'; import { SortDirection, SortOptions } from '../../cache/models/sort-options.model'; diff --git a/src/app/core/shared/search/search.service.spec.ts b/src/app/core/shared/search/search.service.spec.ts index 0e093d119c..816d90cb2b 100644 --- a/src/app/core/shared/search/search.service.spec.ts +++ b/src/app/core/shared/search/search.service.spec.ts @@ -7,14 +7,14 @@ import { Component } from '@angular/core'; import { SearchService } from './search.service'; import { Router, UrlTree } from '@angular/router'; import { RequestService } from '../../data/request.service'; -import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub'; -import { RouterStub } from '../../../shared/testing/router-stub'; +import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub'; +import { RouterStub } from '../../../shared/testing/router.stub'; import { HALEndpointService } from '../hal-endpoint.service'; import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs'; import { PaginatedSearchOptions } from '../../../shared/search/paginated-search-options.model'; import { RemoteData } from '../../data/remote-data'; import { RequestEntry } from '../../data/request.reducer'; -import { getMockRequestService } from '../../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../../shared/mocks/request.service.mock'; import { FacetConfigSuccessResponse, SearchSuccessResponse } from '../../cache/response.models'; import { SearchQueryResponse } from '../../../shared/search/search-query-response.model'; import { SearchFilterConfig } from '../../../shared/search/search-filter-config.model'; @@ -23,9 +23,9 @@ import { ViewMode } from '../view-mode.model'; import { DSpaceObjectDataService } from '../../data/dspace-object-data.service'; import { map } from 'rxjs/operators'; import { RouteService } from '../../services/route.service'; -import { routeServiceStub } from '../../../shared/testing/route-service-stub'; +import { routeServiceStub } from '../../../shared/testing/route-service.stub'; import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service'; -import { createSuccessfulRemoteDataObject$ } from '../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils'; @Component({ template: '' }) class DummyComponent { diff --git a/src/app/core/submission/models/submission-object.model.ts b/src/app/core/submission/models/submission-object.model.ts index 87ea19653d..5b0832975d 100644 --- a/src/app/core/submission/models/submission-object.model.ts +++ b/src/app/core/submission/models/submission-object.model.ts @@ -77,7 +77,9 @@ export abstract class SubmissionObject extends DSpaceObject implements Cacheable * Will be undefined unless the item {@link HALLink} has been resolved. */ @link(ITEM) - item?: Observable> | Item; + /* This was changed from 'Observable> | Item' to 'any' to prevent issues in templates with async */ + item?: any; + /** * The configuration object that define this submission * Will be undefined unless the submissionDefinition {@link HALLink} has been resolved. diff --git a/src/app/core/submission/submission-response-parsing.service.ts b/src/app/core/submission/submission-response-parsing.service.ts index 27a7e43c46..afabde831a 100644 --- a/src/app/core/submission/submission-response-parsing.service.ts +++ b/src/app/core/submission/submission-response-parsing.service.ts @@ -9,8 +9,6 @@ import { ErrorResponse, RestResponse, SubmissionSuccessResponse } from '../cache import { isEmpty, isNotEmpty, isNotNull } from '../../shared/empty.util'; import { ConfigObject } from '../config/models/config.model'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { FormFieldMetadataValueObject } from '../../shared/form/builder/models/form-field-metadata-value.model'; import { SubmissionObject } from './models/submission-object.model'; @@ -89,8 +87,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService */ protected shouldDirectlyAttachEmbeds = true; - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - protected objectCache: ObjectCacheService, + constructor(protected objectCache: ObjectCacheService, protected dsoParser: DSOResponseParsingService ) { super(); diff --git a/src/app/core/submission/submission-rest.service.spec.ts b/src/app/core/submission/submission-rest.service.spec.ts index 68d7ff13f4..e57a350e55 100644 --- a/src/app/core/submission/submission-rest.service.spec.ts +++ b/src/app/core/submission/submission-rest.service.spec.ts @@ -4,9 +4,9 @@ import { getTestScheduler } from 'jasmine-marbles'; import { SubmissionRestService } from './submission-rest.service'; import { RequestService } from '../data/request.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { SubmissionDeleteRequest, SubmissionPatchRequest, diff --git a/src/app/core/tasks/claimed-task-data.service.spec.ts b/src/app/core/tasks/claimed-task-data.service.spec.ts index 078fe1e63f..c787d01282 100644 --- a/src/app/core/tasks/claimed-task-data.service.spec.ts +++ b/src/app/core/tasks/claimed-task-data.service.spec.ts @@ -2,8 +2,8 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Store } from '@ngrx/store'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { CoreState } from '../core.reducers'; diff --git a/src/app/core/tasks/models/task-object.model.ts b/src/app/core/tasks/models/task-object.model.ts index 86e0b46f36..d90c7a19c0 100644 --- a/src/app/core/tasks/models/task-object.model.ts +++ b/src/app/core/tasks/models/task-object.model.ts @@ -67,7 +67,8 @@ export class TaskObject extends DSpaceObject implements CacheableObject { * Will be undefined unless the workflowitem {@link HALLink} has been resolved. */ @link(WORKFLOWITEM) - workflowitem?: Observable> | WorkflowItem; + /* This was changed from 'WorkflowItem | Observable>' to 'any' to prevent issues in templates with async */ + workflowitem?: any; /** * The task action type diff --git a/src/app/core/tasks/pool-task-data.service.spec.ts b/src/app/core/tasks/pool-task-data.service.spec.ts index 70ae4c7a91..e8511aca6f 100644 --- a/src/app/core/tasks/pool-task-data.service.spec.ts +++ b/src/app/core/tasks/pool-task-data.service.spec.ts @@ -2,8 +2,8 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Store } from '@ngrx/store'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { CoreState } from '../core.reducers'; diff --git a/src/app/core/tasks/task-response-parsing.service.ts b/src/app/core/tasks/task-response-parsing.service.ts index 090b67ccbb..c4bf8afb05 100644 --- a/src/app/core/tasks/task-response-parsing.service.ts +++ b/src/app/core/tasks/task-response-parsing.service.ts @@ -5,8 +5,6 @@ import { RestRequest } from '../data/request.models'; import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model'; import { BaseResponseParsingService } from '../data/base-response-parsing.service'; -import { GLOBAL_CONFIG } from '../../../config'; -import { GlobalConfig } from '../../../config/global-config.interface'; import { ObjectCacheService } from '../cache/object-cache.service'; import { ErrorResponse, RestResponse, TaskResponse } from '../cache/response.models'; @@ -21,11 +19,9 @@ export class TaskResponseParsingService extends BaseResponseParsingService imple /** * Initialize instance variables * - * @param {GlobalConfig} EnvConfig * @param {ObjectCacheService} objectCache */ - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - protected objectCache: ObjectCacheService,) { + constructor(protected objectCache: ObjectCacheService) { super(); } diff --git a/src/app/core/tasks/tasks.service.spec.ts b/src/app/core/tasks/tasks.service.spec.ts index 782a950b2d..9c8750a832 100644 --- a/src/app/core/tasks/tasks.service.spec.ts +++ b/src/app/core/tasks/tasks.service.spec.ts @@ -1,12 +1,12 @@ import { getTestScheduler } from 'jasmine-marbles'; import { TestScheduler } from 'rxjs/testing'; -import { getMockRequestService } from '../../shared/mocks/mock-request.service'; +import { getMockRequestService } from '../../shared/mocks/request.service.mock'; import { TasksService } from './tasks.service'; import { RequestService } from '../data/request.service'; import { TaskDeleteRequest, TaskPostRequest } from '../data/request.models'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service-stub'; +import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub'; import { TaskObject } from './models/task-object.model'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { Store } from '@ngrx/store'; diff --git a/src/app/core/url-combiner/rest-url-combiner.ts b/src/app/core/url-combiner/rest-url-combiner.ts index 06561c2379..92134050b5 100644 --- a/src/app/core/url-combiner/rest-url-combiner.ts +++ b/src/app/core/url-combiner/rest-url-combiner.ts @@ -1,6 +1,5 @@ import { URLCombiner } from './url-combiner'; - -import { GlobalConfig } from '../../../config'; +import { environment } from '../../../environments/environment'; /** * Combines a variable number of strings representing parts @@ -9,7 +8,7 @@ import { GlobalConfig } from '../../../config'; * TODO write tests once GlobalConfig becomes injectable */ export class RESTURLCombiner extends URLCombiner { - constructor(EnvConfig: GlobalConfig, ...parts: string[]) { - super(EnvConfig.rest.baseUrl, ...parts); + constructor(...parts: string[]) { + super(environment.rest.baseUrl, ...parts); } } diff --git a/src/app/core/url-combiner/ui-url-combiner.ts b/src/app/core/url-combiner/ui-url-combiner.ts index 2ebb26bb76..534c5620b5 100644 --- a/src/app/core/url-combiner/ui-url-combiner.ts +++ b/src/app/core/url-combiner/ui-url-combiner.ts @@ -1,5 +1,5 @@ import { URLCombiner } from './url-combiner'; -import { GlobalConfig } from '../../../config'; +import { environment } from '../../../environments/environment'; /** * Combines a variable number of strings representing parts @@ -8,7 +8,7 @@ import { GlobalConfig } from '../../../config'; * TODO write tests once GlobalConfig becomes injectable */ export class UIURLCombiner extends URLCombiner { - constructor(EnvConfig: GlobalConfig, ...parts: string[]) { - super(EnvConfig.ui.baseUrl, ...parts); + constructor(...parts: string[]) { + super(environment.ui.baseUrl, ...parts); } } diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts index 854ca1065d..31614158dd 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-issue/journal-issue-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { Item } from '../../../../core/shared/item.model'; import { JournalIssueGridElementComponent } from './journal-issue-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { of as observableOf } from 'rxjs'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts index 7405bb7ab4..81cb6ff215 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal-volume/journal-volume-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { Item } from '../../../../core/shared/item.model'; import { JournalVolumeGridElementComponent } from './journal-volume-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { of as observableOf } from 'rxjs'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts index 7355c4aad1..db6d701a7e 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/journal/journal-grid-element.component.spec.ts @@ -1,7 +1,7 @@ import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { JournalGridElementComponent } from './journal-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { async, TestBed } from '@angular/core/testing'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts index 98616daa0b..f65fd97cb0 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts index 9dfa3c3ab3..a7d5acdd00 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts index 4aea6ef156..180b7f4600 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts index 64c1fc3bf7..2ceafa7372 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.spec.ts @@ -3,7 +3,7 @@ import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { JournalIssueComponent } from './journal-issue.component'; import { createRelationshipsObservable, getItemPageFieldsTest } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; const mockItem: Item = Object.assign(new Item(), { bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.spec.ts index f679d80ce7..7849a7e077 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal-volume/journal-volume.component.spec.ts @@ -8,7 +8,7 @@ import { createRelationshipsObservable, getItemPageFieldsTest } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; const mockItem: Item = Object.assign(new Item(), { bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), diff --git a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts index 3cd2ac1cce..91373ce3e0 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-pages/journal/journal.component.spec.ts @@ -22,9 +22,9 @@ import { Item } from '../../../../core/shared/item.model'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { UUIDService } from '../../../../core/shared/uuid.service'; import { isNotEmpty } from '../../../../shared/empty.util'; -import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock'; import { NotificationsService } from '../../../../shared/notifications/notifications.service'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.service'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { JournalComponent } from './journal.component'; @@ -67,7 +67,7 @@ describe('JournalComponent', () => { imports: [TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } })], declarations: [JournalComponent, GenericItemPageFieldComponent, TruncatePipe], diff --git a/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts index f5a0b04dba..1945f67a5c 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/org-unit/org-unit-grid-element.component.spec.ts @@ -1,7 +1,7 @@ import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { OrgUnitGridElementComponent } from './org-unit-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { async, TestBed } from '@angular/core/testing'; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts index 469f45ebf5..99001e887f 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/person/person-grid-element.component.spec.ts @@ -1,7 +1,7 @@ import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { PersonGridElementComponent } from './person-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { async, TestBed } from '@angular/core/testing'; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts index ff9e3bb64a..c2ca0a303e 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/project/project-grid-element.component.spec.ts @@ -1,7 +1,7 @@ import { Item } from '../../../../core/shared/item.model'; import { of as observableOf } from 'rxjs/internal/observable/of'; import { ProjectGridElementComponent } from './project-grid-element.component'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../core/data/paginated-list'; import { PageInfo } from '../../../../core/shared/page-info.model'; import { async, TestBed } from '@angular/core/testing'; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts index a44d2d1373..8dec83295e 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { OrgUnitSearchResultGridElementComponent } from './org-unit-search-result-grid-element.component'; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts index 4938af2b73..f56d6c76af 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { getEntityGridElementTestComponent } from '../../../../../shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.spec'; diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts index 6497fadbaf..5a25eea955 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.spec.ts @@ -1,6 +1,6 @@ import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { Item } from '../../../../../core/shared/item.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PageInfo } from '../../../../../core/shared/page-info.model'; import { ProjectSearchResultGridElementComponent } from './project-search-result-grid-element.component'; diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts index 8bfedbed21..2582754b2f 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.spec.ts @@ -8,7 +8,7 @@ import { createRelationshipsObservable, getItemPageFieldsTest } from '../../../../+item-page/simple/item-types/shared/item.component.spec'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; const mockItem: Item = Object.assign(new Item(), { bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])), diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.spec.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.spec.ts index 8954d27de8..471444de64 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.spec.ts @@ -5,7 +5,7 @@ import { import { PaginatedList } from '../../../../core/data/paginated-list'; import { Item } from '../../../../core/shared/item.model'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { PersonComponent } from './person.component'; const mockItem: Item = Object.assign(new Item(), { diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.spec.ts b/src/app/entity-groups/research-entities/item-pages/project/project.component.spec.ts index 72857654ce..24dc865e2f 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.spec.ts @@ -5,7 +5,7 @@ import { import { PaginatedList } from '../../../../core/data/paginated-list'; import { Item } from '../../../../core/shared/item.model'; import { PageInfo } from '../../../../core/shared/page-info.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils'; import { ProjectComponent } from './project.component'; const mockItem: Item = Object.assign(new Item(), { diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.scss b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.scss index 8fc6d2138d..78cc32591b 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.scss +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.scss @@ -1,7 +1,5 @@ -@import '../../../../../../styles/variables'; - $submission-relationship-thumbnail-width: 80px; .person-thumbnail { width: $submission-relationship-thumbnail-width; -} \ No newline at end of file +} diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.spec.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.spec.ts index e1520d9edd..52f5de92d7 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-search-result-list-submission-element.component.spec.ts @@ -24,7 +24,7 @@ import { UUIDService } from '../../../../../core/shared/uuid.service'; import { NotificationsService } from '../../../../../shared/notifications/notifications.service'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe'; import { OrgUnitSearchResultListSubmissionElementComponent } from './org-unit-search-result-list-submission-element.component'; diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.scss b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.scss index 8fc6d2138d..78cc32591b 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.scss +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.scss @@ -1,7 +1,5 @@ -@import '../../../../../../styles/variables'; - $submission-relationship-thumbnail-width: 80px; .person-thumbnail { width: $submission-relationship-thumbnail-width; -} \ No newline at end of file +} diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts index 0949ebea7e..8064e9be79 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts @@ -24,7 +24,7 @@ import { UUIDService } from '../../../../../core/shared/uuid.service'; import { NotificationsService } from '../../../../../shared/notifications/notifications.service'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils'; import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe'; import { PersonSearchResultListSubmissionElementComponent } from './person-search-result-list-submission-element.component'; diff --git a/src/app/footer/footer.component.spec.ts b/src/app/footer/footer.component.spec.ts index dde432e1ef..8d1d3a9891 100644 --- a/src/app/footer/footer.component.spec.ts +++ b/src/app/footer/footer.component.spec.ts @@ -21,7 +21,8 @@ import { Store, StoreModule } from '@ngrx/store'; // Load the implementations that should be tested import { FooterComponent } from './footer.component'; -import { MockTranslateLoader } from '../shared/mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock'; +import { storeModuleConfig } from '../app.reducer'; let comp: FooterComponent; let fixture: ComponentFixture; @@ -33,10 +34,10 @@ describe('Footer component', () => { // async beforeEach beforeEach(async(() => { return TestBed.configureTestingModule({ - imports: [CommonModule, StoreModule.forRoot({}), TranslateModule.forRoot({ + imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } })], declarations: [FooterComponent], // declare the test component diff --git a/src/app/header/header.component.spec.ts b/src/app/header/header.component.spec.ts index c46eef75e2..1c3133375a 100644 --- a/src/app/header/header.component.spec.ts +++ b/src/app/header/header.component.spec.ts @@ -9,7 +9,7 @@ import { ReactiveFormsModule } from '@angular/forms'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { MenuService } from '../shared/menu/menu.service'; -import { MenuServiceStub } from '../shared/testing/menu-service-stub'; +import { MenuServiceStub } from '../shared/testing/menu-service.stub'; let comp: HeaderComponent; let fixture: ComponentFixture; diff --git a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.spec.ts b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.spec.ts index d1061c72bc..7aec26c140 100644 --- a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.spec.ts +++ b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.spec.ts @@ -2,12 +2,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ExpandableNavbarSectionComponent } from './expandable-navbar-section.component'; import { By } from '@angular/platform-browser'; -import { MenuServiceStub } from '../../shared/testing/menu-service-stub'; +import { MenuServiceStub } from '../../shared/testing/menu-service.stub'; import { Component } from '@angular/core'; import { of as observableOf } from 'rxjs'; import { HostWindowService } from '../../shared/host-window.service'; import { MenuService } from '../../shared/menu/menu.service'; -import { HostWindowServiceStub } from '../../shared/testing/host-window-service-stub'; +import { HostWindowServiceStub } from '../../shared/testing/host-window-service.stub'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; describe('ExpandableNavbarSectionComponent', () => { diff --git a/src/app/navbar/navbar-section/navbar-section.component.spec.ts b/src/app/navbar/navbar-section/navbar-section.component.spec.ts index af46227ec3..90df574021 100644 --- a/src/app/navbar/navbar-section/navbar-section.component.spec.ts +++ b/src/app/navbar/navbar-section/navbar-section.component.spec.ts @@ -4,9 +4,9 @@ import { NavbarSectionComponent } from './navbar-section.component'; import { HostWindowService } from '../../shared/host-window.service'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MenuService } from '../../shared/menu/menu.service'; -import { HostWindowServiceStub } from '../../shared/testing/host-window-service-stub'; +import { HostWindowServiceStub } from '../../shared/testing/host-window-service.stub'; import { Component } from '@angular/core'; -import { MenuServiceStub } from '../../shared/testing/menu-service-stub'; +import { MenuServiceStub } from '../../shared/testing/menu-service.stub'; import { of as observableOf } from 'rxjs'; describe('NavbarSectionComponent', () => { diff --git a/src/app/navbar/navbar.component.spec.ts b/src/app/navbar/navbar.component.spec.ts index ca054a662b..206afda003 100644 --- a/src/app/navbar/navbar.component.spec.ts +++ b/src/app/navbar/navbar.component.spec.ts @@ -6,12 +6,11 @@ import { of as observableOf } from 'rxjs'; import { NavbarComponent } from './navbar.component'; import { ReactiveFormsModule } from '@angular/forms'; import { HostWindowService } from '../shared/host-window.service'; -import { HostWindowServiceStub } from '../shared/testing/host-window-service-stub'; +import { HostWindowServiceStub } from '../shared/testing/host-window-service.stub'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { MenuService } from '../shared/menu/menu.service'; -import { MenuServiceStub } from '../shared/testing/menu-service-stub'; -import { ENV_CONFIG, GLOBAL_CONFIG } from '../../config'; +import { MenuServiceStub } from '../shared/testing/menu-service.stub'; let comp: NavbarComponent; let fixture: ComponentFixture; @@ -31,7 +30,6 @@ describe('NavbarComponent', () => { { provide: Injector, useValue: {} }, { provide: MenuService, useValue: menuService }, { provide: HostWindowService, useValue: new HostWindowServiceStub(800) }, - { provide: GLOBAL_CONFIG, useValue: ENV_CONFIG } ], schemas: [NO_ERRORS_SCHEMA] }) diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts index b2ba10fb98..6055aac263 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -6,7 +6,7 @@ import { MenuID, MenuItemType } from '../shared/menu/initial-menus-state'; import { TextMenuItemModel } from '../shared/menu/menu-item/models/text.model'; import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model'; import { HostWindowService } from '../shared/host-window.service'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../config'; +import { environment } from '../../environments/environment'; /** * Component representing the public navbar @@ -24,8 +24,7 @@ export class NavbarComponent extends MenuComponent implements OnInit { */ menuID = MenuID.PUBLIC; - constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig, - protected menuService: MenuService, + constructor(protected menuService: MenuService, protected injector: Injector, public windowService: HostWindowService ) { @@ -80,7 +79,7 @@ export class NavbarComponent extends MenuComponent implements OnInit { }, ]; // Read the different Browse-By types from config and add them to the browse menu - const types = this.config.browseBy.types; + const types = environment.browseBy.types; types.forEach((typeConfig) => { menuList.push({ id: `browse_global_by_${typeConfig.id}`, diff --git a/src/app/navbar/navbar.effects.spec.ts b/src/app/navbar/navbar.effects.spec.ts index 897fc15be7..34e22ad59d 100644 --- a/src/app/navbar/navbar.effects.spec.ts +++ b/src/app/navbar/navbar.effects.spec.ts @@ -8,7 +8,7 @@ import * as fromRouter from '@ngrx/router-store'; import { CollapseMenuAction } from '../shared/menu/menu.actions'; import { MenuID } from '../shared/menu/initial-menus-state'; import { MenuService } from '../shared/menu/menu.service'; -import { MenuServiceStub } from '../shared/testing/menu-service-stub'; +import { MenuServiceStub } from '../shared/testing/menu-service.stub'; describe('NavbarEffects', () => { let navbarEffects: NavbarEffects; diff --git a/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.spec.ts b/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.spec.ts index 7aeb33d84d..f331750b26 100644 --- a/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.spec.ts +++ b/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.spec.ts @@ -5,72 +5,68 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { RouterTestingModule } from '@angular/router/testing'; import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core'; import { EPerson } from '../../core/eperson/models/eperson.model'; -import { GLOBAL_CONFIG } from '../../../config'; import { FormBuilderService } from '../../shared/form/builder/form-builder.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { EPersonDataService } from '../../core/eperson/eperson-data.service'; import { cloneDeep } from 'lodash'; -import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; describe('ProfilePageMetadataFormComponent', () => { let component: ProfilePageMetadataFormComponent; let fixture: ComponentFixture; - const config = { - languages: [{ - code: 'en', - label: 'English', - active: true, - }, { - code: 'de', - label: 'Deutsch', - active: true, - }] - } as any; + let user; - const user = Object.assign(new EPerson(), { - email: 'example@gmail.com', - metadata: { - 'eperson.firstname': [ - { - value: 'John', - language: null - } - ], - 'eperson.lastname': [ - { - value: 'Doe', - language: null - } - ], - 'eperson.language': [ - { - value: 'de', - language: null - } - ] - } - }); + let epersonService; + let notificationsService; + let translate; - const epersonService = jasmine.createSpyObj('epersonService', { - update: createSuccessfulRemoteDataObject$(user) - }); - const notificationsService = jasmine.createSpyObj('notificationsService', { - success: {}, - error: {}, - warning: {} - }); - const translate = { - instant: () => 'translated', - onLangChange: new EventEmitter() - }; + function init() { + user = Object.assign(new EPerson(), { + email: 'example@gmail.com', + metadata: { + 'eperson.firstname': [ + { + value: 'John', + language: null + } + ], + 'eperson.lastname': [ + { + value: 'Doe', + language: null + } + ], + 'eperson.language': [ + { + value: 'de', + language: null + } + ] + } + }); + + epersonService = jasmine.createSpyObj('epersonService', { + update: createSuccessfulRemoteDataObject$(user) + }); + notificationsService = jasmine.createSpyObj('notificationsService', { + success: {}, + error: {}, + warning: {} + }); + translate = { + instant: () => 'translated', + onLangChange: new EventEmitter() + }; + + } beforeEach(async(() => { + init(); TestBed.configureTestingModule({ declarations: [ProfilePageMetadataFormComponent, VarDirective], imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], providers: [ - { provide: GLOBAL_CONFIG, useValue: config }, { provide: EPersonDataService, useValue: epersonService }, { provide: TranslateService, useValue: translate }, { provide: NotificationsService, useValue: notificationsService }, diff --git a/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.ts b/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.ts index b44faa8c4a..c1216cbb5f 100644 --- a/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.ts +++ b/src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.ts @@ -1,20 +1,20 @@ import { Component, Inject, Input, OnInit } from '@angular/core'; import { DynamicFormControlModel, - DynamicFormService, DynamicFormValueControlModel, + DynamicFormValueControlModel, DynamicInputModel, DynamicSelectModel } from '@ng-dynamic-forms/core'; import { FormGroup } from '@angular/forms'; import { EPerson } from '../../core/eperson/models/eperson.model'; import { TranslateService } from '@ngx-translate/core'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { LangConfig } from '../../../config/lang-config.interface'; import { EPersonDataService } from '../../core/eperson/eperson-data.service'; import { cloneDeep } from 'lodash'; import { getRemoteDataPayload, getSucceededRemoteData } from '../../core/shared/operators'; import { FormBuilderService } from '../../shared/form/builder/form-builder.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { environment } from '../../../environments/environment'; @Component({ selector: 'ds-profile-page-metadata-form', @@ -102,15 +102,14 @@ export class ProfilePageMetadataFormComponent implements OnInit { */ activeLangs: LangConfig[]; - constructor(@Inject(GLOBAL_CONFIG) protected config: GlobalConfig, - protected formBuilderService: FormBuilderService, + constructor(protected formBuilderService: FormBuilderService, protected translate: TranslateService, protected epersonService: EPersonDataService, protected notificationsService: NotificationsService) { } ngOnInit(): void { - this.activeLangs = this.config.languages.filter((MyLangConfig) => MyLangConfig.active === true); + this.activeLangs = environment.languages.filter((MyLangConfig) => MyLangConfig.active === true); this.setFormValues(); this.updateFieldTranslations(); this.translate.onLangChange diff --git a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts index 324230ce9f..225bd8507e 100644 --- a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts +++ b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts @@ -15,22 +15,30 @@ describe('ProfilePageSecurityFormComponent', () => { let component: ProfilePageSecurityFormComponent; let fixture: ComponentFixture; - const user = Object.assign(new EPerson(), { - _links: { - self: { href: 'user-selflink' } - } - }); + let user; - const epersonService = jasmine.createSpyObj('epersonService', { - patch: observableOf(new RestResponse(true, 200, 'OK')) - }); - const notificationsService = jasmine.createSpyObj('notificationsService', { - success: {}, - error: {}, - warning: {} - }); + let epersonService; + let notificationsService; + + function init() { + user = Object.assign(new EPerson(), { + _links: { + self: { href: 'user-selflink' } + } + }); + + epersonService = jasmine.createSpyObj('epersonService', { + patch: observableOf(new RestResponse(true, 200, 'OK')) + }); + notificationsService = jasmine.createSpyObj('notificationsService', { + success: {}, + error: {}, + warning: {} + }); + } beforeEach(async(() => { + init(); TestBed.configureTestingModule({ declarations: [ProfilePageSecurityFormComponent, VarDirective], imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], diff --git a/src/app/profile-page/profile-page.component.spec.ts b/src/app/profile-page/profile-page.component.spec.ts index 5992012be9..d4a65c0ba0 100644 --- a/src/app/profile-page/profile-page.component.spec.ts +++ b/src/app/profile-page/profile-page.component.spec.ts @@ -5,39 +5,48 @@ import { TranslateModule } from '@ngx-translate/core'; import { RouterTestingModule } from '@angular/router/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { EPerson } from '../core/eperson/models/eperson.model'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../shared/testing/utils'; import { Store, StoreModule } from '@ngrx/store'; import { AppState } from '../app.reducer'; import { AuthTokenInfo } from '../core/auth/models/auth-token-info.model'; import { EPersonDataService } from '../core/eperson/eperson-data.service'; import { NotificationsService } from '../shared/notifications/notifications.service'; import { authReducer } from '../core/auth/auth.reducer'; +import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils'; +import { createPaginatedList } from '../shared/testing/utils.test'; describe('ProfilePageComponent', () => { let component: ProfilePageComponent; let fixture: ComponentFixture; + let user; + let authState; - const user = Object.assign(new EPerson(), { - groups: createSuccessfulRemoteDataObject$(createPaginatedList([])) - }); - const authState = { - authenticated: true, - loaded: true, - loading: false, - authToken: new AuthTokenInfo('test_token'), - user: user - }; + let epersonService; + let notificationsService; - const epersonService = jasmine.createSpyObj('epersonService', { - findById: createSuccessfulRemoteDataObject$(user) - }); - const notificationsService = jasmine.createSpyObj('notificationsService', { - success: {}, - error: {}, - warning: {} - }); + function init() { + user = Object.assign(new EPerson(), { + groups: createSuccessfulRemoteDataObject$(createPaginatedList([])) + }); + authState = { + authenticated: true, + loaded: true, + loading: false, + authToken: new AuthTokenInfo('test_token'), + user: user + }; + + epersonService = jasmine.createSpyObj('epersonService', { + findById: createSuccessfulRemoteDataObject$(user) + }); + notificationsService = jasmine.createSpyObj('notificationsService', { + success: {}, + error: {}, + warning: {} + }); + } beforeEach(async(() => { + init(); TestBed.configureTestingModule({ declarations: [ProfilePageComponent, VarDirective], imports: [StoreModule.forRoot(authReducer), TranslateModule.forRoot(), RouterTestingModule.withRoutes([])], diff --git a/src/app/search-navbar/search-navbar.component.spec.ts b/src/app/search-navbar/search-navbar.component.spec.ts index 2a03acd2a2..1388b23113 100644 --- a/src/app/search-navbar/search-navbar.component.spec.ts +++ b/src/app/search-navbar/search-navbar.component.spec.ts @@ -5,7 +5,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { Router } from '@angular/router'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { SearchService } from '../core/shared/search/search.service'; -import { MockTranslateLoader } from '../shared/mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock'; import { SearchNavbarComponent } from './search-navbar.component'; @@ -34,7 +34,7 @@ describe('SearchNavbarComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } })], declarations: [SearchNavbarComponent], diff --git a/src/app/shared/alert/alert.component.spec.ts b/src/app/shared/alert/alert.component.spec.ts index e235e27b28..51e584c3fa 100644 --- a/src/app/shared/alert/alert.component.spec.ts +++ b/src/app/shared/alert/alert.component.spec.ts @@ -7,7 +7,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { TranslateModule } from '@ngx-translate/core'; import { AlertComponent } from './alert.component'; -import { createTestComponent } from '../testing/utils'; +import { createTestComponent } from '../testing/utils.test'; import { AlertType } from './aletr-type'; describe('AlertComponent test suite', () => { diff --git a/src/app/shared/auth-nav-menu/auth-nav-menu.component.spec.ts b/src/app/shared/auth-nav-menu/auth-nav-menu.component.spec.ts index 5e01494674..a05afbdbfb 100644 --- a/src/app/shared/auth-nav-menu/auth-nav-menu.component.spec.ts +++ b/src/app/shared/auth-nav-menu/auth-nav-menu.component.spec.ts @@ -5,11 +5,11 @@ import { By } from '@angular/platform-browser'; import { Store, StoreModule } from '@ngrx/store'; import { authReducer, AuthState } from '../../core/auth/auth.reducer'; -import { EPersonMock } from '../testing/eperson-mock'; +import { EPersonMock } from '../testing/eperson.mock'; import { TranslateModule } from '@ngx-translate/core'; -import { AppState } from '../../app.reducer'; +import { AppState, storeModuleConfig } from '../../app.reducer'; import { AuthNavMenuComponent } from './auth-nav-menu.component'; -import { HostWindowServiceStub } from '../testing/host-window-service-stub'; +import { HostWindowServiceStub } from '../testing/host-window-service.stub'; import { HostWindowService } from '../host-window.service'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { AuthTokenInfo } from '../../core/auth/models/auth-token-info.model'; @@ -51,7 +51,12 @@ describe('AuthNavMenuComponent', () => { TestBed.configureTestingModule({ imports: [ NoopAnimationsModule, - StoreModule.forRoot(authReducer), + StoreModule.forRoot(authReducer, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), TranslateModule.forRoot() ], declarations: [ @@ -244,7 +249,12 @@ describe('AuthNavMenuComponent', () => { TestBed.configureTestingModule({ imports: [ NoopAnimationsModule, - StoreModule.forRoot(authReducer), + StoreModule.forRoot(authReducer, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), TranslateModule.forRoot() ], declarations: [ diff --git a/src/app/shared/auth-nav-menu/user-menu/user-menu.component.spec.ts b/src/app/shared/auth-nav-menu/user-menu/user-menu.component.spec.ts index 512d9e0917..06a25e7ff8 100644 --- a/src/app/shared/auth-nav-menu/user-menu/user-menu.component.spec.ts +++ b/src/app/shared/auth-nav-menu/user-menu/user-menu.component.spec.ts @@ -7,9 +7,9 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { UserMenuComponent } from './user-menu.component'; import { authReducer, AuthState } from '../../../core/auth/auth.reducer'; import { AuthTokenInfo } from '../../../core/auth/models/auth-token-info.model'; -import { EPersonMock } from '../../testing/eperson-mock'; -import { AppState } from '../../../app.reducer'; -import { MockTranslateLoader } from '../../mocks/mock-translate-loader'; +import { EPersonMock } from '../../testing/eperson.mock'; +import { AppState, storeModuleConfig } from '../../../app.reducer'; +import { TranslateLoaderMock } from '../../mocks/translate-loader.mock'; import { cold } from 'jasmine-marbles'; import { By } from '@angular/platform-browser'; @@ -41,11 +41,16 @@ describe('UserMenuComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot(authReducer), + StoreModule.forRoot(authReducer, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }) ], diff --git a/src/app/shared/authority-confidence/authority-confidence-state.directive.ts b/src/app/shared/authority-confidence/authority-confidence-state.directive.ts index 6362daf3c7..410dadfc5f 100644 --- a/src/app/shared/authority-confidence/authority-confidence-state.directive.ts +++ b/src/app/shared/authority-confidence/authority-confidence-state.directive.ts @@ -1,8 +1,9 @@ import { + AfterViewInit, Directive, - ElementRef, EventEmitter, + ElementRef, + EventEmitter, HostListener, - Inject, Input, OnChanges, Output, @@ -16,8 +17,8 @@ import { AuthorityValue } from '../../core/integration/models/authority.value'; import { FormFieldMetadataValueObject } from '../form/builder/models/form-field-metadata-value.model'; import { ConfidenceType } from '../../core/integration/models/confidence-type'; import { isNotEmpty, isNull } from '../empty.util'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { ConfidenceIconConfig } from '../../../config/submission-config.interface'; +import { environment } from '../../../environments/environment'; /** * Directive to add to the element a bootstrap utility class based on metadata confidence value @@ -25,7 +26,7 @@ import { ConfidenceIconConfig } from '../../../config/submission-config.interfac @Directive({ selector: '[dsAuthorityConfidenceState]' }) -export class AuthorityConfidenceStateDirective implements OnChanges { +export class AuthorityConfidenceStateDirective implements OnChanges, AfterViewInit { /** * The metadata value @@ -69,7 +70,6 @@ export class AuthorityConfidenceStateDirective implements OnChanges { * @param {Renderer2} renderer */ constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, private elem: ElementRef, private renderer: Renderer2 ) { @@ -135,7 +135,7 @@ export class AuthorityConfidenceStateDirective implements OnChanges { return 'd-none'; } - const confidenceIcons: ConfidenceIconConfig[] = this.EnvConfig.submission.icons.authority.confidence; + const confidenceIcons: ConfidenceIconConfig[] = environment.submission.icons.authority.confidence; const confidenceIndex: number = findIndex(confidenceIcons, {value: confidence}); diff --git a/src/app/shared/browse-by/browse-by.component.spec.ts b/src/app/shared/browse-by/browse-by.component.spec.ts index 51db888c4b..b21fd2968d 100644 --- a/src/app/shared/browse-by/browse-by.component.spec.ts +++ b/src/app/shared/browse-by/browse-by.component.spec.ts @@ -12,12 +12,13 @@ import { PaginatedList } from '../../core/data/paginated-list'; import { PageInfo } from '../../core/shared/page-info.model'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { StoreModule } from '@ngrx/store'; -import { MockTranslateLoader } from '../mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../mocks/translate-loader.mock'; import { RouterTestingModule } from '@angular/router/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; -import { createSuccessfulRemoteDataObject$ } from '../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils'; +import { storeModuleConfig } from '../../app.reducer'; describe('BrowseByComponent', () => { let comp: BrowseByComponent; @@ -52,11 +53,11 @@ describe('BrowseByComponent', () => { TranslateModule.forRoot(), SharedModule, NgbModule, - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), RouterTestingModule, diff --git a/src/app/shared/chips/chips.component.html b/src/app/shared/chips/chips.component.html index db8f08dad0..74006c80ca 100644 --- a/src/app/shared/chips/chips.component.html +++ b/src/app/shared/chips/chips.component.html @@ -33,7 +33,7 @@ [authorityValue]="c.item[icon.metadata] || c.item" [visibleWhenAuthorityEmpty]="icon.visibleWhenAuthorityEmpty" aria-hidden="true" - (dragstart)="tooltip.close();" + (dragstart)="t.close();" (mouseover)="showTooltip(t, i, icon.metadata)" (mouseout)="t.close()"> diff --git a/src/app/shared/chips/chips.component.spec.ts b/src/app/shared/chips/chips.component.spec.ts index facfc8061b..accbaf8f34 100644 --- a/src/app/shared/chips/chips.component.spec.ts +++ b/src/app/shared/chips/chips.component.spec.ts @@ -8,14 +8,12 @@ import { ChipsComponent } from './chips.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { By } from '@angular/platform-browser'; import { FormFieldMetadataValueObject } from '../form/builder/models/form-field-metadata-value.model'; -import { createTestComponent } from '../testing/utils'; +import { createTestComponent } from '../testing/utils.test'; import { AuthorityConfidenceStateDirective } from '../authority-confidence/authority-confidence-state.directive'; import { TranslateModule } from '@ngx-translate/core'; -import { GlobalConfig } from '../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../config'; -import { MOCK_SUBMISSION_CONFIG } from '../testing/mock-submission-config'; import { ConfidenceType } from '../../core/integration/models/confidence-type'; import { SortablejsModule } from 'ngx-sortablejs'; +import { environment } from '../../../environments/environment'; describe('ChipsComponent test suite', () => { @@ -26,7 +24,6 @@ describe('ChipsComponent test suite', () => { let html; let chips: Chips; - const envConfig: GlobalConfig = MOCK_SUBMISSION_CONFIG; // async beforeEach beforeEach(async(() => { @@ -42,7 +39,6 @@ describe('ChipsComponent test suite', () => { AuthorityConfidenceStateDirective ], // declare the test component providers: [ - { provide: GLOBAL_CONFIG, useValue: envConfig }, ChangeDetectorRef, ChipsComponent, UploaderService @@ -154,7 +150,7 @@ describe('ChipsComponent test suite', () => { otherRelatedField: new FormFieldMetadataValueObject('other related test') }; - chips = new Chips([item], 'display', 'mainField', envConfig.submission.icons.metadata); + chips = new Chips([item], 'display', 'mainField', environment.submission.icons.metadata); chipsFixture = TestBed.createComponent(ChipsComponent); chipsComp = chipsFixture.componentInstance; // TruncatableComponent test instance chipsComp.editable = true; @@ -177,7 +173,7 @@ describe('ChipsComponent test suite', () => { icons[0].triggerEventHandler('mouseover', null); - expect(chipsComp.tipText).toEqual(['main test']) + expect(chipsComp.tipText).toEqual(['main test']); }); }); }); diff --git a/src/app/shared/chips/models/chips-item.model.ts b/src/app/shared/chips/models/chips-item.model.ts index 913232fa71..d60d29e41e 100644 --- a/src/app/shared/chips/models/chips-item.model.ts +++ b/src/app/shared/chips/models/chips-item.model.ts @@ -102,7 +102,7 @@ export class ChipsItem { const obj = this.objToDisplay ? this._item[this.objToDisplay] : this._item; if (isObject(obj) && obj) { - value = obj[this.fieldToDisplay] || obj.value; + value = obj[this.fieldToDisplay] || (obj as any).value; } else { value = obj; } @@ -113,6 +113,6 @@ export class ChipsItem { private hasPlaceholder(value: any) { return (typeof value === 'string') ? (value === PLACEHOLDER_PARENT_METADATA) : - (value as FormFieldMetadataValueObject).hasPlaceholder() + (value as FormFieldMetadataValueObject).hasPlaceholder(); } } diff --git a/src/app/shared/chips/models/chips.model.ts b/src/app/shared/chips/models/chips.model.ts index 25754361cb..de694bdcfd 100644 --- a/src/app/shared/chips/models/chips.model.ts +++ b/src/app/shared/chips/models/chips.model.ts @@ -74,7 +74,7 @@ export class Chips { private hasPlaceholder(value) { if (isObject(value)) { - return value.value === PLACEHOLDER_PARENT_METADATA; + return (value as any).value === PLACEHOLDER_PARENT_METADATA; } else { return value === PLACEHOLDER_PARENT_METADATA; } diff --git a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts index 454a036b15..a1bac46f87 100644 --- a/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts +++ b/src/app/shared/comcol-forms/comcol-form/comcol-form.component.spec.ts @@ -17,9 +17,9 @@ import { RestRequestMethod } from '../../../core/data/rest-request-method'; import { Community } from '../../../core/shared/community.model'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { hasValue } from '../../empty.util'; -import { AuthServiceMock } from '../../mocks/mock-auth.service'; +import { AuthServiceMock } from '../../mocks/auth.service.mock'; import { NotificationsService } from '../../notifications/notifications.service'; -import { NotificationsServiceStub } from '../../testing/notifications-service-stub'; +import { NotificationsServiceStub } from '../../testing/notifications-service.stub'; import { VarDirective } from '../../utils/var.directive'; import { ComColFormComponent } from './comcol-form.component'; @@ -318,7 +318,6 @@ describe('ComColFormComponent', () => { (comp as any).type = Community.type; comp.uploaderComponent = {uploader: {}} as any; - console.log(comp); (comp as any).dsoService = dsoService; fixture.detectChanges(); location = (comp as any).location; diff --git a/src/app/shared/comcol-forms/create-comcol-page/create-comcol-page.component.spec.ts b/src/app/shared/comcol-forms/create-comcol-page/create-comcol-page.component.spec.ts index 717979891f..780589d0c5 100644 --- a/src/app/shared/comcol-forms/create-comcol-page/create-comcol-page.component.spec.ts +++ b/src/app/shared/comcol-forms/create-comcol-page/create-comcol-page.component.spec.ts @@ -14,10 +14,10 @@ import { CreateComColPageComponent } from './create-comcol-page.component'; import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ -} from '../../testing/utils'; +} from '../../remote-data.utils'; import { ComColDataService } from '../../../core/data/comcol-data.service'; import { NotificationsService } from '../../notifications/notifications.service'; -import { NotificationsServiceStub } from '../../testing/notifications-service-stub'; +import { NotificationsServiceStub } from '../../testing/notifications-service.stub'; describe('CreateComColPageComponent', () => { let comp: CreateComColPageComponent; diff --git a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts index dbbeea5bc6..a3f6ac0216 100644 --- a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts +++ b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts @@ -12,7 +12,7 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { DataService } from '../../../core/data/data.service'; import { DeleteComColPageComponent } from './delete-comcol-page.component'; import { NotificationsService } from '../../notifications/notifications.service'; -import { NotificationsServiceStub } from '../../testing/notifications-service-stub'; +import { NotificationsServiceStub } from '../../testing/notifications-service.stub'; describe('DeleteComColPageComponent', () => { let comp: DeleteComColPageComponent; diff --git a/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts index 84454c4250..414d64cbff 100644 --- a/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts +++ b/src/app/shared/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.spec.ts @@ -12,8 +12,8 @@ import { Community } from '../../../../core/shared/community.model'; import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; import { NotificationsService } from '../../../notifications/notifications.service'; import { SharedModule } from '../../../shared.module'; -import { NotificationsServiceStub } from '../../../testing/notifications-service-stub'; -import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../testing/utils'; +import { NotificationsServiceStub } from '../../../testing/notifications-service.stub'; +import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils'; import { ComcolMetadataComponent } from './comcol-metadata.component'; describe('ComColMetadataComponent', () => { diff --git a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts index 091e02723f..477af5c1e4 100644 --- a/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts +++ b/src/app/shared/comcol-page-browse-by/comcol-page-browse-by.component.ts @@ -1,27 +1,18 @@ -import { - ChangeDetectionStrategy, - Component, - Inject, - Input, NgZone, - OnDestroy, - OnInit -} from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { Observable } from 'rxjs/internal/Observable'; -import { Subscription } from 'rxjs/internal/Subscription'; -import { filter, map, startWith, tap } from 'rxjs/operators'; +import { map } from 'rxjs/operators'; import { getCollectionPageRoute } from '../../+collection-page/collection-page-routing.module'; import { getCommunityPageRoute } from '../../+community-page/community-page-routing.module'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; -import { Router, ActivatedRoute, RouterModule, UrlSegment, Params } from '@angular/router'; +import { ActivatedRoute, Params, Router } from '@angular/router'; import { BrowseByTypeConfig } from '../../../config/browse-by-type-config.interface'; -import { hasValue } from '../empty.util'; +import { environment } from '../../../environments/environment'; export interface ComColPageNavOption { id: string; - label: string, - routerLink: string + label: string; + routerLink: string; params?: any; -}; +} /** * A component to display the "Browse By" section of a Community or Collection page @@ -48,13 +39,12 @@ export class ComcolPageBrowseByComponent implements OnInit { currentOptionId$: Observable; constructor( - @Inject(GLOBAL_CONFIG) public config: GlobalConfig, private route: ActivatedRoute, private router: Router) { } ngOnInit(): void { - this.allOptions = this.config.browseBy.types + this.allOptions = environment.browseBy.types .map((config: BrowseByTypeConfig) => ({ id: config.id, label: `browse.comcol.by.${config.id}`, diff --git a/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts b/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts index 3a2ab307be..bf403e9e88 100644 --- a/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts +++ b/src/app/shared/comcol-page-handle/comcol-page-handle.component.ts @@ -1,7 +1,6 @@ -import { Component, Input, Inject, Injectable } from '@angular/core'; -import { GlobalConfig } from '../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../config'; +import { Component, Injectable, Input } from '@angular/core'; import { UIURLCombiner } from '../../core/url-combiner/ui-url-combiner'; + /** * This component builds a URL from the value of "handle" */ @@ -21,9 +20,7 @@ export class ComcolPageHandleComponent { // The value of "handle" @Input() content: string; - constructor(@Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { - } public getHandle(): string { - return new UIURLCombiner(this.EnvConfig, '/handle/', this.content).toString(); + return new UIURLCombiner('/handle/', this.content).toString(); } } diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts index 2de59d614b..b177e12988 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts @@ -8,7 +8,7 @@ import { ItemSearchResult } from '../../object-collection/shared/item-search-res import { Item } from '../../../core/shared/item.model'; import { PaginatedList } from '../../../core/data/paginated-list'; import { MetadataValue } from '../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject$ } from '../../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils'; import { PaginatedSearchOptions } from '../../search/paginated-search-options.model'; describe('DSOSelectorComponent', () => { diff --git a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.spec.ts index 97957d5250..480f6ff709 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.spec.ts @@ -5,12 +5,12 @@ import { of as observableOf } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import * as collectionRouter from '../../../../+collection-page/collection-page-routing.module'; import { Community } from '../../../../core/shared/community.model'; import { CreateCollectionParentSelectorComponent } from './create-collection-parent-selector.component'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('CreateCollectionParentSelectorComponent', () => { let component: CreateCollectionParentSelectorComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.spec.ts index 4871d74b98..b723d3fe98 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.spec.ts @@ -5,12 +5,12 @@ import { of as observableOf } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import * as communityRouter from '../../../../+community-page/community-page-routing.module'; import { Community } from '../../../../core/shared/community.model'; import { CreateCommunityParentSelectorComponent } from './create-community-parent-selector.component'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('CreateCommunityParentSelectorComponent', () => { let component: CreateCommunityParentSelectorComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.spec.ts index b3058ab879..854349a47c 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.spec.ts @@ -5,11 +5,11 @@ import { of as observableOf } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import { Collection } from '../../../../core/shared/collection.model'; import { CreateItemParentSelectorComponent } from './create-item-parent-selector.component'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('CreateItemParentSelectorComponent', () => { let component: CreateItemParentSelectorComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts index 15f23d1fe6..7b5c020f1b 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts @@ -14,7 +14,7 @@ import { By } from '@angular/platform-browser'; import { DSOSelectorComponent } from '../dso-selector/dso-selector.component'; import { MockComponent } from 'ng-mocks'; import { MetadataValue } from '../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../remote-data.utils'; describe('DSOSelectorModalWrapperComponent', () => { let component: DSOSelectorModalWrapperComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.spec.ts index cbb8fb654e..a17d9e4c21 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.spec.ts @@ -5,12 +5,12 @@ import { of as observableOf } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import * as collectionRouter from '../../../../+collection-page/collection-page-routing.module'; import { EditCollectionSelectorComponent } from './edit-collection-selector.component'; import { Collection } from '../../../../core/shared/collection.model'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('EditCollectionSelectorComponent', () => { let component: EditCollectionSelectorComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.spec.ts index 46684e6cfb..c48d29baa9 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.spec.ts @@ -5,12 +5,12 @@ import { of as observableOf } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import * as communityRouter from '../../../../+community-page/community-page-routing.module'; import { EditCommunitySelectorComponent } from './edit-community-selector.component'; import { Community } from '../../../../core/shared/community.model'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('EditCommunitySelectorComponent', () => { let component: EditCommunitySelectorComponent; diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.spec.ts index 86066916a6..582320acae 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.spec.ts @@ -7,10 +7,10 @@ import { ActivatedRoute, Router } from '@angular/router'; import { EditItemSelectorComponent } from './edit-item-selector.component'; import { Item } from '../../../../core/shared/item.model'; import { RemoteData } from '../../../../core/data/remote-data'; -import { RouterStub } from '../../../testing/router-stub'; +import { RouterStub } from '../../../testing/router.stub'; import * as itemRouter from '../../../../+item-page/item-page-routing.module'; import { MetadataValue } from '../../../../core/shared/metadata.models'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('EditItemSelectorComponent', () => { let component: EditItemSelectorComponent; diff --git a/src/app/shared/error/error.component.spec.ts b/src/app/shared/error/error.component.spec.ts index 7335f93aed..18ee2f24ef 100644 --- a/src/app/shared/error/error.component.spec.ts +++ b/src/app/shared/error/error.component.spec.ts @@ -4,7 +4,7 @@ import { DebugElement } from '@angular/core'; import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core'; -import { MockTranslateLoader } from '../mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../mocks/translate-loader.mock'; import { ErrorComponent } from './error.component'; @@ -21,7 +21,7 @@ describe('ErrorComponent (inline template)', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), ], diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts index 75ea88735f..4dee6905d2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts @@ -70,7 +70,7 @@ import { SubmissionObjectDataService } from '../../../../core/submission/submiss import { Item } from '../../../../core/shared/item.model'; import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model'; import { of as observableOf } from 'rxjs'; -import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; +import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils'; describe('DsDynamicFormControlContainerComponent test suite', () => { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts index fa13febcd1..79a650b597 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts @@ -7,7 +7,7 @@ import { select, Store } from '@ngrx/store'; import { Item } from '../../../../../core/shared/item.model'; import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model'; import { RelationshipOptions } from '../../models/relationship-options.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils'; import { RemoveRelationshipAction } from '../relation-lookup-modal/relationship.actions'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html index 9d56d7d1b3..75c27b6ca5 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html @@ -12,7 +12,7 @@ = new EventEmitter(); @Output() change: EventEmitter = new EventEmitter(); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.html index 3cfb5980c6..254b15411d 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.html @@ -59,7 +59,7 @@ ngbTooltip="{{'form.clear-help' | translate}}" placement="top" [disabled]="model.readOnly" - (click)="remove($event)">{{'form.clear' | translate}} + (click)="remove()">{{'form.clear' | translate}}
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts index c1f8ad69ba..472fb3af61 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts @@ -13,7 +13,7 @@ import { } from '@ng-dynamic-forms/core'; import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstrap'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; -import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; +import { AuthorityServiceStub } from '../../../../../testing/authority-service.stub'; import { DsDynamicLookupComponent } from './dynamic-lookup.component'; import { DynamicLookupModel } from './dynamic-lookup.model'; import { InfiniteScrollModule } from 'ngx-infinite-scroll'; @@ -21,14 +21,11 @@ import { TranslateModule } from '@ngx-translate/core'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { By } from '@angular/platform-browser'; import { AuthorityValue } from '../../../../../../core/integration/models/authority.value'; -import { createTestComponent } from '../../../../../testing/utils'; +import { createTestComponent } from '../../../../../testing/utils.test'; import { DynamicLookupNameModel } from './dynamic-lookup-name.model'; import { AuthorityConfidenceStateDirective } from '../../../../../authority-confidence/authority-confidence-state.directive'; import { ObjNgFor } from '../../../../../utils/object-ngfor.pipe'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../../../../../config'; -import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config'; -import { WorkspaceitemsEditPageModule } from '../../../../../../+workspaceitems-edit-page/workspaceitems-edit-page.module'; -import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model'; +import { GlobalConfig } from '../../../../../../../config/global-config.interface'; let LOOKUP_TEST_MODEL_CONFIG = { authorityOptions: { @@ -83,8 +80,6 @@ let LOOKUP_TEST_GROUP = new FormGroup({ lookupName: new FormControl() }); -const envConfig: GlobalConfig = MOCK_SUBMISSION_CONFIG; - describe('Dynamic Lookup component', () => { function init() { LOOKUP_TEST_MODEL_CONFIG = { @@ -172,7 +167,6 @@ describe('Dynamic Lookup component', () => { providers: [ ChangeDetectorRef, DsDynamicLookupComponent, - { provide: GLOBAL_CONFIG, useValue: envConfig }, { provide: AuthorityService, useValue: authorityService }, { provide: DynamicFormLayoutService, useValue: {} }, { provide: DynamicFormValidationService, useValue: {} } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts index ac9046c12b..d5516df6d9 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts @@ -30,7 +30,7 @@ import { ConfidenceType } from '../../../../../../core/integration/models/confid export class DsDynamicLookupComponent extends DynamicFormControlComponent implements OnDestroy, OnInit { @Input() bindId = true; @Input() group: FormGroup; - @Input() model: DynamicLookupModel | DynamicLookupNameModel; + @Input() model: any; @Output() blur: EventEmitter = new EventEmitter(); @Output() change: EventEmitter = new EventEmitter(); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts index eb0f8f76f9..bcddb52123 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts @@ -12,27 +12,25 @@ import { SubmissionFormsModel } from '../../../../../../core/config/models/confi import { FormFieldModel } from '../../../models/form-field.model'; import { FormBuilderService } from '../../../form-builder.service'; import { FormService } from '../../../../form.service'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../../../../../config'; import { FormComponent } from '../../../../form.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { Chips } from '../../../../../chips/models/chips.model'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { DsDynamicInputModel } from '../ds-dynamic-input.model'; -import { createTestComponent } from '../../../../../testing/utils'; +import { createTestComponent } from '../../../../../testing/utils.test'; import { DynamicFormLayoutService, DynamicFormValidationService } from '@ng-dynamic-forms/core'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; -import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; -import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config'; +import { AuthorityServiceStub } from '../../../../../testing/authority-service.stub'; import { Store, StoreModule } from '@ngrx/store'; -import { MockStore } from '../../../../../testing/mock-store'; +import { StoreMock } from '../../../../../testing/store.mock'; import { FormRowModel } from '../../../../../../core/config/models/config-submission-form.model'; +import { GlobalConfig } from '../../../../../../../config/global-config.interface'; +import { storeModuleConfig } from '../../../../../../app.reducer'; export let FORM_GROUP_TEST_MODEL_CONFIG; export let FORM_GROUP_TEST_GROUP; -const config: GlobalConfig = MOCK_SUBMISSION_CONFIG; - const submissionId = '1234'; function init() { @@ -114,7 +112,7 @@ describe('DsDynamicRelationGroupComponent test suite', () => { FormsModule, ReactiveFormsModule, NgbModule, - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot() ], declarations: [ @@ -131,8 +129,7 @@ describe('DsDynamicRelationGroupComponent test suite', () => { FormComponent, FormService, { provide: AuthorityService, useValue: new AuthorityServiceStub() }, - { provide: GLOBAL_CONFIG, useValue: config }, - { provide: Store, useClass: MockStore } + { provide: Store, useClass: StoreMock } ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts index 5f96e957ac..11085a1bc3 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts @@ -32,14 +32,13 @@ import { Chips } from '../../../../../chips/models/chips.model'; import { hasValue, isEmpty, isNotEmpty, isNotNull } from '../../../../../empty.util'; import { shrinkInOut } from '../../../../../animations/shrink'; import { ChipsItem } from '../../../../../chips/models/chips-item.model'; -import { GlobalConfig } from '../../../../../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../../../../../config'; import { hasOnlyEmptyProperties } from '../../../../../object.util'; import { IntegrationSearchOptions } from '../../../../../../core/integration/models/integration-options.model'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; import { IntegrationData } from '../../../../../../core/integration/integration-data'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { AuthorityValue } from '../../../../../../core/integration/models/authority.value'; +import { environment } from '../../../../../../../environments/environment'; @Component({ selector: 'ds-dynamic-relation-group', @@ -67,8 +66,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent @ViewChild('formRef', {static: false}) private formRef: FormComponent; - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - private authorityService: AuthorityService, + constructor(private authorityService: AuthorityService, private formBuilderService: FormBuilderService, private formService: FormService, private cdr: ChangeDetectorRef, @@ -295,7 +293,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent initChipsValue, 'value', this.model.mandatoryField, - this.EnvConfig.submission.icons.metadata); + environment.submission.icons.metadata); this.subs.push( this.chips.chipsItems .subscribe(() => { @@ -308,7 +306,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent } } }), - ) + ); } private resetForm() { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts index 16446e624e..6086444264 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts @@ -11,11 +11,11 @@ import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstr import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; -import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; +import { AuthorityServiceStub } from '../../../../../testing/authority-service.stub'; import { DsDynamicScrollableDropdownComponent } from './dynamic-scrollable-dropdown.component'; import { DynamicScrollableDropdownModel } from './dynamic-scrollable-dropdown.model'; import { AuthorityValue } from '../../../../../../core/integration/models/authority.value'; -import { createTestComponent, hasClass } from '../../../../../testing/utils'; +import { createTestComponent, hasClass } from '../../../../../testing/utils.test'; export const SD_TEST_GROUP = new FormGroup({ dropdown: new FormControl(), diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts index dcc4eaf9c9..79d652623f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts @@ -14,16 +14,14 @@ import { NgbModule, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstr import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; -import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; +import { AuthorityServiceStub } from '../../../../../testing/authority-service.stub'; import { DsDynamicTagComponent } from './dynamic-tag.component'; import { DynamicTagModel } from './dynamic-tag.model'; import { GlobalConfig } from '../../../../../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../../../../../config'; import { Chips } from '../../../../../chips/models/chips.model'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { AuthorityValue } from '../../../../../../core/integration/models/authority.value'; -import { createTestComponent } from '../../../../../testing/utils'; -import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config'; +import { createTestComponent } from '../../../../../testing/utils.test'; function createKeyUpEvent(key: number) { /* tslint:disable:no-empty */ @@ -40,7 +38,6 @@ function createKeyUpEvent(key: number) { let TAG_TEST_GROUP; let TAG_TEST_MODEL_CONFIG; -const envConfig: GlobalConfig = MOCK_SUBMISSION_CONFIG; function init() { TAG_TEST_GROUP = new FormGroup({ @@ -96,7 +93,6 @@ describe('DsDynamicTagComponent test suite', () => { ChangeDetectorRef, DsDynamicTagComponent, { provide: AuthorityService, useValue: authorityServiceStub }, - { provide: GLOBAL_CONFIG, useValue: envConfig }, { provide: DynamicFormLayoutService, useValue: {} }, { provide: DynamicFormValidationService, useValue: {} } ], diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts index c976454dd9..69a7a5a8c2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts @@ -16,8 +16,7 @@ import { DynamicTagModel } from './dynamic-tag.model'; import { IntegrationSearchOptions } from '../../../../../../core/integration/models/integration-options.model'; import { Chips } from '../../../../../chips/models/chips.model'; import { hasValue, isNotEmpty } from '../../../../../empty.util'; -import { GlobalConfig } from '../../../../../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../../../../../config'; +import { environment } from '../../../../../../../environments/environment'; @Component({ selector: 'ds-dynamic-tag', @@ -73,10 +72,9 @@ export class DsDynamicTagComponent extends DynamicFormControlComponent implement }), map((results) => results.list), tap(() => this.changeSearchingStatus(false)), - merge(this.hideSearchingWhenUnsubscribed),); + merge(this.hideSearchingWhenUnsubscribed)); - constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - private authorityService: AuthorityService, + constructor(private authorityService: AuthorityService, private cdr: ChangeDetectorRef, protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService @@ -98,7 +96,7 @@ export class DsDynamicTagComponent extends DynamicFormControlComponent implement this.model.value, 'display', null, - this.EnvConfig.submission.icons.metadata); + environment.submission.icons.metadata); this.chips.chipsItems .subscribe((subItems: any[]) => { @@ -108,7 +106,7 @@ export class DsDynamicTagComponent extends DynamicFormControlComponent implement this.model.valueUpdates.next(items); this.change.emit(event); } - }) + }); } changeSearchingStatus(status: boolean) { diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.model.ts index d17cccd338..dfc350bd2f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.model.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.model.ts @@ -1,6 +1,5 @@ import { AUTOCOMPLETE_OFF, DynamicFormControlLayout, serializable } from '@ng-dynamic-forms/core'; import { DsDynamicInputModel, DsDynamicInputModelConfig } from '../ds-dynamic-input.model'; -import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; export const DYNAMIC_FORM_CONTROL_TYPE_TAG = 'TAG'; @@ -22,7 +21,7 @@ export class DynamicTagModel extends DsDynamicInputModel { this.autoComplete = AUTOCOMPLETE_OFF; this.minChars = config.minChars || 3; const value = config.value || []; - this.valueUpdates.next(value) + this.valueUpdates.next(value); } } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.spec.ts index 4b1e2d8703..f31f0eeff9 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.spec.ts @@ -12,23 +12,19 @@ import { TranslateModule } from '@ngx-translate/core'; import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; import { AuthorityService } from '../../../../../../core/integration/authority.service'; -import { AuthorityServiceStub } from '../../../../../testing/authority-service-stub'; +import { AuthorityServiceStub } from '../../../../../testing/authority-service.stub'; import { GlobalConfig } from '../../../../../../../config/global-config.interface'; -import { GLOBAL_CONFIG } from '../../../../../../../config'; import { DsDynamicTypeaheadComponent } from './dynamic-typeahead.component'; import { DynamicTypeaheadModel } from './dynamic-typeahead.model'; import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; -import { createTestComponent } from '../../../../../testing/utils'; +import { createTestComponent } from '../../../../../testing/utils.test'; import { AuthorityConfidenceStateDirective } from '../../../../../authority-confidence/authority-confidence-state.directive'; -import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config'; import { ObjNgFor } from '../../../../../utils/object-ngfor.pipe'; export let TYPEAHEAD_TEST_GROUP; export let TYPEAHEAD_TEST_MODEL_CONFIG; -const envConfig: GlobalConfig = MOCK_SUBMISSION_CONFIG; - function init() { TYPEAHEAD_TEST_GROUP = new FormGroup({ typeahead: new FormControl(), @@ -83,7 +79,6 @@ describe('DsDynamicTypeaheadComponent test suite', () => { providers: [ ChangeDetectorRef, DsDynamicTypeaheadComponent, - { provide: GLOBAL_CONFIG, useValue: envConfig }, { provide: AuthorityService, useValue: authorityServiceStub }, { provide: DynamicFormLayoutService, useValue: {} }, { provide: DynamicFormValidationService, useValue: {} } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html index 328cdc6763..b4a9e4c9c7 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.html @@ -27,6 +27,7 @@ { let component: DsDynamicLookupRelationExternalSourceTabComponent; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts index c8b3b3d311..a280f577f1 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts @@ -72,7 +72,7 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit * The context to displaying lists for */ @Input() context: Context; - + @Input() repeatable: boolean; /** * Emit an event when an object has been imported (or selected from similar local entries) */ diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.spec.ts index 264b3f945a..ec0f225ae2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/external-source-entry-import-modal/external-source-entry-import-modal.component.spec.ts @@ -8,12 +8,13 @@ import { LookupRelationService } from '../../../../../../../core/data/lookup-rel import { ExternalSourceEntry } from '../../../../../../../core/shared/external-source-entry.model'; import { Item } from '../../../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../../object-collection/shared/item-search-result.model'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../../../../../testing/utils'; import { Collection } from '../../../../../../../core/shared/collection.model'; import { RelationshipOptions } from '../../../../models/relationship-options.model'; import { SelectableListService } from '../../../../../../object-list/selectable-list/selectable-list.service'; import { ItemDataService } from '../../../../../../../core/data/item-data.service'; import { NotificationsService } from '../../../../../../notifications/notifications.service'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../../remote-data.utils'; +import { createPaginatedList } from '../../../../../../testing/utils.test'; describe('DsDynamicLookupRelationExternalSourceTabComponent', () => { let component: ExternalSourceEntryImportModalComponent; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts index f9d7dabf9c..32067b8b3a 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts @@ -8,7 +8,8 @@ import { MetadataValue } from '../../../../../core/shared/metadata.models'; import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service'; import { RelationshipService } from '../../../../../core/data/relationship.service'; import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model'; -import { createSuccessfulRemoteDataObject$, spyOnOperator } from '../../../../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils'; +import { spyOnOperator } from '../../../../testing/utils.test'; import { RelationshipType } from '../../../../../core/shared/item-relationships/relationship-type.model'; import { cold, hot } from 'jasmine-marbles'; import * as operators from 'rxjs/operators'; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts index ced6c8b88b..8db75261ee 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts @@ -11,7 +11,7 @@ import { VarDirective } from '../../../../../utils/var.directive'; import { RelationshipOptions } from '../../../models/relationship-options.model'; import { of as observableOf } from 'rxjs'; import { PaginatedSearchOptions } from '../../../../../search/paginated-search-options.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../remote-data.utils'; import { PaginatedList } from '../../../../../../core/data/paginated-list'; import { ItemSearchResult } from '../../../../../object-collection/shared/item-search-result.model'; import { Item } from '../../../../../../core/shared/item.model'; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts index 18e5d3c3ab..eeea96e64b 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.spec.ts @@ -14,7 +14,7 @@ import { By } from '@angular/platform-browser'; import { RemoteData } from '../../../../../../core/data/remote-data'; import { PaginatedList } from '../../../../../../core/data/paginated-list'; import { ListableObject } from '../../../../../object-collection/shared/listable-object.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../../../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../../../../../remote-data.utils'; describe('DsDynamicLookupRelationSelectionTabComponent', () => { let component: DsDynamicLookupRelationSelectionTabComponent; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts index f4746853f6..a918b51930 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts @@ -5,13 +5,13 @@ import { Observable } from 'rxjs'; import { ListableObject } from '../../../../../object-collection/shared/listable-object.model'; import { RemoteData } from '../../../../../../core/data/remote-data'; import { map, switchMap, take } from 'rxjs/operators'; -import { createSuccessfulRemoteDataObject } from '../../../../../testing/utils'; import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model'; import { PaginatedList } from '../../../../../../core/data/paginated-list'; import { Router } from '@angular/router'; import { PaginatedSearchOptions } from '../../../../../search/paginated-search-options.model'; import { PageInfo } from '../../../../../../core/shared/page-info.model'; import { Context } from '../../../../../../core/shared/context.model'; +import { createSuccessfulRemoteDataObject } from '../../../../../remote-data.utils'; @Component({ selector: 'ds-dynamic-lookup-relation-selection-tab', diff --git a/src/app/shared/form/builder/form-builder.service.ts b/src/app/shared/form/builder/form-builder.service.ts index bd5728668c..7e657d97d4 100644 --- a/src/app/shared/form/builder/form-builder.service.ts +++ b/src/app/shared/form/builder/form-builder.service.ts @@ -110,12 +110,12 @@ export class FormBuilderService extends DynamicFormService { if (isString(controlValue)) { return new FormFieldMetadataValueObject(controlValue, controlLanguage, null, null, controlModelIndex); } else if (isObject(controlValue)) { - const authority = controlValue.authority || controlValue.id || null; - const place = controlModelIndex || controlValue.place; + const authority = (controlValue as any).authority || (controlValue as any).id || null; + const place = controlModelIndex || (controlValue as any).place; if (isNgbDateStruct(controlValue)) { - return new FormFieldMetadataValueObject(controlValue, controlLanguage, authority, controlValue, place); + return new FormFieldMetadataValueObject(controlValue, controlLanguage, authority, controlValue as any, place); } else { - return new FormFieldMetadataValueObject(controlValue.value, controlLanguage, authority, controlValue.display, place, controlValue.confidence); + return new FormFieldMetadataValueObject((controlValue as any).value, controlLanguage, authority, (controlValue as any).display, place, (controlValue as any).confidence); } } }; @@ -175,13 +175,13 @@ export class FormBuilderService extends DynamicFormService { } } }); - }) + }); } else if (isNotUndefined((controlModel as any).value) && isNotEmpty((controlModel as any).value)) { const controlArrayValue = []; // Normalize control value as an array of FormFieldMetadataValueObject const values = Array.isArray((controlModel as any).value) ? (controlModel as any).value : [(controlModel as any).value]; values.forEach((controlValue) => { - controlArrayValue.push(normalizeValue(controlModel, controlValue, controlModelIndex)) + controlArrayValue.push(normalizeValue(controlModel, controlValue, controlModelIndex)); }); if (controlId && iterateResult.hasOwnProperty(controlId) && isNotNull(iterateResult[controlId])) { diff --git a/src/app/shared/form/builder/parsers/disabled-field-parser.spec.ts b/src/app/shared/form/builder/parsers/disabled-field-parser.spec.ts index 7dce05f18d..c885b737c2 100644 --- a/src/app/shared/form/builder/parsers/disabled-field-parser.spec.ts +++ b/src/app/shared/form/builder/parsers/disabled-field-parser.spec.ts @@ -59,7 +59,6 @@ describe('DisabledFieldParser test suite', () => { const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions); const fieldModel = parser.parse(); - console.log(fieldModel); expect(fieldModel.value).toEqual(expectedValue); }); diff --git a/src/app/shared/form/builder/parsers/disabled-field-parser.ts b/src/app/shared/form/builder/parsers/disabled-field-parser.ts index db3e4ac8b9..14d7051466 100644 --- a/src/app/shared/form/builder/parsers/disabled-field-parser.ts +++ b/src/app/shared/form/builder/parsers/disabled-field-parser.ts @@ -8,7 +8,6 @@ import { DsDynamicDisabledModelConfig, DynamicDisabledModel } from '../ds-dynami export class DisabledFieldParser extends FieldParser { public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: boolean): any { - console.log(fieldValue); const emptyModelConfig: DsDynamicDisabledModelConfig = this.initModel(null, label); this.setValues(emptyModelConfig, fieldValue); return new DynamicDisabledModel(emptyModelConfig) diff --git a/src/app/shared/form/form.component.spec.ts b/src/app/shared/form/form.component.spec.ts index f0617c5c0a..6a8a1229d4 100644 --- a/src/app/shared/form/form.component.spec.ts +++ b/src/app/shared/form/form.component.spec.ts @@ -19,11 +19,11 @@ import { FormService } from './form.service'; import { FormBuilderService } from './builder/form-builder.service'; import { FormState } from './form.reducer'; import { FormChangeAction, FormStatusChangeAction } from './form.actions'; -import { MockStore } from '../testing/mock-store'; +import { StoreMock } from '../testing/store.mock'; import { FormFieldMetadataValueObject } from './builder/models/form-field-metadata-value.model'; -import { GLOBAL_CONFIG } from '../../../config'; -import { createTestComponent } from '../testing/utils'; +import { createTestComponent } from '../testing/utils.test'; import { BehaviorSubject } from 'rxjs'; +import { storeModuleConfig } from '../../app.reducer'; let TEST_FORM_MODEL; @@ -32,7 +32,7 @@ let TEST_FORM_MODEL_WITH_ARRAY; let config; let formState: FormState; let html; -let store: MockStore; +let store: StoreMock; function init() { TEST_FORM_MODEL = [ @@ -143,7 +143,7 @@ describe('FormComponent test suite', () => { FormsModule, ReactiveFormsModule, NgbModule, - StoreModule.forRoot({}), + StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot() ], declarations: [ @@ -156,8 +156,7 @@ describe('FormComponent test suite', () => { FormBuilderService, FormComponent, FormService, - { provide: GLOBAL_CONFIG, useValue: config }, - { provide: Store, useClass: MockStore } + { provide: Store, useClass: StoreMock } ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }); diff --git a/src/app/shared/form/form.service.spec.ts b/src/app/shared/form/form.service.spec.ts index 80dfa01d1b..ee90e377ee 100644 --- a/src/app/shared/form/form.service.spec.ts +++ b/src/app/shared/form/form.service.spec.ts @@ -10,9 +10,9 @@ import { import { FormService } from './form.service'; import { FormBuilderService } from './builder/form-builder.service'; -import { AppState } from '../../app.reducer'; +import { AppState, storeModuleConfig } from '../../app.reducer'; import { formReducer } from './form.reducer'; -import { getMockFormBuilderService } from '../mocks/mock-form-builder-service'; +import { getMockFormBuilderService } from '../mocks/form-builder-service.mock'; describe('FormService test suite', () => { const config = { @@ -91,7 +91,12 @@ describe('FormService test suite', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({ formReducer }) + StoreModule.forRoot({ formReducer }, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }) ] }).compileComponents(); })); @@ -108,7 +113,7 @@ describe('FormService test suite', () => { const description: AbstractControl = new FormControl(undefined); formGroup = new FormGroup({ author, title, date, description }); controls = { author, title, date, description }; - service = new FormService(config, builderService, store); + service = new FormService(builderService, store); }) ) ; diff --git a/src/app/shared/form/form.service.ts b/src/app/shared/form/form.service.ts index ee354d504f..2b0815a40e 100644 --- a/src/app/shared/form/form.service.ts +++ b/src/app/shared/form/form.service.ts @@ -16,14 +16,13 @@ import { FormRemoveAction, FormRemoveErrorAction, FormStatusChangeAction } from './form.actions'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import { FormEntry } from './form.reducer'; +import { environment } from '../../../environments/environment'; @Injectable() export class FormService { constructor( - @Inject(GLOBAL_CONFIG) public config: GlobalConfig, private formBuilderService: FormBuilderService, private store: Store) { } @@ -147,11 +146,11 @@ export class FormService { validator = this.getValidatorNameFromMap(splitArray[splitArray.length - 1]); } } - return (this.config.form.validatorMap.hasOwnProperty(validator)) ? this.config.form.validatorMap[validator] : validator; + return (environment.form.validatorMap.hasOwnProperty(validator)) ? environment.form.validatorMap[validator] : validator; } public initForm(formId: string, model: DynamicFormControlModel[], valid: boolean) { - this.store.dispatch(new FormInitAction(formId, this.formBuilderService.getValueFromModel(model), valid)) + this.store.dispatch(new FormInitAction(formId, this.formBuilderService.getValueFromModel(model), valid)); } public setStatusChanged(formId: string, valid: boolean) { diff --git a/src/app/shared/host-window.service.spec.ts b/src/app/shared/host-window.service.spec.ts index e65285c2be..a2e8488870 100644 --- a/src/app/shared/host-window.service.spec.ts +++ b/src/app/shared/host-window.service.spec.ts @@ -4,7 +4,7 @@ import { of as observableOf } from 'rxjs'; import { AppState } from '../app.reducer'; import { HostWindowService, WidthCategory } from './host-window.service'; -import { CSSVariableServiceStub } from './testing/css-variable-service-stub'; +import { CSSVariableServiceStub } from './testing/css-variable-service.stub'; describe('HostWindowService', () => { let service: HostWindowService; let store: Store; diff --git a/src/app/shared/item/item-versions/item-versions.component.spec.ts b/src/app/shared/item/item-versions/item-versions.component.spec.ts index 18fa4cf983..3ffbb3824a 100644 --- a/src/app/shared/item/item-versions/item-versions.component.spec.ts +++ b/src/app/shared/item/item-versions/item-versions.component.spec.ts @@ -7,9 +7,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Item } from '../../../core/shared/item.model'; import { Version } from '../../../core/shared/version.model'; import { VersionHistory } from '../../../core/shared/version-history.model'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../testing/utils'; import { VersionHistoryDataService } from '../../../core/data/version-history-data.service'; import { By } from '@angular/platform-browser'; +import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils'; +import { createPaginatedList } from '../../testing/utils.test'; describe('ItemVersionsComponent', () => { let component: ItemVersionsComponent; diff --git a/src/app/shared/item/item-versions/notice/item-versions-notice.component.spec.ts b/src/app/shared/item/item-versions/notice/item-versions-notice.component.spec.ts index ffcd1d897e..f00dee2853 100644 --- a/src/app/shared/item/item-versions/notice/item-versions-notice.component.spec.ts +++ b/src/app/shared/item/item-versions/notice/item-versions-notice.component.spec.ts @@ -5,10 +5,11 @@ import { RouterTestingModule } from '@angular/router/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { VersionHistory } from '../../../../core/shared/version-history.model'; import { Version } from '../../../../core/shared/version.model'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../../testing/utils'; import { Item } from '../../../../core/shared/item.model'; import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service'; import { By } from '@angular/platform-browser'; +import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils'; +import { createPaginatedList } from '../../../testing/utils.test'; describe('ItemVersionsNoticeComponent', () => { let component: ItemVersionsNoticeComponent; diff --git a/src/app/shared/lang-switch/lang-switch.component.spec.ts b/src/app/shared/lang-switch/lang-switch.component.spec.ts index 3d7aca46b6..4e24ba4d04 100644 --- a/src/app/shared/lang-switch/lang-switch.component.spec.ts +++ b/src/app/shared/lang-switch/lang-switch.component.spec.ts @@ -1,13 +1,12 @@ -import {LangSwitchComponent} from './lang-switch.component'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {DebugElement, NO_ERRORS_SCHEMA} from '@angular/core'; -import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core'; -import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import { GLOBAL_CONFIG } from '../../../config'; -import {LangConfig} from '../../../config/lang-config.interface'; -import {Observable, of} from 'rxjs'; +import { LangSwitchComponent } from './lang-switch.component'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; +import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { LangConfig } from '../../../config/lang-config.interface'; +import { Observable, of } from 'rxjs'; import { By } from '@angular/platform-browser'; -import { MockCookieService } from '../mocks/mock-cookie.service'; +import { CookieServiceMock } from '../mocks/cookie.service.mock'; import { CookieService } from '../../core/services/cookie.service'; // This test is completely independent from any message catalogs or keys in the codebase @@ -20,14 +19,15 @@ import { CookieService } from '../../core/services/cookie.service'; class CustomLoader implements TranslateLoader { getTranslation(lang: string): Observable { return of({ - "footer": { - "copyright": "copyright © 2002-{{ year }}", - "link.dspace": "DSpace software", - "link.duraspace": "DuraSpace" + 'footer': { + 'copyright': 'copyright © 2002-{{ year }}', + 'link.dspace': 'DSpace software', + 'link.duraspace': 'DuraSpace' } }); } } + /* tslint:enable:quotemark */ /* tslint:enable:object-literal-key-quotes */ @@ -36,7 +36,7 @@ let cookie: CookieService; describe('LangSwitchComponent', () => { beforeEach(() => { - cookie = Object.assign(new MockCookieService()); + cookie = Object.assign(new CookieServiceMock()); }); describe('with English and Deutsch activated, English as default', () => { @@ -65,14 +65,13 @@ describe('LangSwitchComponent', () => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule, TranslateModule.forRoot( { - loader: {provide: TranslateLoader, useClass: CustomLoader} + loader: { provide: TranslateLoader, useClass: CustomLoader } } )], declarations: [LangSwitchComponent], schemas: [NO_ERRORS_SCHEMA], providers: [ TranslateService, - { provide: GLOBAL_CONFIG, useValue: mockConfig }, { provide: CookieService, useValue: cookie } ] }).compileComponents() @@ -154,14 +153,13 @@ describe('LangSwitchComponent', () => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule, TranslateModule.forRoot( { - loader: {provide: TranslateLoader, useClass: CustomLoader} + loader: { provide: TranslateLoader, useClass: CustomLoader } } )], declarations: [LangSwitchComponent], schemas: [NO_ERRORS_SCHEMA], providers: [ TranslateService, - { provide: GLOBAL_CONFIG, useValue: mockConfig }, { provide: CookieService, useValue: cookie } ] }).compileComponents(); diff --git a/src/app/shared/lang-switch/lang-switch.component.ts b/src/app/shared/lang-switch/lang-switch.component.ts index e91ed5c9a2..433d9038d7 100644 --- a/src/app/shared/lang-switch/lang-switch.component.ts +++ b/src/app/shared/lang-switch/lang-switch.component.ts @@ -1,9 +1,9 @@ import {Component, Inject, OnInit} from '@angular/core'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../config'; import {TranslateService} from '@ngx-translate/core'; import {LangConfig} from '../../../config/lang-config.interface'; import { LANG_COOKIE } from '../../app.component'; import { CookieService } from '../../core/services/cookie.service'; +import { environment } from '../../../environments/environment'; @Component({ selector: 'ds-lang-switch', @@ -24,14 +24,13 @@ export class LangSwitchComponent implements OnInit { moreThanOneLanguage: boolean; constructor( - @Inject(GLOBAL_CONFIG) public config: GlobalConfig, public translate: TranslateService, public cookie: CookieService ) { } ngOnInit(): void { - this.activeLangs = this.config.languages.filter((MyLangConfig) => MyLangConfig.active === true); + this.activeLangs = environment.languages.filter((MyLangConfig) => MyLangConfig.active === true); this.moreThanOneLanguage = (this.activeLangs.length > 1); } diff --git a/src/app/shared/loading/loading.component.spec.ts b/src/app/shared/loading/loading.component.spec.ts index 3c58fa3e9e..52ffad7c50 100644 --- a/src/app/shared/loading/loading.component.spec.ts +++ b/src/app/shared/loading/loading.component.spec.ts @@ -4,7 +4,7 @@ import { DebugElement } from '@angular/core'; import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core'; -import { MockTranslateLoader } from '../mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../mocks/translate-loader.mock'; import { LoadingComponent } from './loading.component'; @@ -21,7 +21,7 @@ describe('LoadingComponent (inline template)', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }), ], diff --git a/src/app/shared/log-in/container/log-in-container.component.spec.ts b/src/app/shared/log-in/container/log-in-container.component.spec.ts index c819b0cc8d..41673cc773 100644 --- a/src/app/shared/log-in/container/log-in-container.component.spec.ts +++ b/src/app/shared/log-in/container/log-in-container.component.spec.ts @@ -8,10 +8,10 @@ import { TranslateModule } from '@ngx-translate/core'; import { LogInContainerComponent } from './log-in-container.component'; import { authReducer } from '../../../core/auth/auth.reducer'; import { SharedModule } from '../../shared.module'; -import { createTestComponent } from '../../testing/utils'; import { AuthService } from '../../../core/auth/auth.service'; import { AuthMethod } from '../../../core/auth/models/auth.method'; -import { AuthServiceStub } from '../../testing/auth-service-stub'; +import { AuthServiceStub } from '../../testing/auth-service.stub'; +import { createTestComponent } from '../../testing/utils.test'; describe('LogInContainerComponent', () => { diff --git a/src/app/shared/log-in/log-in.component.spec.ts b/src/app/shared/log-in/log-in.component.spec.ts index 0be04d4ddf..0167d61686 100644 --- a/src/app/shared/log-in/log-in.component.spec.ts +++ b/src/app/shared/log-in/log-in.component.spec.ts @@ -1,22 +1,23 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { StoreModule } from '@ngrx/store'; -import { provideMockStore } from '@ngrx/store/testing'; -import { TranslateModule } from '@ngx-translate/core'; +import { Store, StoreModule } from '@ngrx/store'; import { LogInComponent } from './log-in.component'; +import { authReducer } from '../../core/auth/auth.reducer'; +import { TranslateModule } from '@ngx-translate/core'; + import { AuthService } from '../../core/auth/auth.service'; -import { authMethodsMock, AuthServiceStub } from '../testing/auth-service-stub'; -import { createTestComponent } from '../testing/utils'; +import { authMethodsMock, AuthServiceStub } from '../testing/auth-service.stub'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { SharedModule } from '../shared.module'; -import { appReducers } from '../../app.reducer'; -import { NativeWindowService } from '../../core/services/window.service'; import { NativeWindowMockFactory } from '../mocks/mock-native-window-ref'; +import { ActivatedRouteStub } from '../testing/active-router.stub'; import { ActivatedRoute, Router } from '@angular/router'; -import { RouterStub } from '../testing/router-stub'; -import { ActivatedRouteStub } from '../testing/active-router-stub'; +import { RouterStub } from '../testing/router.stub'; +import { NativeWindowService } from '../../core/services/window.service'; +import { provideMockStore } from '@ngrx/store/testing'; +import { createTestComponent } from '../testing/utils.test'; describe('LogInComponent', () => { @@ -39,7 +40,12 @@ describe('LogInComponent', () => { imports: [ FormsModule, ReactiveFormsModule, - StoreModule.forRoot(appReducers), + StoreModule.forRoot(authReducer, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), SharedModule, TranslateModule.forRoot() ], diff --git a/src/app/shared/log-in/methods/password/log-in-password.component.spec.ts b/src/app/shared/log-in/methods/password/log-in-password.component.spec.ts index ff65a240c8..68c939d1bc 100644 --- a/src/app/shared/log-in/methods/password/log-in-password.component.spec.ts +++ b/src/app/shared/log-in/methods/password/log-in-password.component.spec.ts @@ -8,10 +8,10 @@ import { TranslateModule } from '@ngx-translate/core'; import { LogInPasswordComponent } from './log-in-password.component'; import { EPerson } from '../../../../core/eperson/models/eperson.model'; -import { EPersonMock } from '../../../testing/eperson-mock'; +import { EPersonMock } from '../../../testing/eperson.mock'; import { authReducer } from '../../../../core/auth/auth.reducer'; import { AuthService } from '../../../../core/auth/auth.service'; -import { AuthServiceStub } from '../../../testing/auth-service-stub'; +import { AuthServiceStub } from '../../../testing/auth-service.stub'; import { AppState } from '../../../../app.reducer'; import { AuthMethod } from '../../../../core/auth/models/auth.method'; import { AuthMethodType } from '../../../../core/auth/models/auth.method-type'; diff --git a/src/app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.spec.ts b/src/app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.spec.ts index 29723d0f65..7c1e782ee0 100644 --- a/src/app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.spec.ts +++ b/src/app/shared/log-in/methods/shibboleth/log-in-shibboleth.component.spec.ts @@ -5,17 +5,17 @@ import { Store, StoreModule } from '@ngrx/store'; import { TranslateModule } from '@ngx-translate/core'; import { EPerson } from '../../../../core/eperson/models/eperson.model'; -import { EPersonMock } from '../../../testing/eperson-mock'; +import { EPersonMock } from '../../../testing/eperson.mock'; import { authReducer } from '../../../../core/auth/auth.reducer'; import { AuthService } from '../../../../core/auth/auth.service'; -import { AuthServiceStub } from '../../../testing/auth-service-stub'; +import { AuthServiceStub } from '../../../testing/auth-service.stub'; import { AppState } from '../../../../app.reducer'; import { AuthMethod } from '../../../../core/auth/models/auth.method'; import { AuthMethodType } from '../../../../core/auth/models/auth.method-type'; import { LogInShibbolethComponent } from './log-in-shibboleth.component'; import { NativeWindowService } from '../../../../core/services/window.service'; -import { RouterStub } from '../../../testing/router-stub'; -import { ActivatedRouteStub } from '../../../testing/active-router-stub'; +import { RouterStub } from '../../../testing/router.stub'; +import { ActivatedRouteStub } from '../../../testing/active-router.stub'; import { NativeWindowMockFactory } from '../../../mocks/mock-native-window-ref'; describe('LogInShibbolethComponent', () => { @@ -26,17 +26,21 @@ describe('LogInShibbolethComponent', () => { let user: EPerson; let componentAsAny: any; let setHrefSpy; - const shibbolethBaseUrl = 'dspace-rest.test/shibboleth?redirectUrl='; - const location = shibbolethBaseUrl + 'http://dspace-angular.test/home'; + let shibbolethBaseUrl; + let location; - const authState = { - authenticated: false, - loaded: false, - loading: false, - }; + let authState; beforeEach(() => { user = EPersonMock; + shibbolethBaseUrl = 'dspace-rest.test/shibboleth?redirectUrl='; + location = shibbolethBaseUrl + 'http://dspace-angular.test/home'; + + authState = { + authenticated: false, + loaded: false, + loading: false, + }; }); beforeEach(async(() => { diff --git a/src/app/shared/log-out/log-out.component.spec.ts b/src/app/shared/log-out/log-out.component.spec.ts index 94780ead5a..fcdb50f17c 100644 --- a/src/app/shared/log-out/log-out.component.spec.ts +++ b/src/app/shared/log-out/log-out.component.spec.ts @@ -5,13 +5,13 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { Store, StoreModule } from '@ngrx/store'; import { authReducer } from '../../core/auth/auth.reducer'; -import { EPersonMock } from '../testing/eperson-mock'; +import { EPersonMock } from '../testing/eperson.mock'; import { EPerson } from '../../core/eperson/models/eperson.model'; import { TranslateModule } from '@ngx-translate/core'; import { Router } from '@angular/router'; -import { AppState } from '../../app.reducer'; +import { AppState, storeModuleConfig } from '../../app.reducer'; import { LogOutComponent } from './log-out.component'; -import { RouterStub } from '../testing/router-stub'; +import { RouterStub } from '../testing/router.stub'; describe('LogOutComponent', () => { @@ -37,7 +37,12 @@ describe('LogOutComponent', () => { imports: [ FormsModule, ReactiveFormsModule, - StoreModule.forRoot(authReducer), + StoreModule.forRoot(authReducer, { + runtimeChecks: { + strictStateImmutability: false, + strictActionImmutability: false + } + }), TranslateModule.forRoot() ], declarations: [ diff --git a/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts b/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts index 199bbeae25..d20773165f 100644 --- a/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts +++ b/src/app/shared/menu/menu-item/link-menu-item.component.spec.ts @@ -3,8 +3,8 @@ import { TranslateModule } from '@ngx-translate/core'; import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { By } from '@angular/platform-browser'; import { LinkMenuItemComponent } from './link-menu-item.component'; -import { RouterLinkDirectiveStub } from '../../testing/router-link-directive-stub'; -import { GLOBAL_CONFIG } from '../../../../config'; +import { RouterLinkDirectiveStub } from '../../testing/router-link-directive.stub'; +import { environment } from '../../../../environments/environment'; describe('LinkMenuItemComponent', () => { let component: LinkMenuItemComponent; @@ -12,18 +12,10 @@ describe('LinkMenuItemComponent', () => { let debugElement: DebugElement; let text; let link; - let nameSpace; - let globalConfig; function init() { text = 'HELLO'; link = 'http://google.com'; - nameSpace = 'dspace.com/'; - globalConfig = { - ui: { - nameSpace: nameSpace - } - } as any; } beforeEach(async(() => { init(); @@ -32,7 +24,6 @@ describe('LinkMenuItemComponent', () => { declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub], providers: [ { provide: 'itemModelProvider', useValue: { text: text, link: link } }, - { provide: GLOBAL_CONFIG, useValue: globalConfig }, ], schemas: [NO_ERRORS_SCHEMA] }) @@ -60,6 +51,6 @@ describe('LinkMenuItemComponent', () => { const routerLinkQuery = linkDes.map((de) => de.injector.get(RouterLinkDirectiveStub)); expect(routerLinkQuery.length).toBe(1); - expect(routerLinkQuery[0].routerLink).toBe(nameSpace + link); + expect(routerLinkQuery[0].routerLink).toBe(environment.ui.nameSpace + link); }); }); diff --git a/src/app/shared/menu/menu-item/link-menu-item.component.ts b/src/app/shared/menu/menu-item/link-menu-item.component.ts index 4e1e70236b..e5b66c5aab 100644 --- a/src/app/shared/menu/menu-item/link-menu-item.component.ts +++ b/src/app/shared/menu/menu-item/link-menu-item.component.ts @@ -2,8 +2,8 @@ import { Component, Inject, Input, OnInit } from '@angular/core'; import { LinkMenuItemModel } from './models/link.model'; import { MenuItemType } from '../initial-menus-state'; import { rendersMenuItemForType } from '../menu-item.decorator'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config'; import { isNotEmpty } from '../../empty.util'; +import { environment } from '../../../../environments/environment'; /** * Component that renders a menu section of type LINK @@ -16,7 +16,7 @@ import { isNotEmpty } from '../../empty.util'; export class LinkMenuItemComponent implements OnInit { item: LinkMenuItemModel; hasLink: boolean; - constructor(@Inject('itemModelProvider') item: LinkMenuItemModel, @Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig) { + constructor(@Inject('itemModelProvider') item: LinkMenuItemModel) { this.item = item; } @@ -26,7 +26,7 @@ export class LinkMenuItemComponent implements OnInit { getRouterLink() { if (this.hasLink) { - return this.EnvConfig.ui.nameSpace + this.item.link; + return environment.ui.nameSpace + this.item.link; } return undefined; } diff --git a/src/app/shared/menu/menu-section/menu-section.component.spec.ts b/src/app/shared/menu/menu-section/menu-section.component.spec.ts index 0a72d17eca..5c28d8fadf 100644 --- a/src/app/shared/menu/menu-section/menu-section.component.spec.ts +++ b/src/app/shared/menu/menu-section/menu-section.component.spec.ts @@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { MenuSectionComponent } from './menu-section.component'; import { MenuService } from '../menu.service'; -import { MenuServiceStub } from '../../testing/menu-service-stub'; +import { MenuServiceStub } from '../../testing/menu-service.stub'; import { MenuSection } from '../menu.reducer'; import { of as observableOf } from 'rxjs'; import { LinkMenuItemComponent } from '../menu-item/link-menu-item.component'; diff --git a/src/app/shared/menu/menu.component.spec.ts b/src/app/shared/menu/menu.component.spec.ts index 52cdebbe91..625c96e795 100644 --- a/src/app/shared/menu/menu.component.spec.ts +++ b/src/app/shared/menu/menu.component.spec.ts @@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; import { MenuService } from './menu.service'; import { MenuComponent } from './menu.component'; -import { MenuServiceStub } from '../testing/menu-service-stub'; +import { MenuServiceStub } from '../testing/menu-service.stub'; import { of as observableOf } from 'rxjs'; import { MenuSection } from './menu.reducer'; diff --git a/src/app/shared/menu/menu.component.ts b/src/app/shared/menu/menu.component.ts index 763da86c4b..1e81fa2dda 100644 --- a/src/app/shared/menu/menu.component.ts +++ b/src/app/shared/menu/menu.component.ts @@ -8,7 +8,6 @@ import { GenericConstructor } from '../../core/shared/generic-constructor'; import { hasValue } from '../empty.util'; import { MenuSectionComponent } from './menu-section/menu-section.component'; import { getComponentForMenu } from './menu-section.decorator'; -import Timer = NodeJS.Timer; /** * A basic implementation of a MenuComponent @@ -61,7 +60,7 @@ export class MenuComponent implements OnInit { /** * Timer to briefly delay the sidebar preview from opening or closing */ - private previewTimer: Timer; + private previewTimer; constructor(protected menuService: MenuService, protected injector: Injector) { } @@ -78,8 +77,8 @@ export class MenuComponent implements OnInit { sections.forEach((section: MenuSection) => { this.sectionInjectors.set(section.id, this.getSectionDataInjector(section)); this.getSectionComponent(section).pipe(first()).subscribe((constr) => this.sectionComponents.set(section.id, constr)); - }) - }) + }); + }); } /** diff --git a/src/app/shared/menu/menu.service.spec.ts b/src/app/shared/menu/menu.service.spec.ts index 0386e5a4d5..634120dd9c 100644 --- a/src/app/shared/menu/menu.service.spec.ts +++ b/src/app/shared/menu/menu.service.spec.ts @@ -23,6 +23,7 @@ import { ToggleMenuAction } from './menu.actions'; import { MenuSection, menusReducer } from './menu.reducer'; +import { storeModuleConfig } from '../../app.reducer'; describe('MenuService', () => { let service: MenuService; @@ -84,7 +85,7 @@ describe('MenuService', () => { init(); TestBed.configureTestingModule({ imports: [ - StoreModule.forRoot({ menus: menusReducer }) + StoreModule.forRoot({ menus: menusReducer }, storeModuleConfig) ], providers: [ provideMockStore({ initialState }), diff --git a/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts b/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts index 4097fb99c4..2c9927164a 100644 --- a/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts +++ b/src/app/shared/metadata-representation/metadata-representation-loader.component.spec.ts @@ -4,7 +4,7 @@ import { Context } from '../../core/shared/context.model'; import { MetadataRepresentation, MetadataRepresentationType } from '../../core/shared/metadata-representation/metadata-representation.model'; import { MetadataRepresentationLoaderComponent } from './metadata-representation-loader.component'; import { PlainTextMetadataListElementComponent } from '../object-list/metadata-representation-list-element/plain-text/plain-text-metadata-list-element.component'; -import { spyOnExported } from '../testing/utils'; +import { spyOnExported } from '../testing/utils.test'; import { MetadataRepresentationDirective } from './metadata-representation.directive'; import * as metadataRepresentationDecorator from './metadata-representation.decorator'; diff --git a/src/app/shared/mocks/mock-action.ts b/src/app/shared/mocks/action.mock.ts similarity index 61% rename from src/app/shared/mocks/mock-action.ts rename to src/app/shared/mocks/action.mock.ts index 0f619c8aff..e227946f64 100644 --- a/src/app/shared/mocks/mock-action.ts +++ b/src/app/shared/mocks/action.mock.ts @@ -1,6 +1,6 @@ import { Action } from '@ngrx/store'; -export class MockAction implements Action { +export class ActionMock implements Action { type = null; payload: {}; } diff --git a/src/app/shared/mocks/mock-active-router.ts b/src/app/shared/mocks/active-router.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-active-router.ts rename to src/app/shared/mocks/active-router.mock.ts diff --git a/src/app/shared/mocks/mock-admin-guard.service.ts b/src/app/shared/mocks/admin-guard.service.mock.ts similarity index 97% rename from src/app/shared/mocks/mock-admin-guard.service.ts rename to src/app/shared/mocks/admin-guard.service.mock.ts index fad2412cdc..99882e70ac 100644 --- a/src/app/shared/mocks/mock-admin-guard.service.ts +++ b/src/app/shared/mocks/admin-guard.service.mock.ts @@ -1,23 +1,23 @@ -import { Injectable } from '@angular/core'; -import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router'; - -import { hasValue } from '../empty.util'; - -@Injectable() -export class MockAdminGuard implements CanActivate, CanActivateChild { - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - // if being run in browser, enforce 'isAdmin' requirement - if (typeof window === 'object' && hasValue(window.localStorage)) { - if (window.localStorage.getItem('isAdmin') === 'true') { - return true; - } - return false; - } - return true; - } - - canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - return this.canActivate(route, state); - } -} +import { Injectable } from '@angular/core'; +import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router'; + +import { hasValue } from '../empty.util'; + +@Injectable() +export class MockAdminGuard implements CanActivate, CanActivateChild { + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + // if being run in browser, enforce 'isAdmin' requirement + if (typeof window === 'object' && hasValue(window.localStorage)) { + if (window.localStorage.getItem('isAdmin') === 'true') { + return true; + } + return false; + } + return true; + } + + canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + return this.canActivate(route, state); + } +} diff --git a/src/app/shared/mocks/mock-angulartics.service.ts b/src/app/shared/mocks/angulartics.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-angulartics.service.ts rename to src/app/shared/mocks/angulartics.service.mock.ts diff --git a/src/app/shared/mocks/mock-auth.service.ts b/src/app/shared/mocks/auth.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-auth.service.ts rename to src/app/shared/mocks/auth.service.mock.ts diff --git a/src/app/shared/mocks/mock-cookie.service.ts b/src/app/shared/mocks/cookie.service.mock.ts similarity index 92% rename from src/app/shared/mocks/mock-cookie.service.ts rename to src/app/shared/mocks/cookie.service.mock.ts index 14f8271fed..f94f3d4a7d 100644 --- a/src/app/shared/mocks/mock-cookie.service.ts +++ b/src/app/shared/mocks/cookie.service.mock.ts @@ -1,7 +1,7 @@ /** * Mock for [[CookieService]] */ -export class MockCookieService { +export class CookieServiceMock { cookies: Map; constructor(cookies: Map = new Map()) { diff --git a/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.spec.ts b/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.spec.ts index e0dae08470..c35713669f 100644 --- a/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.spec.ts +++ b/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.spec.ts @@ -1,36 +1,33 @@ import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { of as observableOf } from 'rxjs'; -import { GlobalConfig } from '../../../../config/global-config.interface'; import { RestRequestMethod } from '../../../core/data/rest-request-method'; import { EndpointMockingRestService } from './endpoint-mocking-rest.service'; -import { MockResponseMap } from './mocks/mock-response-map'; +import { ResponseMapMock } from './mocks/response-map.mock'; describe('EndpointMockingRestService', () => { let service: EndpointMockingRestService; - const serverHttpResponse: HttpResponse = { - body: { bar: false }, - headers: new HttpHeaders(), - statusText: '200' - } as HttpResponse; + let serverHttpResponse: HttpResponse; - const mockResponseMap: MockResponseMap = new Map([ - [ '/foo', { bar: true } ] - ]); + let mockResponseMap: ResponseMapMock; beforeEach(() => { - const EnvConfig = { - rest: { - nameSpace: '/api' - } - } as GlobalConfig; + serverHttpResponse = { + body: { bar: false }, + headers: new HttpHeaders(), + statusText: '200' + } as HttpResponse; + + mockResponseMap = new Map([ + [ '/foo', { bar: true } ] + ]); const httpStub = jasmine.createSpyObj('http', { get: observableOf(serverHttpResponse), request: observableOf(serverHttpResponse) }); - service = new EndpointMockingRestService(EnvConfig, mockResponseMap, httpStub); + service = new EndpointMockingRestService(mockResponseMap, httpStub); }); describe('get', () => { diff --git a/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.ts b/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.ts index b0e89b80b5..aa13b57d7b 100644 --- a/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.ts +++ b/src/app/shared/mocks/dspace-rest-v2/endpoint-mocking-rest.service.ts @@ -1,14 +1,14 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http' +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Inject, Injectable } from '@angular/core'; import { Observable, of as observableOf } from 'rxjs'; -import { GLOBAL_CONFIG, GlobalConfig } from '../../../../config'; import { isEmpty } from '../../empty.util'; import { RestRequestMethod } from '../../../core/data/rest-request-method'; import { DSpaceRESTV2Response } from '../../../core/dspace-rest-v2/dspace-rest-v2-response.model'; import { DSpaceRESTv2Service, HttpOptions } from '../../../core/dspace-rest-v2/dspace-rest-v2.service'; -import { MOCK_RESPONSE_MAP, MockResponseMap } from './mocks/mock-response-map'; +import { MOCK_RESPONSE_MAP, ResponseMapMock } from './mocks/response-map.mock'; import * as URL from 'url-parse'; +import { environment } from '../../../../environments/environment'; /** * Service to access DSpace's REST API. @@ -21,8 +21,7 @@ import * as URL from 'url-parse'; export class EndpointMockingRestService extends DSpaceRESTv2Service { constructor( - @Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig, - @Inject(MOCK_RESPONSE_MAP) protected mockResponseMap: MockResponseMap, + @Inject(MOCK_RESPONSE_MAP) protected mockResponseMap: ResponseMapMock, protected http: HttpClient ) { super(http); @@ -99,7 +98,7 @@ export class EndpointMockingRestService extends DSpaceRESTv2Service { */ private getMockData(urlStr: string): any { const url = new URL(urlStr); - const key = url.pathname.slice(this.EnvConfig.rest.nameSpace.length); + const key = url.pathname.slice(environment.rest.nameSpace.length); if (this.mockResponseMap.has(key)) { // parse and stringify to clone the object to ensure that any changes made // to it afterwards don't affect future calls diff --git a/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts b/src/app/shared/mocks/dspace-rest-v2/mocks/response-map.mock.ts similarity index 62% rename from src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts rename to src/app/shared/mocks/dspace-rest-v2/mocks/response-map.mock.ts index a7fab782da..8476217835 100644 --- a/src/app/shared/mocks/dspace-rest-v2/mocks/mock-response-map.ts +++ b/src/app/shared/mocks/dspace-rest-v2/mocks/response-map.mock.ts @@ -1,15 +1,15 @@ import { InjectionToken } from '@angular/core'; import mockSubmissionResponse from './mock-submission-response.json'; -export class MockResponseMap extends Map {}; +export class ResponseMapMock extends Map {}; -export const MOCK_RESPONSE_MAP: InjectionToken = new InjectionToken('mockResponseMap'); +export const MOCK_RESPONSE_MAP: InjectionToken = new InjectionToken('mockResponseMap'); /** * List of endpoints with their matching mock response * Note that this list is only used in development mode * In production the actual endpoints on the REST server will be called */ -export const mockResponseMap: MockResponseMap = new Map([ +export const mockResponseMap: ResponseMapMock = new Map([ // [ '/config/submissionforms/traditionalpageone', mockSubmissionResponse ] ]); diff --git a/src/app/shared/mocks/mock-form-builder-service.ts b/src/app/shared/mocks/form-builder-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-form-builder-service.ts rename to src/app/shared/mocks/form-builder-service.mock.ts diff --git a/src/app/shared/mocks/mock-form-models.ts b/src/app/shared/mocks/form-models.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-form-models.ts rename to src/app/shared/mocks/form-models.mock.ts diff --git a/src/app/shared/mocks/mock-form-operations-service.ts b/src/app/shared/mocks/form-operations-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-form-operations-service.ts rename to src/app/shared/mocks/form-operations-service.mock.ts diff --git a/src/app/shared/mocks/mock-form-service.ts b/src/app/shared/mocks/form-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-form-service.ts rename to src/app/shared/mocks/form-service.mock.ts diff --git a/src/app/shared/mocks/mock-host-window-service.ts b/src/app/shared/mocks/host-window-service.mock.ts similarity index 90% rename from src/app/shared/mocks/mock-host-window-service.ts rename to src/app/shared/mocks/host-window-service.mock.ts index a9be248240..4c8cd2b633 100644 --- a/src/app/shared/mocks/mock-host-window-service.ts +++ b/src/app/shared/mocks/host-window-service.mock.ts @@ -1,7 +1,7 @@ import {of as observableOf, Observable } from 'rxjs'; // declare a stub service -export class MockHostWindowService { +export class HostWindowServiceMock { private width: number; diff --git a/src/app/shared/mocks/mock-item.ts b/src/app/shared/mocks/item.mock.ts similarity index 97% rename from src/app/shared/mocks/mock-item.ts rename to src/app/shared/mocks/item.mock.ts index a5b6a45d4a..945b0f7816 100644 --- a/src/app/shared/mocks/mock-item.ts +++ b/src/app/shared/mocks/item.mock.ts @@ -3,7 +3,8 @@ import { BitstreamFormat } from '../../core/shared/bitstream-format.model'; import { Bitstream } from '../../core/shared/bitstream.model'; import { Item } from '../../core/shared/item.model'; -import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils'; +import { createPaginatedList } from '../testing/utils.test'; export const MockBitstreamFormat1: BitstreamFormat = Object.assign(new BitstreamFormat(), { shortDescription: 'Microsoft Word XML', @@ -82,7 +83,7 @@ export const MockBitstream2: Bitstream = Object.assign(new Bitstream(), { }); /* tslint:disable:no-shadowed-variable */ -export const MockItem: Item = Object.assign(new Item(), { +export const ItemMock: Item = Object.assign(new Item(), { handle: '10673/6', lastModified: '2017-04-24T19:44:08.178+0000', isArchived: true, diff --git a/src/app/shared/mocks/mock-link-service.ts b/src/app/shared/mocks/link-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-link-service.ts rename to src/app/shared/mocks/link-service.mock.ts diff --git a/src/app/shared/mocks/mock-metadata-service.ts b/src/app/shared/mocks/metadata-service.mock.ts similarity index 71% rename from src/app/shared/mocks/mock-metadata-service.ts rename to src/app/shared/mocks/metadata-service.mock.ts index 8456e92b92..5b2524b53a 100644 --- a/src/app/shared/mocks/mock-metadata-service.ts +++ b/src/app/shared/mocks/metadata-service.mock.ts @@ -1,5 +1,5 @@ -export class MockMetadataService { +export class MetadataServiceMock { // tslint:disable-next-line:no-empty public listenForRouteChange(): void { diff --git a/src/app/shared/mocks/mock-object-cache.service.ts b/src/app/shared/mocks/object-cache.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-object-cache.service.ts rename to src/app/shared/mocks/object-cache.service.mock.ts diff --git a/src/app/shared/mocks/mock-remote-data-build.service.ts b/src/app/shared/mocks/remote-data-build.service.mock.ts similarity index 97% rename from src/app/shared/mocks/mock-remote-data-build.service.ts rename to src/app/shared/mocks/remote-data-build.service.mock.ts index 2dff033a26..fa30282d6b 100644 --- a/src/app/shared/mocks/mock-remote-data-build.service.ts +++ b/src/app/shared/mocks/remote-data-build.service.mock.ts @@ -6,7 +6,7 @@ import { RemoteData } from '../../core/data/remote-data'; import { RequestEntry } from '../../core/data/request.reducer'; import { PageInfo } from '../../core/shared/page-info.model'; import { hasValue } from '../empty.util'; -import { createSuccessfulRemoteDataObject$ } from '../testing/utils'; +import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils'; export function getMockRemoteDataBuildService(toRemoteDataObservable$?: Observable>, buildList$?: Observable>>): RemoteDataBuildService { return { diff --git a/src/app/shared/mocks/mock-request.service.ts b/src/app/shared/mocks/request.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-request.service.ts rename to src/app/shared/mocks/request.service.mock.ts diff --git a/src/app/shared/mocks/mock-role-service.ts b/src/app/shared/mocks/role-service.mock.ts similarity index 97% rename from src/app/shared/mocks/mock-role-service.ts rename to src/app/shared/mocks/role-service.mock.ts index dad296f986..795db3aa57 100644 --- a/src/app/shared/mocks/mock-role-service.ts +++ b/src/app/shared/mocks/role-service.mock.ts @@ -2,7 +2,7 @@ import { Observable } from 'rxjs/internal/Observable'; import { RoleType } from '../../core/roles/role-types'; import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; -export class MockRoleService { +export class RoleServiceMock { _isSubmitter = new BehaviorSubject(true); _isController = new BehaviorSubject(true); diff --git a/src/app/shared/mocks/mock-router.ts b/src/app/shared/mocks/router.mock.ts similarity index 95% rename from src/app/shared/mocks/mock-router.ts rename to src/app/shared/mocks/router.mock.ts index fb475a0467..eb260af6b4 100644 --- a/src/app/shared/mocks/mock-router.ts +++ b/src/app/shared/mocks/router.mock.ts @@ -3,7 +3,7 @@ import { of as observableOf } from 'rxjs'; /** * Mock for [[RouterService]] */ -export class MockRouter { +export class RouterMock { public events = observableOf({}); public routerState = { snapshot: { diff --git a/src/app/shared/mocks/mock-scroll-to-service.ts b/src/app/shared/mocks/scroll-to-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-scroll-to-service.ts rename to src/app/shared/mocks/scroll-to-service.mock.ts diff --git a/src/app/shared/mocks/mock-search-service.ts b/src/app/shared/mocks/search-service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-search-service.ts rename to src/app/shared/mocks/search-service.mock.ts diff --git a/src/app/shared/mocks/mock-section-upload.service.ts b/src/app/shared/mocks/section-upload.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-section-upload.service.ts rename to src/app/shared/mocks/section-upload.service.mock.ts diff --git a/src/app/shared/mocks/mock-submission.ts b/src/app/shared/mocks/submission.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-submission.ts rename to src/app/shared/mocks/submission.mock.ts diff --git a/src/app/shared/testing/mock-translate-loader.ts b/src/app/shared/mocks/translate-loader.mock.ts similarity index 75% rename from src/app/shared/testing/mock-translate-loader.ts rename to src/app/shared/mocks/translate-loader.mock.ts index 529a257ec0..3251de9ea1 100644 --- a/src/app/shared/testing/mock-translate-loader.ts +++ b/src/app/shared/mocks/translate-loader.mock.ts @@ -1,7 +1,7 @@ import {of as observableOf, Observable } from 'rxjs'; import { TranslateLoader } from '@ngx-translate/core'; -export class MockTranslateLoader implements TranslateLoader { +export class TranslateLoaderMock implements TranslateLoader { getTranslation(lang: string): Observable { return observableOf({}); } diff --git a/src/app/shared/mocks/mock-translate.service.ts b/src/app/shared/mocks/translate.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-translate.service.ts rename to src/app/shared/mocks/translate.service.mock.ts diff --git a/src/app/shared/mocks/mock-uuid.service.ts b/src/app/shared/mocks/uuid.service.mock.ts similarity index 100% rename from src/app/shared/mocks/mock-uuid.service.ts rename to src/app/shared/mocks/uuid.service.mock.ts diff --git a/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts index 1cbfdb7c46..0b276625ba 100644 --- a/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts @@ -5,10 +5,10 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { of as observableOf } from 'rxjs'; import { ClaimedTaskActionsApproveComponent } from './claimed-task-actions-approve.component'; -import { MockTranslateLoader } from '../../../mocks/mock-translate-loader'; -import { ProcessTaskResponse } from '../../../../core/tasks/models/process-task-response'; +import { TranslateLoaderMock } from '../../../mocks/translate-loader.mock'; import { ClaimedTaskDataService } from '../../../../core/tasks/claimed-task-data.service'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; +import { ProcessTaskResponse } from '../../../../core/tasks/models/process-task-response'; let component: ClaimedTaskActionsApproveComponent; let fixture: ComponentFixture; @@ -25,7 +25,7 @@ describe('ClaimedTaskActionsApproveComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }) ], diff --git a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts index f30feb4163..35e7c4602f 100644 --- a/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/claimed-task-actions.component.spec.ts @@ -6,23 +6,23 @@ import { of as observableOf } from 'rxjs'; import { cold } from 'jasmine-marbles'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; -import { MockTranslateLoader } from '../../mocks/mock-translate-loader'; +import { TranslateLoaderMock } from '../../mocks/translate-loader.mock'; import { NotificationsService } from '../../notifications/notifications.service'; -import { NotificationsServiceStub } from '../../testing/notifications-service-stub'; -import { RouterStub } from '../../testing/router-stub'; +import { NotificationsServiceStub } from '../../testing/notifications-service.stub'; +import { RouterStub } from '../../testing/router.stub'; import { Item } from '../../../core/shared/item.model'; import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service'; import { ClaimedTaskActionsComponent } from './claimed-task-actions.component'; import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model'; import { WorkflowItem } from '../../../core/submission/models/workflowitem.model'; -import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../testing/utils'; -import { getMockSearchService } from '../../mocks/mock-search-service'; -import { getMockRequestService } from '../../mocks/mock-request.service'; +import { getMockSearchService } from '../../mocks/search-service.mock'; +import { getMockRequestService } from '../../mocks/request.service.mock'; import { RequestService } from '../../../core/data/request.service'; import { SearchService } from '../../../core/shared/search/search.service'; import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service'; import { WorkflowAction } from '../../../core/tasks/models/workflow-action-object.model'; import { VarDirective } from '../../utils/var.directive'; +import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../remote-data.utils'; let component: ClaimedTaskActionsComponent; let fixture: ComponentFixture; @@ -99,7 +99,7 @@ describe('ClaimedTaskActionsComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }) ], diff --git a/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts index 912671bd4b..705563941e 100644 --- a/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts @@ -4,9 +4,9 @@ import { By } from '@angular/platform-browser'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { ClaimedTaskActionsEditMetadataComponent } from './claimed-task-actions-edit-metadata.component'; -import { MockTranslateLoader } from '../../../mocks/mock-translate-loader'; import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; import { ClaimedTaskDataService } from '../../../../core/tasks/claimed-task-data.service'; +import { TranslateLoaderMock } from '../../../testing/translate-loader.mock'; let component: ClaimedTaskActionsEditMetadataComponent; let fixture: ComponentFixture; @@ -20,7 +20,7 @@ describe('ClaimedTaskActionsEditMetadataComponent', () => { TranslateModule.forRoot({ loader: { provide: TranslateLoader, - useClass: MockTranslateLoader + useClass: TranslateLoaderMock } }) ], diff --git a/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.html b/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.html index 7c7b83cd8a..0cb2871bf5 100644 --- a/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.html +++ b/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.html @@ -21,7 +21,7 @@ -
+