[CST-5270] Fix unit testing

This commit is contained in:
Rezart Vata
2022-05-24 12:28:21 +02:00
parent 268ee04d1e
commit 53851ba18e
3 changed files with 100 additions and 90 deletions

View File

@@ -6,96 +6,96 @@ export const SherpaDataResponse = {
'id': 'sherpaPolicies',
'retrievalTime': '2022-04-20T09:44:39.870+00:00',
'sherpaResponse':
{
'error': false,
'message': null,
'metadata': {
'id': 23803,
'uri': 'http://v2.sherpa.ac.uk/id/publication/23803',
'dateCreated': '2012-11-20 14:51:52',
'dateModified': '2020-03-06 11:25:54',
'inDOAJ': false,
'publiclyVisible': true
{
'error': false,
'message': null,
'metadata': {
'id': 23803,
'uri': 'http://v2.sherpa.ac.uk/id/publication/23803',
'dateCreated': '2012-11-20 14:51:52',
'dateModified': '2020-03-06 11:25:54',
'inDOAJ': false,
'publiclyVisible': true
},
'journals': [{
'titles': ['The Lancet', 'Lancet'],
'url': 'http://www.thelancet.com/journals/lancet/issue/current',
'issns': ['0140-6736', '1474-547X'],
'romeoPub': 'Elsevier: The Lancet',
'zetoPub': 'Elsevier: The Lancet',
'publisher': {
'name': 'Elsevier',
'relationshipType': null,
'country': null,
'uri': 'http://www.elsevier.com/',
'identifier': null,
'publicationCount': 0,
'paidAccessDescription': 'Open access',
'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access'
},
'journals': [{
'titles': ['The Lancet', 'Lancet'],
'url': 'http://www.thelancet.com/journals/lancet/issue/current',
'issns': ['0140-6736', '1474-547X'],
'romeoPub': 'Elsevier: The Lancet',
'zetoPub': 'Elsevier: The Lancet',
'publisher': {
'name': 'Elsevier',
'relationshipType': null,
'country': null,
'uri': 'http://www.elsevier.com/',
'identifier': null,
'publicationCount': 0,
'paidAccessDescription': 'Open access',
'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access'
'publishers': [{
'name': 'Elsevier',
'relationshipType': null,
'country': null,
'uri': 'http://www.elsevier.com/',
'identifier': null,
'publicationCount': 0,
'paidAccessDescription': 'Open access',
'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access'
}],
'policies': [{
'id': 0,
'openAccessPermitted': false,
'uri': null,
'internalMoniker': 'Lancet',
'permittedVersions': [{
'articleVersion': 'submitted',
'option': 1,
'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'],
'prerequisites': [],
'locations': ['Author\'s Homepage', 'Preprint Repository'],
'licenses': [],
'embargo': null
}, {
'articleVersion': 'accepted',
'option': 1,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': [],
'locations': ['Author\'s Homepage', 'Institutional Website'],
'licenses': ['CC BY-NC-ND'],
'embargo': null
}, {
'articleVersion': 'accepted',
'option': 2,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': ['If Required by Funder'],
'locations': ['Non-Commercial Repository'],
'licenses': ['CC BY-NC-ND'],
'embargo': { amount: 6, units: 'Months' }
}, {
'articleVersion': 'accepted',
'option': 3,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': [],
'locations': ['Non-Commercial Repository'],
'licenses': [],
'embargo': null
}],
'urls': {
'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors',
'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy',
'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?',
'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication',
'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List',
'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors'
},
'publishers': [{
'name': 'Elsevier',
'relationshipType': null,
'country': null,
'uri': 'http://www.elsevier.com/',
'identifier': null,
'publicationCount': 0,
'paidAccessDescription': 'Open access',
'paidAccessUrl': 'https://www.elsevier.com/about/open-science/open-access'
}],
'policies': [{
'id': 0,
'openAccessPermitted': false,
'uri': null,
'internalMoniker': 'Lancet',
'permittedVersions': [{
'articleVersion': 'submitted',
'option': 1,
'conditions': ['Upon publication publisher copyright and source must be acknowledged', 'Upon publication must link to publisher version'],
'prerequisites': [],
'locations': ['Author\'s Homepage', 'Preprint Repository'],
'licenses': [],
'embargo': null
}, {
'articleVersion': 'accepted',
'option': 1,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': [],
'locations': ['Author\'s Homepage', 'Institutional Website'],
'licenses': ['CC BY-NC-ND'],
'embargo': null
}, {
'articleVersion': 'accepted',
'option': 2,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': ['If Required by Funder'],
'locations': ['Non-Commercial Repository'],
'licenses': ['CC BY-NC-ND'],
'embargo': null
}, {
'articleVersion': 'accepted',
'option': 3,
'conditions': ['Publisher copyright and source must be acknowledged', 'Must link to publisher version'],
'prerequisites': [],
'locations': ['Non-Commercial Repository'],
'licenses': [],
'embargo': null
}],
'urls': {
'http://download.thelancet.com/flatcontentassets/authors/lancet-information-for-authors.pdf': 'Guidelines for Authors',
'http://www.thelancet.com/journals/lancet/article/PIIS0140-6736%2813%2960720-5/fulltext': 'The Lancet journals welcome a new open access policy',
'http://www.thelancet.com/lancet-information-for-authors/after-publication': 'What happens after publication?',
'http://www.thelancet.com/lancet/information-for-authors/disclosure-of-results': 'Disclosure of results before publication',
'https://www.elsevier.com/__data/assets/pdf_file/0005/78476/external-embargo-list.pdf': 'Journal Embargo Period List',
'https://www.elsevier.com/__data/assets/pdf_file/0011/78473/UK-Embargo-Periods.pdf': 'Journal Embargo List for UK Authors'
},
'openAccessProhibited': false,
'publicationCount': 0,
'preArchiving': 'can',
'postArchiving': 'can',
'pubArchiving': 'cannot'
}],
'inDOAJ': false
}]
}
'openAccessProhibited': false,
'publicationCount': 0,
'preArchiving': 'can',
'postArchiving': 'can',
'pubArchiving': 'cannot'
}],
'inDOAJ': false
}]
}
} as WorkspaceitemSectionSherpaPoliciesObject;

View File

@@ -20,4 +20,5 @@ export class SectionsServiceStub {
computeSectionConfiguredMetadata = jasmine.createSpy('computeSectionConfiguredMetadata');
getShownSectionErrors = jasmine.createSpy('getShownSectionErrors');
getSectionServerErrors = jasmine.createSpy('getSectionServerErrors');
getIsInformational = jasmine.createSpy('getIsInformational');
}

View File

@@ -34,6 +34,7 @@ describe('ContentAccordionComponent', () => {
fixture = TestBed.createComponent(ContentAccordionComponent);
component = fixture.componentInstance;
de = fixture.debugElement;
component.isCollapsed = false;
component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[0];
fixture.detectChanges();
});
@@ -42,7 +43,15 @@ describe('ContentAccordionComponent', () => {
expect(component).toBeTruthy();
});
it('should show 2 rows', () => {
component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[0];
fixture.detectChanges();
expect(de.queryAll(By.css('.row')).length).toEqual(2);
});
it('should show 5 rows', () => {
component.version = SherpaDataResponse.sherpaResponse.journals[0].policies[0].permittedVersions[2];
fixture.detectChanges();
expect(de.queryAll(By.css('.row')).length).toEqual(5);
});
});