Skip to content

Commit bf82359

Browse files
committed
fix(tests): updated unit tests
1 parent 13d8aa5 commit bf82359

File tree

13 files changed

+32
-66
lines changed

13 files changed

+32
-66
lines changed

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ module.exports = {
5050
extensionsToTreatAsEsm: ['.ts'],
5151
coverageThreshold: {
5252
global: {
53-
branches: 24.1,
54-
functions: 28.73,
55-
lines: 56.52,
56-
statements: 56.82,
53+
branches: 29.01,
54+
functions: 32.75,
55+
lines: 60.28,
56+
statements: 60.77,
5757
},
5858
},
5959
watchPathIgnorePatterns: [

src/app/features/metadata/metadata.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class MetadataComponent implements OnInit {
125125
metadata = select(MetadataSelectors.getResourceMetadata);
126126
isMetadataLoading = select(MetadataSelectors.getLoading);
127127
customItemMetadata = select(MetadataSelectors.getCustomItemMetadata);
128-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
128+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
129129
isContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
130130
hasMoreContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
131131
cedarRecords = select(MetadataSelectors.getCedarRecords);

src/app/features/preprints/components/preprint-details/general-information/general-information.component.spec.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ describe('GeneralInformationComponent', () => {
4747
),
4848
],
4949
providers: [
50-
MockProvider(ENVIRONMENT, {
51-
webUrl: mockWebUrl,
52-
}),
50+
MockProvider(ENVIRONMENT, { webUrl: mockWebUrl }),
5351
provideMockStore({
5452
signals: [
5553
{
@@ -61,11 +59,15 @@ describe('GeneralInformationComponent', () => {
6159
value: false,
6260
},
6361
{
64-
selector: ContributorsSelectors.getContributors,
62+
selector: ContributorsSelectors.getBibliographicContributors,
6563
value: mockContributors,
6664
},
6765
{
68-
selector: ContributorsSelectors.isContributorsLoading,
66+
selector: ContributorsSelectors.isBibliographicContributorsLoading,
67+
value: false,
68+
},
69+
{
70+
selector: ContributorsSelectors.hasMoreBibliographicContributors,
6971
value: false,
7072
},
7173
{
@@ -83,26 +85,16 @@ describe('GeneralInformationComponent', () => {
8385
fixture.componentRef.setInput('preprintProvider', mockPreprintProvider);
8486
});
8587

86-
it('should create', () => {
87-
expect(component).toBeTruthy();
88-
});
89-
9088
it('should return preprint from store', () => {
9189
const preprint = component.preprint();
9290
expect(preprint).toBe(mockPreprint);
9391
});
9492

9593
it('should return contributors from store', () => {
96-
const contributors = component.contributors();
94+
const contributors = component.bibliographicContributors();
9795
expect(contributors).toBe(mockContributors);
9896
});
9997

100-
it('should filter bibliographic contributors', () => {
101-
const bibliographicContributors = component.bibliographicContributors();
102-
expect(bibliographicContributors).toHaveLength(1);
103-
expect(bibliographicContributors.every((contributor) => contributor.isBibliographic)).toBe(true);
104-
});
105-
10698
it('should return affiliated institutions from store', () => {
10799
const institutions = component.affiliatedInstitutions();
108100
expect(institutions).toBe(mockInstitutions);

src/app/features/preprints/components/preprint-details/general-information/general-information.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class GeneralInformationComponent implements OnDestroy {
6969

7070
affiliatedInstitutions = select(InstitutionsSelectors.getResourceInstitutions);
7171

72-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
72+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
7373
areContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
7474
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
7575

src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.spec.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ describe('PreprintTombstoneComponent', () => {
5050
value: false,
5151
},
5252
{
53-
selector: ContributorsSelectors.getContributors,
53+
selector: ContributorsSelectors.getBibliographicContributors,
5454
value: mockContributors,
5555
},
5656
{
57-
selector: ContributorsSelectors.isContributorsLoading,
57+
selector: ContributorsSelectors.isBibliographicContributorsLoading,
58+
value: false,
59+
},
60+
{
61+
selector: ContributorsSelectors.hasMoreBibliographicContributors,
5862
value: false,
5963
},
6064
{
@@ -76,16 +80,6 @@ describe('PreprintTombstoneComponent', () => {
7680
fixture.componentRef.setInput('preprintProvider', mockProvider);
7781
});
7882

79-
it('should create', () => {
80-
expect(component).toBeTruthy();
81-
});
82-
83-
it('should compute bibliographic contributors', () => {
84-
const bibliographicContributors = component.bibliographicContributors();
85-
expect(bibliographicContributors).toHaveLength(1);
86-
expect(bibliographicContributors[0].isBibliographic).toBe(true);
87-
});
88-
8983
it('should compute license from preprint', () => {
9084
const license = component.license();
9185
expect(license).toBe(mockPreprint.embeddedLicense);

src/app/features/preprints/components/preprint-details/preprint-tombstone/preprint-tombstone.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class PreprintTombstoneComponent implements OnDestroy {
6969
preprint = select(PreprintSelectors.getPreprint);
7070
isPreprintLoading = select(PreprintSelectors.isPreprintLoading);
7171

72-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
72+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
7373
areContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
7474
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
7575
subjects = select(SubjectsSelectors.getSelectedSubjects);

src/app/features/preprints/components/stepper/review-step/review-step.component.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ describe('ReviewStepComponent', () => {
5252
{ selector: PreprintStepperSelectors.isPreprintSubmitting, value: false },
5353
{ selector: PreprintStepperSelectors.getPreprintLicense, value: mockLicense },
5454
{ selector: PreprintStepperSelectors.getPreprintProject, value: mockPreprintProject },
55-
{ selector: ContributorsSelectors.getContributors, value: mockContributors },
55+
{ selector: ContributorsSelectors.getBibliographicContributors, value: mockContributors },
56+
{ selector: ContributorsSelectors.isBibliographicContributorsLoading, value: false },
57+
{ selector: ContributorsSelectors.hasMoreBibliographicContributors, value: false },
5658
{ selector: SubjectsSelectors.getSelectedSubjects, value: mockSubjects },
5759
{ selector: InstitutionsSelectors.getResourceInstitutions, value: mockInstitutions },
5860
],
@@ -68,20 +70,10 @@ describe('ReviewStepComponent', () => {
6870
fixture.componentRef.setInput('provider', mockProvider);
6971
});
7072

71-
it('should create', () => {
72-
expect(component).toBeTruthy();
73-
});
74-
7573
it('should have required provider input', () => {
7674
expect(component.provider()).toEqual(mockProvider);
7775
});
7876

79-
it('should filter bibliographic contributors', () => {
80-
const bibliographicContributors = component.bibliographicContributors();
81-
expect(bibliographicContributors).toHaveLength(1);
82-
expect(bibliographicContributors.every((c) => c.isBibliographic)).toBe(true);
83-
});
84-
8577
it('should create license options record', () => {
8678
const licenseOptionsRecord = component.licenseOptionsRecord();
8779
expect(licenseOptionsRecord).toEqual({ copyrightHolders: 'John Doe', year: '2023' });

src/app/features/preprints/components/stepper/review-step/review-step.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ReviewStepComponent implements OnInit {
8383
preprintFile = select(PreprintStepperSelectors.getPreprintFile);
8484
isPreprintSubmitting = select(PreprintStepperSelectors.isPreprintSubmitting);
8585

86-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
86+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
8787
areContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
8888
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
8989
subjects = select(SubjectsSelectors.getSelectedSubjects);

src/app/features/project/overview/project-overview.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class ProjectOverviewComponent implements OnInit {
143143
isWikiEnabled = select(ProjectOverviewSelectors.isWikiEnabled);
144144
parentProject = select(ProjectOverviewSelectors.getParentProject);
145145
isParentProjectLoading = select(ProjectOverviewSelectors.getParentProjectLoading);
146-
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributorsList);
146+
bibliographicContributors = select(ContributorsSelectors.getBibliographicContributors);
147147
isBibliographicContributorsLoading = select(ContributorsSelectors.isBibliographicContributorsLoading);
148148
hasMoreBibliographicContributors = select(ContributorsSelectors.hasMoreBibliographicContributors);
149149
addonsResourceReference = select(AddonsSelectors.getAddonsResourceReference);

src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { ActivatedRoute } from '@angular/router';
99
import { UserSelectors } from '@core/store/user';
1010
import { ResourceType } from '@osf/shared/enums';
1111
import { CustomConfirmationService, CustomDialogService, ToastService } from '@osf/shared/services';
12-
import { ContributorsSelectors } from '@osf/shared/stores';
13-
import { ContributorsTableComponent } from '@shared/components/contributors';
12+
import { ContributorsSelectors } from '@osf/shared/stores/contributors/contributors.selectors';
13+
import { ContributorsTableComponent } from '@shared/components/contributors/contributors-table/contributors-table.component';
1414

1515
import { RegistriesContributorsComponent } from './registries-contributors.component';
1616

@@ -77,15 +77,12 @@ describe('RegistriesContributorsComponent', () => {
7777
deleteContributor: jest.fn().mockReturnValue(of({})),
7878
bulkUpdateContributors: jest.fn().mockReturnValue(of({})),
7979
bulkAddContributors: jest.fn().mockReturnValue(of({})),
80+
resetContributorsState: jest.fn().mockRejectedValue(of({})),
8081
} as any;
8182
Object.defineProperty(component, 'actions', { value: mockActions });
8283
fixture.detectChanges();
8384
});
8485

85-
it('should create', () => {
86-
expect(component).toBeTruthy();
87-
});
88-
8986
it('should request contributors on init', () => {
9087
const actions = (component as any).actions;
9188
expect(actions.getContributors).toHaveBeenCalledWith('draft-1', ResourceType.DraftRegistration);

0 commit comments

Comments
 (0)