Plugin name list
Summary: Adds an argument to the headless Flipper to print the list of available plugins. Added `--list-plugins`. Currently the startFlipper function is not scalable enough to add new arguments and its implementation. I am planning to tackle this with the list of Actions which will be closure. So adding a new argument with its implementation will be just appending a closure at the correct location in an array. Will work on that in the later diff stacked on the current one. Reviewed By: jknoxville Differential Revision: D15789778 fbshipit-source-id: 91ba472617d593c3490bb932590a06d83597cba7
This commit is contained in:
committed by
Facebook Github Bot
parent
198841d1d7
commit
e5294d34f0
62
src/utils/__tests__/pluginUtils.node.js
Normal file
62
src/utils/__tests__/pluginUtils.node.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {getActivePluginNames} from '../pluginUtils';
|
||||
import type {State as PluginsState} from '../../reducers/plugins.js';
|
||||
import type {PluginDefinition} from '../../dispatcher/plugins';
|
||||
|
||||
function mockPluginState(
|
||||
gatekeepedPlugins: Array<PluginDefinition>,
|
||||
disabledPlugins: Array<PluginDefinition>,
|
||||
failedPlugins: Array<[PluginDefinition, string]>,
|
||||
): PluginsState {
|
||||
return {
|
||||
devicePlugins: new Map([
|
||||
//$FlowFixMe: Class instance won't be used in the test
|
||||
['DevicePlugin1', undefined],
|
||||
//$FlowFixMe: Class instance won't be used in the test
|
||||
['DevicePlugin2', undefined],
|
||||
]),
|
||||
clientPlugins: new Map([
|
||||
//$FlowFixMe: Class instance won't be used in the test
|
||||
['ClientPlugin1', undefined],
|
||||
//$FlowFixMe: Class instance won't be used in the test
|
||||
['ClientPlugin2', undefined],
|
||||
]),
|
||||
gatekeepedPlugins,
|
||||
disabledPlugins,
|
||||
failedPlugins,
|
||||
};
|
||||
}
|
||||
|
||||
function mockPluginDefinition(name: string): PluginDefinition {
|
||||
return {
|
||||
name,
|
||||
out: 'out',
|
||||
};
|
||||
}
|
||||
|
||||
test('getActivePluginNames with the plugins getting excluded', () => {
|
||||
let state = mockPluginState(
|
||||
[mockPluginDefinition('DevicePlugin1')],
|
||||
[mockPluginDefinition('ClientPlugin1')],
|
||||
[[mockPluginDefinition('DevicePlugin2'), 'DevicePlugin2']],
|
||||
);
|
||||
let list = getActivePluginNames(state);
|
||||
expect(list).toEqual(['ClientPlugin2']);
|
||||
});
|
||||
|
||||
test('getActivePluginNames with the no plugins getting excluded', () => {
|
||||
let state = mockPluginState([], [], []);
|
||||
let list = getActivePluginNames(state);
|
||||
expect(list).toEqual([
|
||||
'ClientPlugin1',
|
||||
'ClientPlugin2',
|
||||
'DevicePlugin1',
|
||||
'DevicePlugin2',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user