|
1 | 1 | import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core'; |
2 | 2 | import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing'; |
| 3 | +import { By } from '@angular/platform-browser'; |
3 | 4 |
|
4 | 5 | import { of as observableOf } from 'rxjs'; |
5 | 6 | import { cold, getTestScheduler } from 'jasmine-marbles'; |
@@ -259,6 +260,44 @@ describe('SubmissionFormComponent Component', () => { |
259 | 260 | done(); |
260 | 261 | }); |
261 | 262 |
|
| 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 | + |
262 | 301 | }); |
263 | 302 | }); |
264 | 303 |
|
|
0 commit comments