added deeplink support to sandy device plugins
Summary: Make sure device plugins can be deeplinked as well. (note that the duplication between `Plugin` and `DevicePlugin` is cleaned up again in D22727089, first wanted to make it work and tested, then clean) DeepLink no longer have to be strings, per popular requests, as that makes direct linking between plugins easier (online links from the outside world have to arrive as strings) Reviewed By: jknoxville, nikoant Differential Revision: D22727091 fbshipit-source-id: 523c90b1e1fbf3700fdb4f62699dd57070cbc980
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b621dcf754
commit
f8ff6dc393
@@ -11,6 +11,7 @@ import * as TestUtils from '../test-utils/test-utils';
|
||||
import * as testPlugin from './TestPlugin';
|
||||
import {createState} from '../state/atom';
|
||||
import {FlipperClient} from '../plugin/Plugin';
|
||||
import {DevicePluginClient} from '../plugin/DevicePlugin';
|
||||
|
||||
test('it can start a plugin and lifecycle events', () => {
|
||||
const {instance, ...p} = TestUtils.startPlugin(testPlugin);
|
||||
@@ -215,3 +216,25 @@ test('plugins can receive deeplinks', async () => {
|
||||
plugin.triggerDeepLink('test');
|
||||
expect(plugin.instance.field1.get()).toBe('test');
|
||||
});
|
||||
|
||||
test('device plugins can receive deeplinks', async () => {
|
||||
const plugin = TestUtils.startDevicePlugin({
|
||||
devicePlugin(client: DevicePluginClient) {
|
||||
client.onDeepLink((deepLink) => {
|
||||
if (typeof deepLink === 'string') {
|
||||
field1.set(deepLink);
|
||||
}
|
||||
});
|
||||
const field1 = createState('', {persist: 'test'});
|
||||
return {field1};
|
||||
},
|
||||
supportsDevice: () => true,
|
||||
Component() {
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
expect(plugin.instance.field1.get()).toBe('');
|
||||
plugin.triggerDeepLink('test');
|
||||
expect(plugin.instance.field1.get()).toBe('test');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user