Support supportsMethod in FlipperPlugin
Summary: `supportsMethod` wasn't implemented in the new sandy APIs so far, but is needed for D24108772 Reviewed By: cekkaewnumchai Differential Revision: D24109496 fbshipit-source-id: 694344b423c1805baa193e4f2e1ad5f28483378b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e40eb2dadd
commit
7b758d2697
@@ -346,3 +346,46 @@ test('plugins can create pastes', async () => {
|
||||
plugin.instance.doIt();
|
||||
expect(plugin.flipperLib.createPaste).toBeCalledWith('test');
|
||||
});
|
||||
|
||||
test('plugins support all methods by default', async () => {
|
||||
type Methods = {
|
||||
doit(): Promise<boolean>;
|
||||
};
|
||||
const plugin = TestUtils.startPlugin({
|
||||
plugin(client: PluginClient<{}, Methods>) {
|
||||
return {
|
||||
async checkEnabled() {
|
||||
return client.supportsMethod('doit');
|
||||
},
|
||||
};
|
||||
},
|
||||
Component() {
|
||||
return null;
|
||||
},
|
||||
});
|
||||
expect(await plugin.instance.checkEnabled()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('available methods can be overridden', async () => {
|
||||
type Methods = {
|
||||
doit(): Promise<boolean>;
|
||||
};
|
||||
const plugin = TestUtils.startPlugin(
|
||||
{
|
||||
plugin(client: PluginClient<{}, Methods>) {
|
||||
return {
|
||||
async checkEnabled() {
|
||||
return client.supportsMethod('doit');
|
||||
},
|
||||
};
|
||||
},
|
||||
Component() {
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
unsupportedMethods: ['doit'],
|
||||
},
|
||||
);
|
||||
expect(await plugin.instance.checkEnabled()).toBeFalsy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user