Skip to content

Commit 284a8fb

Browse files
committed
Changed name of test and combined spy functionality in beforeEach for last two tests
1 parent 077210a commit 284a8fb

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

test/extractors/FHIRAdverseEventExtractor.test.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('FHIRAdverseEventExtractor', () => {
2121
test('sets study based on BASE_STUDY if not provided', () => {
2222
expect(extractor.study).toEqual(baseStudy);
2323
});
24-
test('sets status if provided', () => {
24+
test('sets study if provided', () => {
2525
expect(extractorWithStudy.study).toEqual(MOCK_STUDIES);
2626
});
2727
});
@@ -38,27 +38,25 @@ describe('FHIRAdverseEventExtractor', () => {
3838
expect(params).not.toHaveProperty('study');
3939
});
4040

41-
test('should add study when set to param values', async () => {
42-
// Create spy
43-
const { baseFHIRModule } = extractorWithStudy;
44-
const baseFHIRModuleSearchSpy = jest.spyOn(baseFHIRModule, 'search');
45-
baseFHIRModuleSearchSpy
46-
.mockReturnValue(examplePatientBundle);
47-
48-
const params = await extractorWithStudy.parametrizeArgsForFHIRModule({ mrn: MOCK_MRN });
49-
expect(params).toHaveProperty('study');
50-
expect(params.study).toEqual(extractorWithStudy.study);
51-
});
52-
53-
test('should delete patient after its value is moved to subject', async () => {
54-
// Create spy
55-
const { baseFHIRModule } = extractorWithStudy;
56-
const baseFHIRModuleSearchSpy = jest.spyOn(baseFHIRModule, 'search');
57-
baseFHIRModuleSearchSpy
58-
.mockReturnValue(examplePatientBundle);
59-
60-
const params = await extractorWithStudy.parametrizeArgsForFHIRModule({ mrn: MOCK_MRN });
61-
expect(params).not.toHaveProperty('patient');
41+
describe('pass in optional study parameter', () => {
42+
beforeEach(() => {
43+
// Create spy
44+
const { baseFHIRModule } = extractorWithStudy;
45+
const baseFHIRModuleSearchSpy = jest.spyOn(baseFHIRModule, 'search');
46+
baseFHIRModuleSearchSpy
47+
.mockReturnValue(examplePatientBundle);
48+
});
49+
50+
test('should add study when set to param values', async () => {
51+
const params = await extractorWithStudy.parametrizeArgsForFHIRModule({ mrn: MOCK_MRN });
52+
expect(params).toHaveProperty('study');
53+
expect(params.study).toEqual(extractorWithStudy.study);
54+
});
55+
56+
test('should delete patient after its value is moved to subject', async () => {
57+
const params = await extractorWithStudy.parametrizeArgsForFHIRModule({ mrn: MOCK_MRN });
58+
expect(params).not.toHaveProperty('patient');
59+
});
6260
});
6361
});
6462
});

0 commit comments

Comments
 (0)