diff --git a/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.spec.ts b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.spec.ts index 91c264cd0f..628dd545df 100644 --- a/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.spec.ts +++ b/src/app/+collection-page/edit-collection-page/collection-curate/collection-curate.component.spec.ts @@ -17,7 +17,7 @@ describe('CollectionCurateComponent', () => { let dsoNameService; const collection = Object.assign(new Collection(), { - handle: '123456789/1', metadata: {'dc.title': ['Collection Name']} + metadata: {'dc.title': ['Collection Name'], 'dc.identifier.uri': [ { value: '123456789/1'}]} }); beforeEach(async(() => { diff --git a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.spec.ts b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.spec.ts index 42dc0f08a9..3217fee3c1 100644 --- a/src/app/+community-page/edit-community-page/community-curate/community-curate.component.spec.ts +++ b/src/app/+community-page/edit-community-page/community-curate/community-curate.component.spec.ts @@ -17,7 +17,7 @@ describe('CommunityCurateComponent', () => { let dsoNameService; const community = Object.assign(new Community(), { - handle: '123456789/1', metadata: {'dc.title': ['Community Name']} + metadata: {'dc.title': ['Community Name'], 'dc.identifier.uri': [ { value: '123456789/1'}]} }); beforeEach(async(() => { diff --git a/src/app/core/shared/collection.model.spec.ts b/src/app/core/shared/collection.model.spec.ts new file mode 100644 index 0000000000..6c2f015b5b --- /dev/null +++ b/src/app/core/shared/collection.model.spec.ts @@ -0,0 +1,31 @@ +import {Collection} from './collection.model'; + +fdescribe('Collection', () => { + + fdescribe('Collection handle value', () => { + + let metadataValue; + let handleValue; + + beforeEach(() => { + metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]}; + handleValue = '11111111111/1'; + }) + + it('should return the handle value from metadata', () => { + const community = Object.assign(new Collection(), { metadata: metadataValue }); + expect(community.handle).toEqual('123456789/1'); + }); + + it('should return the handle value from metadata even when the handle field is provided', () => { + const community = Object.assign(new Collection(), { handle: handleValue, metadata: metadataValue }); + expect(community.handle).toEqual('123456789/1'); + }); + + it('should return undefined if the handle value from metadata is not present', () => { + const community = Object.assign(new Collection(), { handle: handleValue }); + expect(community.handle).toEqual(undefined); + }); + }); + +}); diff --git a/src/app/core/shared/community.model.spec.ts b/src/app/core/shared/community.model.spec.ts new file mode 100644 index 0000000000..3822509720 --- /dev/null +++ b/src/app/core/shared/community.model.spec.ts @@ -0,0 +1,31 @@ +import {Community} from './community.model'; + +fdescribe('Community', () => { + + fdescribe('Community handle value', () => { + + let metadataValue; + let handleValue; + + beforeEach(() => { + metadataValue = {'dc.identifier.uri': [ { value: '123456789/1'}]}; + handleValue = '11111111111/1'; + }) + + it('should return the handle value from metadata', () => { + const community = Object.assign(new Community(), { metadata: metadataValue }); + expect(community.handle).toEqual('123456789/1'); + }); + + it('should return the handle value from metadata even when the handle field is provided', () => { + const community = Object.assign(new Community(), { handle: handleValue, metadata: metadataValue }); + expect(community.handle).toEqual('123456789/1'); + }); + + it('should return undefined if the handle value from metadata is not present', () => { + const community = Object.assign(new Community(), { handle: handleValue }); + expect(community.handle).toEqual(undefined); + }); + }); + +});