mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix tests
This commit is contained in:
@@ -3,15 +3,37 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
|
import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
import { SearchService } from "../../core/shared/search/search.service";
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from "../../shared/remote-data.utils";
|
||||||
|
import { buildPaginatedList } from "../../core/data/paginated-list.model";
|
||||||
|
import { AdminNotifySearchResult } from "./models/admin-notify-message-search-result.model";
|
||||||
|
import { AdminNotifyMessage } from "./models/admin-notify-message.model";
|
||||||
|
|
||||||
describe('AdminNotifyDashboardComponent', () => {
|
describe('AdminNotifyDashboardComponent', () => {
|
||||||
let component: AdminNotifyDashboardComponent;
|
let component: AdminNotifyDashboardComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifyDashboardComponent>;
|
let fixture: ComponentFixture<AdminNotifyDashboardComponent>;
|
||||||
|
|
||||||
|
let item1;
|
||||||
|
let item2;
|
||||||
|
let item3;
|
||||||
|
let searchResult1;
|
||||||
|
let searchResult2;
|
||||||
|
let searchResult3;
|
||||||
|
let results;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
item1 = Object.assign(new AdminNotifyMessage(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' });
|
||||||
|
item2 = Object.assign(new AdminNotifyMessage(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' });
|
||||||
|
item3 = Object.assign(new AdminNotifyMessage(), { uuid: 'c3bcbff5-ec0c-4831-8e4c-94b9c933ccac' });
|
||||||
|
searchResult1 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item1 });
|
||||||
|
searchResult2 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item2 });
|
||||||
|
searchResult3 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item3 });
|
||||||
|
results = buildPaginatedList(undefined, [searchResult1, searchResult2, searchResult3]);
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), NgbNavModule],
|
imports: [TranslateModule.forRoot(), NgbNavModule],
|
||||||
declarations: [ AdminNotifyDashboardComponent ]
|
declarations: [ AdminNotifyDashboardComponent ],
|
||||||
|
providers: [{ provide: SearchService, useValue: { search: () => createSuccessfulRemoteDataObject$(results)}}]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
@@ -83,6 +83,7 @@ export class AdminNotifyDashboardComponent implements OnInit{
|
|||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
boxes: row.boxes.map(rowBox => {
|
boxes: row.boxes.map(rowBox => {
|
||||||
|
// TODO remove aggregate once rest is updated
|
||||||
if (rowBox.isRowAggregateCount) {
|
if (rowBox.isRowAggregateCount) {
|
||||||
const currentRowBoxesWithCount = row.boxes.filter(box => !box.isRowAggregateCount)
|
const currentRowBoxesWithCount = row.boxes.filter(box => !box.isRowAggregateCount)
|
||||||
.map(notAggregateBox => {
|
.map(notAggregateBox => {
|
||||||
|
@@ -1,19 +1,33 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { NotificationBoxComponent } from './notification-box.component';
|
import { NotificationBoxComponent } from './notification-box.component';
|
||||||
|
import { TranslateModule } from "@ngx-translate/core";
|
||||||
|
import {
|
||||||
|
AdminNotifyMetricsBox
|
||||||
|
} from "../../admin/admin-notify-dashboard/admin-notify-metrics/admin-notify-metrics.model";
|
||||||
|
|
||||||
describe('NotificationBoxComponent', () => {
|
describe('NotificationBoxComponent', () => {
|
||||||
let component: NotificationBoxComponent;
|
let component: NotificationBoxComponent;
|
||||||
let fixture: ComponentFixture<NotificationBoxComponent>;
|
let fixture: ComponentFixture<NotificationBoxComponent>;
|
||||||
|
let mockBoxConfig: AdminNotifyMetricsBox;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
mockBoxConfig = {
|
||||||
|
"color": "#D4EDDA",
|
||||||
|
"title": "admin-notify-dashboard.delivered",
|
||||||
|
"config": "NOTIFY.outgoing.delivered",
|
||||||
|
"count": 79
|
||||||
|
}
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot()],
|
||||||
declarations: [ NotificationBoxComponent ]
|
declarations: [ NotificationBoxComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(NotificationBoxComponent);
|
fixture = TestBed.createComponent(NotificationBoxComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
component.boxConfig = mockBoxConfig;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user