Fix idb test (#1996)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1996 Erm, I'm a bit of a dummy. I didn't mock the access check, so it would actually rely on idb being installed to run the tests correctly. Without, we'd fail like here on GitHub: https://github.com/facebook/flipper/runs/2021551466 I couldn't quite figure out how to mock `fs.promises.access`, so I made the constructor configurable, which doesn't seem that bad, actually. Reviewed By: mweststrate Differential Revision: D26778428 fbshipit-source-id: 120b8060ad3ccb1cecd8ce2b208733d5e1090a72
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d7fc17c12e
commit
39f0fa86cc
@@ -65,8 +65,11 @@ function xcrunStartLogListener(udid: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function makeIOSBridge(idbPath: string): Promise<IOSBridge> {
|
||||
if (await isAvailable(idbPath)) {
|
||||
export async function makeIOSBridge(
|
||||
idbPath: string,
|
||||
isAvailableFn: (idbPath: string) => Promise<boolean> = isAvailable,
|
||||
): Promise<IOSBridge> {
|
||||
if (await isAvailableFn(idbPath)) {
|
||||
return {
|
||||
startLogListener: idbStartLogListener.bind(null, idbPath),
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ test('uses xcrun with no idb', async () => {
|
||||
});
|
||||
|
||||
test('uses idb when present', async () => {
|
||||
const ib = await makeIOSBridge('/usr/local/bin/idb');
|
||||
const ib = await makeIOSBridge('/usr/local/bin/idb', async (_) => true);
|
||||
ib.startLogListener('deadbeef');
|
||||
|
||||
expect(spawn).toHaveBeenCalledWith(
|
||||
|
||||
Reference in New Issue
Block a user