forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
108588: Created separate section for communities & collections browse…
… sections
- Loading branch information
1 parent
33f61a1
commit aad8f15
Showing
7 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/app/shared/comcol/sections/comcol-browse-by/comcol-browse-by.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<ds-browse-by-switcher [browseByType]="browseByType$ | async"> | ||
</ds-browse-by-switcher> |
Empty file.
70 changes: 70 additions & 0 deletions
70
src/app/shared/comcol/sections/comcol-browse-by/comcol-browse-by.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// eslint-disable-next-line max-classes-per-file | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ComcolBrowseByComponent } from './comcol-browse-by.component'; | ||
import { rendersBrowseBy } from '../../../../browse-by/browse-by-switcher/browse-by-decorator'; | ||
import { BrowseByDataType } from '../../../../browse-by/browse-by-switcher/browse-by-data-type'; | ||
import { Component } from '@angular/core'; | ||
import { AbstractBrowseByTypeComponent } from '../../../../browse-by/abstract-browse-by-type.component'; | ||
import { BrowseDefinition } from '../../../../core/shared/browse-definition.model'; | ||
import { ActivatedRouteStub } from '../../../testing/active-router.stub'; | ||
import { ThemeService } from '../../../theme-support/theme.service'; | ||
import { getMockThemeService } from '../../../mocks/theme-service.mock'; | ||
import { BrowseBySwitcherComponent } from '../../../../browse-by/browse-by-switcher/browse-by-switcher.component'; | ||
import { DynamicComponentLoaderDirective } from '../../../abstract-component-loader/dynamic-component-loader.directive'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
@rendersBrowseBy('ComcolBrowseByComponent' as BrowseByDataType) | ||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: '', | ||
template: '<span id="ComcolBrowseByComponent"></span>', | ||
}) | ||
class BrowseByTestComponent extends AbstractBrowseByTypeComponent { | ||
} | ||
|
||
class TestBrowseByPageBrowseDefinition extends BrowseDefinition { | ||
getRenderType(): BrowseByDataType { | ||
return 'ComcolBrowseByComponent' as BrowseByDataType; | ||
} | ||
} | ||
|
||
describe('ComcolBrowseByComponent', () => { | ||
let component: ComcolBrowseByComponent; | ||
let fixture: ComponentFixture<ComcolBrowseByComponent>; | ||
|
||
let activatedRoute: ActivatedRouteStub; | ||
let themeService: ThemeService; | ||
|
||
beforeEach(async () => { | ||
activatedRoute = new ActivatedRouteStub(); | ||
themeService = getMockThemeService(); | ||
|
||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
ComcolBrowseByComponent, | ||
BrowseBySwitcherComponent, | ||
DynamicComponentLoaderDirective, | ||
], | ||
providers: [ | ||
BrowseByTestComponent, | ||
{ provide: ActivatedRoute, useValue: activatedRoute }, | ||
{ provide: ThemeService, useValue: themeService }, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ComcolBrowseByComponent); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it('should create the correct browse section based on the route browseDefinition', () => { | ||
activatedRoute.testData = { | ||
browseDefinition: new TestBrowseByPageBrowseDefinition(), | ||
}; | ||
|
||
fixture.detectChanges(); | ||
|
||
expect(component).toBeTruthy(); | ||
expect(fixture.debugElement.query(By.css('#ComcolBrowseByComponent'))).not.toBeNull(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
src/app/shared/comcol/sections/comcol-browse-by/comcol-browse-by.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { BrowseByDataType } from '../../../../browse-by/browse-by-switcher/browse-by-data-type'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { map } from 'rxjs/operators'; | ||
import { BrowseDefinition } from '../../../../core/shared/browse-definition.model'; | ||
|
||
@Component({ | ||
selector: 'ds-comcol-browse-by', | ||
templateUrl: './comcol-browse-by.component.html', | ||
styleUrls: ['./comcol-browse-by.component.scss'], | ||
}) | ||
export class ComcolBrowseByComponent implements OnInit { | ||
|
||
browseByType$: Observable<BrowseByDataType>; | ||
|
||
constructor( | ||
protected route: ActivatedRoute, | ||
) { | ||
} | ||
|
||
/** | ||
* Fetch the correct browse-by component by using the relevant config from the route data | ||
*/ | ||
ngOnInit(): void { | ||
this.browseByType$ = this.route.data.pipe( | ||
map((data: { browseDefinition: BrowseDefinition }) => data.browseDefinition.getRenderType()), | ||
); | ||
} | ||
|
||
} |