Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,31 @@ describe('InstrumentRecordsService', () => {
expect(sessionsService.create).toHaveBeenCalledWith(expect.objectContaining({ username: undefined }));
});

// `pending` is intentionally not written on create; the find-side OR filter treats missing and
// false `pending` alike (see the 'find' describe block), so records stay query-visible without it.
it('should create records via createMany with the processed record data', async () => {
await instrumentRecordsService.upload({ ...baseUploadData });

expect(instrumentRecordModel.createMany).toHaveBeenCalledWith({
data: [expect.objectContaining({ instrumentId: 'instrument-1', subjectId: 'subject-1' })]
});
});

it('should settle a form instrument record, since an upload carries its data in full', async () => {
await instrumentRecordsService.upload({ ...baseUploadData });

expect(instrumentRecordModel.createMany).toHaveBeenCalledWith({
data: [expect.objectContaining({ pending: false })]
});
});

it('should leave a file instrument record pending, so its files can still be attached', async () => {
instrumentsService.findById.mockResolvedValue({ ...mockInstrument, kind: 'FILE' } as any);

await instrumentRecordsService.upload({ ...baseUploadData });

expect(instrumentRecordModel.createMany).toHaveBeenCalledWith({
data: [expect.objectContaining({ pending: true })]
});
});
});

describe('find', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class InstrumentRecordsService {
date,
groupId,
instrumentId,
pending: false,
pending: instrument.kind === 'FILE',
sessionId: session.id,
subjectId
};
Expand Down
Loading