Skip to content

Commit 7a6dad9

Browse files
committed
feat(ENG-9827): fix comments
1 parent 4655dae commit 7a6dad9

10 files changed

Lines changed: 284 additions & 75 deletions

File tree

src/app/features/collections/components/add-to-collection/add-to-collection-confirmation-dialog/add-to-collection-confirmation-dialog.component.spec.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import { of, throwError } from 'rxjs';
99
import { ComponentFixture, TestBed } from '@angular/core/testing';
1010

1111
import { CreateCollectionSubmission } from '@osf/features/collections/store/add-to-collection/add-to-collection.actions';
12+
import { CedarMetadataAttributes, CedarRecordDataBinding } from '@osf/features/metadata/models';
1213
import { CreateCedarMetadataRecord } from '@osf/features/metadata/store';
1314
import { UpdateProjectPublicStatus } from '@osf/features/project/overview/store';
1415
import { ResourceType } from '@osf/shared/enums/resource-type.enum';
16+
import { CollectionSubmissionPayload } from '@osf/shared/models/collections/collection-submission-payload.model';
1517
import { ToastService } from '@osf/shared/services/toast.service';
1618

1719
import { provideOSFCore } from '@testing/osf.testing.provider';
@@ -21,11 +23,11 @@ import { ToastServiceMock, ToastServiceMockType } from '@testing/providers/toast
2123

2224
import { AddToCollectionConfirmationDialogComponent } from './add-to-collection-confirmation-dialog.component';
2325

24-
const MOCK_CEDAR_DATA = {
25-
data: { '@context': {} },
26+
const MOCK_CEDAR_DATA: CedarRecordDataBinding = {
27+
data: { '@context': {} } as CedarMetadataAttributes,
2628
id: 'template-1',
2729
isPublished: true,
28-
} as any;
30+
};
2931

3032
describe('AddToCollectionConfirmationDialogComponent', () => {
3133
let component: AddToCollectionConfirmationDialogComponent;
@@ -35,17 +37,23 @@ describe('AddToCollectionConfirmationDialogComponent', () => {
3537
let toastService: ToastServiceMockType;
3638
let dialogConfig: {
3739
data: {
38-
payload?: unknown;
40+
payload?: CollectionSubmissionPayload;
3941
project?: { id: string; isPublic: boolean };
40-
cedarData?: unknown;
42+
cedarData?: CedarRecordDataBinding | null;
4143
};
4244
};
4345

46+
const MOCK_PAYLOAD: CollectionSubmissionPayload = {
47+
collectionId: 'collection-1',
48+
projectId: 'project-1',
49+
userId: 'user-1',
50+
};
51+
4452
beforeEach(() => {
4553
toastService = ToastServiceMock.simple();
4654
dialogConfig = {
4755
data: {
48-
payload: { title: 'Submission' },
56+
payload: MOCK_PAYLOAD,
4957
project: { id: 'project-1', isPublic: false },
5058
cedarData: null,
5159
},
@@ -90,7 +98,7 @@ describe('AddToCollectionConfirmationDialogComponent', () => {
9098
component.handleAddToCollectionConfirm();
9199

92100
expect(store.dispatch).toHaveBeenCalledWith(new UpdateProjectPublicStatus([{ id: 'project-1', public: true }]));
93-
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission({ title: 'Submission' } as any));
101+
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission(MOCK_PAYLOAD));
94102
expect(store.dispatch).not.toHaveBeenCalledWith(expect.any(CreateCedarMetadataRecord));
95103
expect(dialogRef.close).toHaveBeenCalledWith(true);
96104
expect(toastService.showSuccess).toHaveBeenCalledWith('collections.addToCollection.confirmationDialogToastMessage');
@@ -103,7 +111,7 @@ describe('AddToCollectionConfirmationDialogComponent', () => {
103111

104112
component.handleAddToCollectionConfirm();
105113

106-
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission({ title: 'Submission' } as any));
114+
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission(MOCK_PAYLOAD));
107115
expect(store.dispatch).not.toHaveBeenCalledWith(expect.any(UpdateProjectPublicStatus));
108116
expect(dialogRef.close).toHaveBeenCalledWith(true);
109117
});
@@ -117,7 +125,7 @@ describe('AddToCollectionConfirmationDialogComponent', () => {
117125
expect(store.dispatch).toHaveBeenCalledWith(
118126
new CreateCedarMetadataRecord(MOCK_CEDAR_DATA, 'project-1', ResourceType.Project)
119127
);
120-
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission({ title: 'Submission' } as any));
128+
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission(MOCK_PAYLOAD));
121129
expect(dialogRef.close).toHaveBeenCalledWith(true);
122130
});
123131

@@ -128,7 +136,7 @@ describe('AddToCollectionConfirmationDialogComponent', () => {
128136
component.handleAddToCollectionConfirm();
129137

130138
expect(store.dispatch).not.toHaveBeenCalledWith(expect.any(CreateCedarMetadataRecord));
131-
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission({ title: 'Submission' } as any));
139+
expect(store.dispatch).toHaveBeenCalledWith(new CreateCollectionSubmission(MOCK_PAYLOAD));
132140
});
133141

134142
it('should reset submitting state on error', () => {

0 commit comments

Comments
 (0)