Skip to content

Commit

Permalink
Merge pull request #810 from CSCfi/test
Browse files Browse the repository at this point in the history
Merge test to stable v0.9.40-rc1
  • Loading branch information
tahme authored Apr 30, 2021
2 parents a057331 + 2f6f5f9 commit fde3861
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
40 changes: 40 additions & 0 deletions etsin_finder/frontend/__tests__/utils/cite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ const organizationDataset = {
identifier: 'metax_identifier_for_this_dataset',
}

const publisherSuborganizationDataset = {
research_dataset: {
creator: [{ name: { en: 'Creator', fi: 'Creator' } }],
publisher: {
name: { en: 'Suborganization', fi: 'Joku aliorganisaatio' },
'@type': 'Organization',
is_part_of: {
name: { en: 'Top organization', fi: 'Pääorganisaatio' },
'@type': 'Organization',
},
},
issued: '2021-02-23',
title: { fi: 'Julkaisun nimi', en: 'Publication title' },
preferred_identifier: 'urn:nbn:fi:att:feedc0de',
},
identifier: 'metax_identifier_for_this_dataset',
}

const doiDataset = {
research_dataset: {
...organizationDataset.research_dataset,
Expand Down Expand Up @@ -165,6 +183,12 @@ describe('Citation styles', () => {
'(2021). Publication title. Publisher. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})

it('should render citation for dataset published by a suborganization', () => {
c(publisherSuborganizationDataset).should.eq(
'Creator. (2021). Publication title. Top organization, Suborganization. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})
})

describe('Chicago', () => {
Expand Down Expand Up @@ -222,6 +246,12 @@ describe('Citation styles', () => {
'Eka, Tyyppi, Tyyppi Toka, Tyyppi Kolmas, Tyyppi Neljäs, Tyyppi Viides, Tyyppi Kuudes, Tyyppi Seitsemäs, et al. 2021. ”Publication title”. Publisher. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})

it('should render citation for dataset published by a suborganization', () => {
c(publisherSuborganizationDataset).should.eq(
'Creator. 2021. ”Publication title”. Top organization, Suborganization. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})
})

describe('MLA', () => {
Expand Down Expand Up @@ -279,6 +309,12 @@ describe('Citation styles', () => {
'Eka, Tyyppi, et al. ”Publication title”. Publisher, 2021. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})

it('should render citation for dataset published by a suborganization', () => {
c(publisherSuborganizationDataset).should.eq(
'Creator. ”Publication title”. Top organization, Suborganization, 2021. http://urn.fi/urn:nbn:fi:att:feedc0de'
)
})
})
})

Expand All @@ -292,6 +328,10 @@ describe('Utils', () => {
getNameInitials('Mauri Antero Numminen').should.eq('Numminen, M. A.')
})

it('should ignore whitespace around name', () => {
getNameInitials(' Mauri Antero Numminen ').should.eq('Numminen, M. A.')
})

it('should leave multi-part last name unchanged', () => {
getNameInitials('Johannes Diderik van der Waals').should.eq('van der Waals, J. D.')
})
Expand Down
15 changes: 12 additions & 3 deletions etsin_finder/frontend/js/components/dataset/citation/cite/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const romanNumeralMatch = /^(((IX|IV|V)I{0,3})|I{1,3})$/
const toInitial = name => `${name[0]}.`

export const getNameParts = name => {
const parts = name.split(' ')
const parts = name.trim().split(' ')
if (parts.length === 1) {
return { first: [], last: [parts[0]], suffixes: [] }
}
Expand Down Expand Up @@ -182,5 +182,14 @@ export const getIdentifier = dataset => {
return identifier
}

export const getPublisher = (dataset, getTranslation) =>
getTranslation(dataset.research_dataset.publisher?.name)
export const getPublisher = (dataset, getTranslation) => {
const pub = dataset.research_dataset.publisher
if (pub) {
const top = topOrg(pub)
if (top !== pub) {
return `${getTranslation(top.name)}, ${getTranslation(pub.name)}`
}
return getTranslation(pub.name)
}
return undefined
}

0 comments on commit fde3861

Please sign in to comment.