Skip to content

Commit

Permalink
Add contributor test (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjonin authored May 13, 2024
1 parent fc06c42 commit 29f932f
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions cypress/integration/persons.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,98 @@ describe('Multiple authors', function () {
cy.get('#author_2_givenName').should('have.value', 'Joe');
});
});

describe('Contributors', function () {
it('are exported as an object when unique', function () {
cy.get('#name').type('My Test Software');

cy.get('#contributor_add').click();
cy.get('#contributor_1_givenName').type('Jane');

cy.get('#generateCodemetaV3').click();
cy.get('#codemetaText').then((elem) => JSON.parse(elem.text()))
.should('deep.equal', {
"@context": "https://w3id.org/codemeta/3.0",
"type": "SoftwareSourceCode",
"name": "My Test Software",
"contributor": {
"id": "_:contributor_1",
"type": "Person",
"givenName": "Jane"
}
});
});

it('are exported as an array when multiple', function () {
cy.get('#name').type('My Test Software');

cy.get('#contributor_add').click();
cy.get('#contributor_1_givenName').type('Jane');

cy.get('#contributor_add').click();
cy.get('#contributor_2_givenName').type('Joe');

cy.get('#generateCodemetaV3').click();
cy.get('#codemetaText').then((elem) => JSON.parse(elem.text()))
.should('deep.equal', {
"@context": "https://w3id.org/codemeta/3.0",
"type": "SoftwareSourceCode",
"name": "My Test Software",
"contributor": [
{
"id": "_:contributor_1",
"type": "Person",
"givenName": "Jane"
},
{
"id": "_:contributor_2",
"type": "Person",
"givenName": "Joe"
}
]
});
});

it('can be imported when unique', function () {
cy.get('#codemetaText').then((elem) =>
elem.text(JSON.stringify({
"@context": "https://w3id.org/codemeta/3.0",
"type": "SoftwareSourceCode",
"name": "My Test Software",
"contributor": {
"type": "Person",
"givenName": "Jane"
}
}))
);
cy.get('#importCodemeta').click();

cy.get('#contributor_nb').should('have.value', '1');
cy.get('#contributor_1_givenName').should('have.value', 'Jane');
});

it('can be imported when multiple', function () {
cy.get('#codemetaText').then((elem) =>
elem.text(JSON.stringify({
"@context": "https://w3id.org/codemeta/3.0",
"type": "SoftwareSourceCode",
"name": "My Test Software",
"contributor": [
{
"type": "Person",
"givenName": "Jane"
},
{
"type": "Person",
"givenName": "Joe"
}
]
}))
);
cy.get('#importCodemeta').click();

cy.get('#contributor_nb').should('have.value', '2');
cy.get('#contributor_1_givenName').should('have.value', 'Jane');
cy.get('#contributor_2_givenName').should('have.value', 'Joe');
});
});

0 comments on commit 29f932f

Please sign in to comment.