Skip to content

Commit c929960

Browse files
committed
test(MongoBinaryDownload): add test for "getMongodPath" with path existing
1 parent decdd63 commit c929960

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownload.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,24 @@ describe('MongoBinaryDownload', () => {
202202
);
203203
expect(process.stdout.write).toHaveBeenCalledTimes(1);
204204
});
205+
206+
it('should directly return the path if already exists', async () => {
207+
const binaryPath = '/path/to/binary';
208+
jest.spyOn(utils, 'pathExists').mockResolvedValue(true);
209+
210+
const du = new MongoBinaryDownload({ downloadDir: '/' });
211+
jest
212+
.spyOn(du, 'startDownload')
213+
.mockImplementation(() => fail('Expected this function not to be called'));
214+
// @ts-expect-error because "getPath" is "protected"
215+
jest.spyOn(du, 'getPath').mockResolvedValue(binaryPath);
216+
217+
const returnValue = await du.getMongodPath();
218+
expect(returnValue).toEqual(binaryPath);
219+
expect(du.startDownload).not.toHaveBeenCalled();
220+
expect(
221+
// @ts-expect-error because "getPath" is "protected"
222+
du.getPath
223+
).toHaveBeenCalledTimes(1);
224+
});
205225
});

0 commit comments

Comments
 (0)