Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd6c5b7
commit 752ada3
Showing
33 changed files
with
1,256 additions
and
19 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
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
Empty file.
109 changes: 109 additions & 0 deletions
109
.../+statistics-page/collection-statistics-page/collection-statistics-page.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,109 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { CollectionStatisticsPageComponent } from './collection-statistics-page.component'; | ||
import { StatisticsTableComponent } from '../statistics-table/statistics-table.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { UsageReportService } from '../../core/submission/usage-report-data.service'; | ||
import { of as observableOf } from 'rxjs'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
import { Collection } from '../../core/shared/collection.model'; | ||
import { DebugElement } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { UsageReport } from '../../core/statistics/models/usage-report.model'; | ||
import { SharedModule } from '../../shared/shared.module'; | ||
import { CommonModule } from '@angular/common'; | ||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; | ||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; | ||
|
||
describe('CollectionStatisticsPageComponent', () => { | ||
|
||
let component: CollectionStatisticsPageComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<CollectionStatisticsPageComponent>; | ||
|
||
beforeEach(async(() => { | ||
|
||
const activatedRoute = { | ||
data: observableOf({ | ||
scope: new RemoteData( | ||
false, | ||
false, | ||
true, | ||
undefined, | ||
Object.assign(new Collection(), { | ||
id: 'collection_id', | ||
}), | ||
) | ||
}) | ||
}; | ||
|
||
const router = { | ||
}; | ||
|
||
const usageReportService = { | ||
getStatistic: (scope, type) => undefined, | ||
}; | ||
|
||
spyOn(usageReportService, 'getStatistic').and.callFake( | ||
(scope, type) => observableOf( | ||
Object.assign( | ||
new UsageReport(), { | ||
id: `${scope}-${type}-report`, | ||
points: [], | ||
} | ||
) | ||
) | ||
); | ||
|
||
const nameService = { | ||
getName: () => observableOf('test dso name'), | ||
}; | ||
|
||
TestBed.configureTestingModule({ | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
CommonModule, | ||
SharedModule, | ||
], | ||
declarations: [ | ||
CollectionStatisticsPageComponent, | ||
StatisticsTableComponent, | ||
], | ||
providers: [ | ||
{ provide: ActivatedRoute, useValue: activatedRoute }, | ||
{ provide: Router, useValue: router }, | ||
{ provide: UsageReportService, useValue: usageReportService }, | ||
{ provide: DSpaceObjectDataService, useValue: {} }, | ||
{ provide: DSONameService, useValue: nameService }, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CollectionStatisticsPageComponent); | ||
component = fixture.componentInstance; | ||
de = fixture.debugElement; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should resolve to the correct collection', () => { | ||
expect(de.query(By.css('.header')).nativeElement.id) | ||
.toEqual('collection_id'); | ||
}); | ||
|
||
it('should show a statistics table for each usage report', () => { | ||
expect(de.query(By.css('ds-statistics-table.collection_id-TotalVisits-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.collection_id-TotalVisitsPerMonth-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.collection_id-TopCountries-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.collection_id-TopCities-report')).nativeElement) | ||
.toBeTruthy(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
src/app/+statistics-page/collection-statistics-page/collection-statistics-page.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,41 @@ | ||
import { Component } from '@angular/core'; | ||
import { StatisticsPageComponent } from '../statistics-page/statistics-page.component'; | ||
import { UsageReportService } from '../../core/submission/usage-report-data.service'; | ||
import { ActivatedRoute , Router} from '@angular/router'; | ||
import { Collection } from '../../core/shared/collection.model'; | ||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; | ||
|
||
/** | ||
* Component representing the statistics page for a collection. | ||
*/ | ||
@Component({ | ||
selector: 'ds-collection-statistics-page', | ||
templateUrl: '../statistics-page/statistics-page.component.html', | ||
styleUrls: ['./collection-statistics-page.component.scss'] | ||
}) | ||
export class CollectionStatisticsPageComponent extends StatisticsPageComponent<Collection> { | ||
|
||
/** | ||
* The report types to show on this statistics page. | ||
*/ | ||
types: string[] = [ | ||
'TotalVisits', | ||
'TotalVisitsPerMonth', | ||
'TopCountries', | ||
'TopCities', | ||
]; | ||
|
||
constructor( | ||
protected route: ActivatedRoute, | ||
protected router: Router, | ||
protected usageReportService: UsageReportService, | ||
protected nameService: DSONameService, | ||
) { | ||
super( | ||
route, | ||
router, | ||
usageReportService, | ||
nameService, | ||
); | ||
} | ||
} |
Empty file.
109 changes: 109 additions & 0 deletions
109
...pp/+statistics-page/community-statistics-page/community-statistics-page.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,109 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { CommunityStatisticsPageComponent } from './community-statistics-page.component'; | ||
import { StatisticsTableComponent } from '../statistics-table/statistics-table.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { UsageReportService } from '../../core/submission/usage-report-data.service'; | ||
import { of as observableOf } from 'rxjs'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
import { Community } from '../../core/shared/community.model'; | ||
import { DebugElement } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { UsageReport } from '../../core/statistics/models/usage-report.model'; | ||
import { SharedModule } from '../../shared/shared.module'; | ||
import { CommonModule } from '@angular/common'; | ||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; | ||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; | ||
|
||
describe('CommunityStatisticsPageComponent', () => { | ||
|
||
let component: CommunityStatisticsPageComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<CommunityStatisticsPageComponent>; | ||
|
||
beforeEach(async(() => { | ||
|
||
const activatedRoute = { | ||
data: observableOf({ | ||
scope: new RemoteData( | ||
false, | ||
false, | ||
true, | ||
undefined, | ||
Object.assign(new Community(), { | ||
id: 'community_id', | ||
}), | ||
) | ||
}) | ||
}; | ||
|
||
const router = { | ||
}; | ||
|
||
const usageReportService = { | ||
getStatistic: (scope, type) => undefined, | ||
}; | ||
|
||
spyOn(usageReportService, 'getStatistic').and.callFake( | ||
(scope, type) => observableOf( | ||
Object.assign( | ||
new UsageReport(), { | ||
id: `${scope}-${type}-report`, | ||
points: [], | ||
} | ||
) | ||
) | ||
); | ||
|
||
const nameService = { | ||
getName: () => observableOf('test dso name'), | ||
}; | ||
|
||
TestBed.configureTestingModule({ | ||
imports: [ | ||
TranslateModule.forRoot(), | ||
CommonModule, | ||
SharedModule, | ||
], | ||
declarations: [ | ||
CommunityStatisticsPageComponent, | ||
StatisticsTableComponent, | ||
], | ||
providers: [ | ||
{ provide: ActivatedRoute, useValue: activatedRoute }, | ||
{ provide: Router, useValue: router }, | ||
{ provide: UsageReportService, useValue: usageReportService }, | ||
{ provide: DSpaceObjectDataService, useValue: {} }, | ||
{ provide: DSONameService, useValue: nameService }, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CommunityStatisticsPageComponent); | ||
component = fixture.componentInstance; | ||
de = fixture.debugElement; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should resolve to the correct community', () => { | ||
expect(de.query(By.css('.header')).nativeElement.id) | ||
.toEqual('community_id'); | ||
}); | ||
|
||
it('should show a statistics table for each usage report', () => { | ||
expect(de.query(By.css('ds-statistics-table.community_id-TotalVisits-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.community_id-TotalVisitsPerMonth-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.community_id-TopCountries-report')).nativeElement) | ||
.toBeTruthy(); | ||
expect(de.query(By.css('ds-statistics-table.community_id-TopCities-report')).nativeElement) | ||
.toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.