bump fs-extra types

Summary: `recursive` was dropped in when [dropping](https://github.com/jprichardson/node-fs-extra/issues/886) node v10

Reviewed By: aigoncharov

Differential Revision: D48780242

fbshipit-source-id: 29349590a7f14da85fe8df28b20d9b418e7a8b1d
This commit is contained in:
Anton Kastritskiy
2023-09-05 07:17:06 -07:00
committed by Facebook GitHub Bot
parent d04abff530
commit f2ef26cd9a
13 changed files with 132 additions and 83 deletions

View File

@@ -31,6 +31,7 @@ test('getPluginDetailsV1', async () => {
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV1);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -74,6 +75,7 @@ test('getPluginDetailsV2', async () => {
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -121,6 +123,7 @@ test('id used as title if the latter omited', async () => {
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -167,6 +170,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -216,6 +220,7 @@ test('flipper-plugin-version is parsed', async () => {
'flipper-plugin': '^0.45',
},
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -269,6 +274,7 @@ test('plugin type and supported devices parsed', async () => {
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -338,6 +344,7 @@ test('plugin type and supported apps parsed', async () => {
description: 'Description of Test Plugin',
gatekeeper: 'GK_flipper_plugin_test',
};
// @ts-expect-error this is read only and it is fine, this is a test
fs.readJson = jest.fn().mockImplementation(() => pluginV2);
const details = await getInstalledPluginDetails(pluginPath);
details.dir = normalizePath(details.dir);
@@ -417,7 +424,7 @@ test('can merge two package.json files', async () => {
},
};
const mockedFs = jest.mocked(fs);
mockedFs.readJson.mockImplementation((file) => {
mockedFs.readJson.mockImplementation((file): any => {
if (file === path.join(pluginPath, 'package.json')) {
return pluginBase;
} else if (file === path.join(pluginPath, 'fb', 'package.json')) {

View File

@@ -119,24 +119,32 @@ function collectFileContent(
}
}
describe('pluginInstaller', () => {
let readJson: any;
beforeEach(() => {
mockfs(installedPluginFiles);
readJson = fs.readJson;
fs.readJson = (file: string) => {
jest.mock('fs-extra', () => {
const mod = {
...jest.requireActual('fs-extra'),
readJson: jest.fn((file: string) => {
const content = fileContent.get(normalizePath(file));
if (content) {
return Promise.resolve(JSON.parse(content));
} else {
return Promise.resolve(undefined);
}
};
}),
};
return {
...mod,
default: mod,
};
});
describe('pluginInstaller', () => {
beforeEach(() => {
mockfs(installedPluginFiles);
});
afterEach(() => {
mockfs.restore();
fs.readJson = readJson;
});
test('getInstalledPlugins', async () => {