Update tests to use the sandyLegacy wrapper by default
Summary: Changed unit test infra to wrap legacy plugins by default in Sandy, and adapted tests where needed. Reviewed By: nikoant Differential Revision: D29264660 fbshipit-source-id: fe7cbc8af826afac5f945103586b3cb9647e7fbd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
00e2c803ef
commit
640e06f130
@@ -162,7 +162,14 @@ test('requirePlugin loads plugin', () => {
|
||||
version: '1.0.0',
|
||||
});
|
||||
expect(plugin).not.toBeNull();
|
||||
expect((plugin as any).prototype).toBeInstanceOf(FlipperPlugin);
|
||||
expect(Object.keys(plugin as any)).toEqual([
|
||||
'id',
|
||||
'details',
|
||||
'isDevicePlugin',
|
||||
'module',
|
||||
]);
|
||||
expect(Object.keys((plugin as any).module)).toEqual(['plugin', 'Component']);
|
||||
|
||||
expect(plugin!.id).toBe(TestPlugin.id);
|
||||
});
|
||||
|
||||
|
||||
@@ -318,11 +318,11 @@ const requirePluginInternal = (
|
||||
plugin.packageName = pluginDetails.name;
|
||||
plugin.details = pluginDetails;
|
||||
|
||||
if (GK.get('flipper_use_sandy_plugin_wrapper')) {
|
||||
return new _SandyPluginDefinition(
|
||||
pluginDetails,
|
||||
createSandyPluginWrapper(plugin),
|
||||
);
|
||||
if (
|
||||
GK.get('flipper_use_sandy_plugin_wrapper') ||
|
||||
process.env.NODE_ENV === 'test'
|
||||
) {
|
||||
return createSandyPluginFromClassicPlugin(pluginDetails, plugin);
|
||||
}
|
||||
|
||||
// set values from package.json as static variables on class
|
||||
@@ -336,6 +336,17 @@ const requirePluginInternal = (
|
||||
return plugin;
|
||||
};
|
||||
|
||||
export function createSandyPluginFromClassicPlugin(
|
||||
pluginDetails: ActivatablePluginDetails,
|
||||
plugin: any,
|
||||
) {
|
||||
pluginDetails.id = plugin.id; // for backward compatibility, see above check!
|
||||
return new _SandyPluginDefinition(
|
||||
pluginDetails,
|
||||
createSandyPluginWrapper(plugin),
|
||||
);
|
||||
}
|
||||
|
||||
export function selectCompatibleMarketplaceVersions(
|
||||
availablePlugins: MarketplacePluginDetails[],
|
||||
): MarketplacePluginDetails[] {
|
||||
|
||||
Reference in New Issue
Block a user