Skip to content

Commit

Permalink
Merge pull request #40 from elifesciences/fix-manuscript-having-license
Browse files Browse the repository at this point in the history
add a test for updating preprint license from an inferred republished preprint, and fix the bug
  • Loading branch information
scottaubrey authored Oct 2, 2023
2 parents 809866f + 08fe009 commit f667f69
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/docmap-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ describe('docmap-parser', () => {
});
});

it('detect when a republish is inferred from a step', () => {
const parsedData = parseDocMap(fixtures.inferRepublishedPreprint());

expect(parsedData.versions.length).toStrictEqual(1);
expect(parsedData.versions[0]).toMatchObject({
doi: 'elife/12345.1',
id: 'elife/12345.1',
versionIdentifier: '1',
preprint: {
doi: 'preprint/article1',
id: 'preprint/article1',
versionIdentifier: '4',
},
license: 'http://creativecommons.org/licenses/by/4.0/',
});
});

it('finds a revised preprint from a docmap', () => {
const parsedData = parseDocMap(fixtures.preprintAndRevision());

Expand Down
1 change: 1 addition & 0 deletions src/docmap-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const republishPreprintAs = (expression: Expression, preprint: ReviewedPreprint,
newPreprint.doi = expression.doi;
newPreprint.versionIdentifier = expression.versionIdentifier;
newPreprint.publishedDate = expression.published;
newPreprint.license = expression.license;
};

const findAndFlatMapAllEvaluations = (actions: Action[]): Evaluation[] => actions.flatMap((action) => action.outputs.map((output) => {
Expand Down
13 changes: 13 additions & 0 deletions src/test-fixtures/docmapGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ export const fixtures = {
return generateDocMap('test', publisher, firstStep);
},

inferRepublishedPreprint: (): DocMap => {
const preprintv1 = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, '4', undefined);
const preprintv2 = generatePreprint('elife/12345.1', new Date('2022-04-12'), undefined, '1', undefined, 'http://creativecommons.org/licenses/by/4.0/');

const firstStep = generateStep(
[preprintv1],
[generateAction([], [preprintv2])],
[],
);

return generateDocMap('test', publisher, firstStep);
},

preprintAndRevision: (): DocMap => {
const preprintv1 = generatePreprint('preprint/article1', new Date('2022-03-01'), undefined, '1');
const preprintv2 = generatePreprint('preprint/article1v2', new Date('2022-06-01'), undefined, '2');
Expand Down

0 comments on commit f667f69

Please sign in to comment.