Skip to content

Commit

Permalink
[CST-12500] Unit tests SubmissionSectionCoarNotifyComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaismailati committed Nov 6, 2023
1 parent dd0dfba commit 546c892
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { QaEventNotificationComponent } from './qa-event-notification.component';
import { QualityAssuranceSourceDataService } from '../../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
import { createPaginatedList } from '../../../shared/testing/utils.test';
import { QualityAssuranceSourceObject } from '../../../core/suggestion-notifications/qa/models/quality-assurance-source.model';
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
import { TranslateModule } from '@ngx-translate/core';
import { CommonModule } from '@angular/common';
import { SplitPipe } from '../../../shared/utils/split.pipe';
import { RequestService } from '../../../core/data/request.service';
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { provideMockStore } from '@ngrx/store/testing';
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { HALEndpointServiceStub } from '../../../shared/testing/hal-endpoint-service.stub';

describe('QaEventNotificationComponent', () => {
let component: QaEventNotificationComponent;
let fixture: ComponentFixture<QaEventNotificationComponent>;

let qualityAssuranceSourceDataServiceStub: any;

const obj = createSuccessfulRemoteDataObject$(createPaginatedList([new QualityAssuranceSourceObject()]));
const item = Object.assign({ uuid: '1234' });

beforeEach(async () => {
qualityAssuranceSourceDataServiceStub = {
getSourcesByTarget: () => obj
};
await TestBed.configureTestingModule({
declarations: [ QaEventNotificationComponent ]
imports: [CommonModule, TranslateModule.forRoot()],
declarations: [QaEventNotificationComponent, SplitPipe],
providers: [
{ provide: QualityAssuranceSourceDataService, useValue: qualityAssuranceSourceDataServiceStub },
{ provide: RequestService, useValue: {} },
{ provide: NotificationsService, useValue: {} },
{ provide: HALEndpointService, useValue: new HALEndpointServiceStub('test')},
ObjectCacheService,
RemoteDataBuildService,
provideMockStore({})
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(QaEventNotificationComponent);
component = fixture.componentInstance;
component.item = item;
fixture.detectChanges();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { getFirstCompletedRemoteData, getPaginatedListPayload, getRemoteDataPayload } from '../../../core/shared/operators';
import { Observable, tap } from 'rxjs';
import { Observable } from 'rxjs';
import { AlertType } from '../../../shared/alert/aletr-type';
import { FindListOptions } from '../../../core/data/find-list-options.model';
import { RequestParam } from '../../../core/cache/models/request-param.model';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MyDspaceQaEventsNotificationsComponent } from './my-dspace-qa-events-notifications.component';
import { QualityAssuranceSourceDataService } from '../../core/suggestion-notifications/qa/source/quality-assurance-source-data.service';
import { createSuccessfulRemoteDataObject$ } from 'src/app/shared/remote-data.utils';
import { createPaginatedList } from 'src/app/shared/testing/utils.test';
import { QualityAssuranceSourceObject } from 'src/app/core/suggestion-notifications/qa/models/quality-assurance-source.model';

describe('MyDspaceQaEventsNotificationsComponent', () => {
let component: MyDspaceQaEventsNotificationsComponent;
let fixture: ComponentFixture<MyDspaceQaEventsNotificationsComponent>;

let qualityAssuranceSourceDataServiceStub: any;
const obj = createSuccessfulRemoteDataObject$(createPaginatedList([new QualityAssuranceSourceObject()]));

beforeEach(async () => {
qualityAssuranceSourceDataServiceStub = {
getSources: () => obj
};
await TestBed.configureTestingModule({
declarations: [ MyDspaceQaEventsNotificationsComponent ]
declarations: [ MyDspaceQaEventsNotificationsComponent ],
providers: [
{ provide: QualityAssuranceSourceDataService, useValue: qualityAssuranceSourceDataServiceStub }
]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container-fluid">
<ng-container *ngIf="patterns.length > 0">
<ng-container *ngIf="patterns?.length > 0">
<div *ngFor="let pattern of patterns; let i = index" class="col">
<label class="row col-form-label"
>
Expand Down Expand Up @@ -116,7 +116,7 @@
</div>
</div>
</ng-container>
<ng-container *ngIf="patterns.length === 0">
<ng-container *ngIf="patterns?.length === 0">
<p>
{{'submission.section.section-coar-notify.info.no-pattern' | translate }}
</p>
Expand Down
Loading

0 comments on commit 546c892

Please sign in to comment.