Skip to content

Commit 26909c8

Browse files
Mattia VianelliMattia Vianelli
authored andcommitted
DSC-2715 Provided tests
1 parent f54a69c commit 26909c8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/app/submission/form/submission-form.component.spec.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
22
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
3+
import { By } from '@angular/platform-browser';
34

45
import { of as observableOf } from 'rxjs';
56
import { cold, getTestScheduler } from 'jasmine-marbles';
@@ -259,6 +260,44 @@ describe('SubmissionFormComponent Component', () => {
259260
done();
260261
});
261262

263+
describe('submission legend', () => {
264+
beforeEach(() => {
265+
comp.collectionId = collectionId;
266+
comp.submissionId = submissionId;
267+
comp.submissionDefinition = submissionDefinition;
268+
comp.selfUrl = selfUrl;
269+
comp.sections = sectionsData;
270+
comp.item = new Item();
271+
comp.entityType = 'publication';
272+
submissionServiceStub.getSubmissionObject.and.returnValue(observableOf(submissionState));
273+
submissionServiceStub.getSubmissionSections.and.returnValue(observableOf(sectionsList));
274+
275+
spyOn(comp, 'isLoading').and.returnValue(observableOf(false));
276+
277+
comp.uploadEnabled$ = observableOf(false);
278+
});
279+
280+
it('should display submission legend when shouldShowLegend is true', () => {
281+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(true);
282+
283+
fixture.detectChanges();
284+
285+
const legendElement = fixture.debugElement.query(By.css('ds-submission-legend'));
286+
expect(legendElement).toBeTruthy();
287+
expect(legendElement.nativeElement.classList.contains('submission-form-header-legend')).toBe(true);
288+
});
289+
290+
it('should not display submission legend when shouldShowLegend is false', () => {
291+
spyOnProperty(comp, 'shouldShowLegend', 'get').and.returnValue(false);
292+
293+
fixture.detectChanges();
294+
295+
const legendElement = fixture.debugElement.query(By.css('ds-submission-legend'));
296+
expect(legendElement).toBeNull();
297+
});
298+
299+
});
300+
262301
});
263302
});
264303

0 commit comments

Comments
 (0)