diff --git a/src/app/submission/form/collection/submission-form-collection.component.spec.ts b/src/app/submission/form/collection/submission-form-collection.component.spec.ts index 28df100c00..679500a670 100644 --- a/src/app/submission/form/collection/submission-form-collection.component.spec.ts +++ b/src/app/submission/form/collection/submission-form-collection.component.spec.ts @@ -24,6 +24,7 @@ import { PaginatedList } from '../../../core/data/paginated-list'; import { PageInfo } from '../../../core/shared/page-info.model'; import { Collection } from '../../../core/shared/collection.model'; import { createTestComponent } from '../../../shared/testing/utils'; +import { cold } from 'jasmine-marbles'; const subcommunities = [Object.assign(new Community(), { name: 'SubCommunity 1', @@ -288,11 +289,15 @@ describe('SubmissionFormCollectionComponent Component', () => { currentCollectionId: new SimpleChange(null, collectionId, true) }); - comp.searchListCollection$.pipe( - filter(() => !comp.disabled$.getValue()) - ).subscribe((list) => { - expect(list).toEqual(mockCollectionList); - }) + expect(comp.searchListCollection$).toBeObservable(cold('(ab)', { + a: [], + b: mockCollectionList + })); + + expect(comp.selectedCollectionName$).toBeObservable(cold('(ab|)', { + a: '', + b: 'Community 1-Collection 1' + })); }); it('should show only the searched collection', () => { @@ -306,7 +311,8 @@ describe('SubmissionFormCollectionComponent Component', () => { filter(() => !comp.disabled$.getValue()) ).subscribe((list) => { expect(list).toEqual([mockCollectionList[3]]); - }) + }); + }); it('should emit collectionChange event when selecting a new collection', () => { @@ -321,7 +327,9 @@ describe('SubmissionFormCollectionComponent Component', () => { expect(comp.collectionChange.emit).toHaveBeenCalledWith(submissionRestResponse[0]); expect(submissionServiceStub.changeSubmissionCollection).toHaveBeenCalled(); expect(comp.selectedCollectionId).toBe(mockCollectionList[1].collection.id); - expect(comp.selectedCollectionName).toBe(mockCollectionList[1].collection.name); + expect(comp.selectedCollectionName$).toBeObservable(cold('(a|)', { + a: mockCollectionList[1].collection.name + })); }); diff --git a/src/app/submission/form/collection/submission-form-collection.component.ts b/src/app/submission/form/collection/submission-form-collection.component.ts index 94b05ceefc..fa54280aae 100644 --- a/src/app/submission/form/collection/submission-form-collection.component.ts +++ b/src/app/submission/form/collection/submission-form-collection.component.ts @@ -67,7 +67,6 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit { public searchField: FormControl = new FormControl(); public searchListCollection$: Observable; public selectedCollectionId: string; - public selectedCollectionName: string; public selectedCollectionName$: Observable; protected pathCombiner: JsonPatchOperationPathCombiner; @@ -114,8 +113,8 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit { mergeMap((collections: RemoteData>) => collections.payload.page), filter((collectionData: Collection) => isNotEmpty(collectionData)), map((collectionData: Collection) => ({ - communities: [{id: communityData.id, name: communityData.name}], - collection: {id: collectionData.id, name: collectionData.name} + communities: [{ id: communityData.id, name: communityData.name }], + collection: { id: collectionData.id, name: collectionData.name } })) ); }), @@ -173,7 +172,6 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit { 'collection') .subscribe((submissionObject: SubmissionObject[]) => { this.selectedCollectionId = event.collection.id; - this.selectedCollectionName = event.collection.name; this.selectedCollectionName$ = observableOf(event.collection.name); this.collectionChange.emit(submissionObject[0]); this.submissionService.changeSubmissionCollection(this.submissionId, event.collection.id); diff --git a/src/app/submission/sections/license/section-license.component.spec.ts b/src/app/submission/sections/license/section-license.component.spec.ts index b90f4ccd0f..e0d36bcc96 100644 --- a/src/app/submission/sections/license/section-license.component.spec.ts +++ b/src/app/submission/sections/license/section-license.component.spec.ts @@ -37,6 +37,7 @@ import { Collection } from '../../../core/shared/collection.model'; import { RemoteData } from '../../../core/data/remote-data'; import { License } from '../../../core/shared/license.model'; import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model'; +import { cold } from 'jasmine-marbles'; function getMockSubmissionFormsConfigService(): SubmissionFormsConfigService { return jasmine.createSpyObj('FormOperationsService', { @@ -205,7 +206,10 @@ describe('LicenseSectionComponent test suite', () => { expect(compAsAny.subs.length).toBe(2); expect(comp.formModel).toBeDefined(); expect(model.value).toBeFalsy(); - expect(comp.licenseText).toBe(licenseText); + expect(comp.licenseText$).toBeObservable(cold('(ab|)', { + a: '', + b: licenseText + })); }); it('should set checkbox value to true', () => { @@ -228,7 +232,10 @@ describe('LicenseSectionComponent test suite', () => { expect(compAsAny.subs.length).toBe(2); expect(comp.formModel).toBeDefined(); expect(model.value).toBeTruthy(); - expect(comp.licenseText).toBe(licenseText); + expect(comp.licenseText$).toBeObservable(cold('(ab|)', { + a: '', + b: licenseText + })); }); it('should set section errors properly', () => {