Summary: This is the first of many diffs that extracts the connection, device, client detection out of the flipper core, to create a reusable flipper-server library that can be used in e.g. flipper-dump. To keep diffs a little smaller, the current connection logic is first moved to the `server/` directory, and decoupled manually from the rest of the core, before moving it over to a separate package. This first diffs moves the `comms/`, `devices/` and certificate utilities to the `server` directory. Further untangling will follow in next diffs Reviewed By: timur-valiev Differential Revision: D30246551 fbshipit-source-id: c84259bfb1239119b3267a51b015e30c3c080866
131 lines
2.9 KiB
TypeScript
131 lines
2.9 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {readFile} from 'fs';
|
|
import {promisify} from 'util';
|
|
import * as FlipperPluginModule from '../index';
|
|
|
|
test('Correct top level API exposed', () => {
|
|
const exposedAPIs: string[] = [];
|
|
const exposedTypes: string[] = [];
|
|
Object.entries(FlipperPluginModule).forEach(([key, value]) => {
|
|
if (key[0] === '_') {
|
|
return;
|
|
}
|
|
if (value === undefined) {
|
|
exposedTypes.push(key);
|
|
} else {
|
|
exposedAPIs.push(key);
|
|
}
|
|
});
|
|
|
|
// Note, all `exposedAPIs` should be documented in `flipper-plugin.mdx`
|
|
expect(exposedAPIs.sort()).toMatchInlineSnapshot(`
|
|
Array [
|
|
"CodeBlock",
|
|
"DataDescription",
|
|
"DataFormatter",
|
|
"DataInspector",
|
|
"DataList",
|
|
"DataSource",
|
|
"DataTable",
|
|
"DetailSidebar",
|
|
"Dialog",
|
|
"ElementsInspector",
|
|
"Layout",
|
|
"MarkerTimeline",
|
|
"MasterDetail",
|
|
"NUX",
|
|
"Panel",
|
|
"Spinner",
|
|
"Tab",
|
|
"Tabs",
|
|
"TestUtils",
|
|
"Toolbar",
|
|
"Tracked",
|
|
"TrackingScope",
|
|
"batch",
|
|
"createDataSource",
|
|
"createState",
|
|
"createTablePlugin",
|
|
"getFlipperLib",
|
|
"produce",
|
|
"renderReactRoot",
|
|
"sleep",
|
|
"styled",
|
|
"textContent",
|
|
"theme",
|
|
"timeout",
|
|
"useLocalStorageState",
|
|
"useLogger",
|
|
"useMemoize",
|
|
"usePlugin",
|
|
"useTrackedCallback",
|
|
"useValue",
|
|
"withTrackingScope",
|
|
]
|
|
`);
|
|
|
|
expect(exposedTypes.sort()).toMatchInlineSnapshot(`
|
|
Array [
|
|
"Atom",
|
|
"DataDescriptionType",
|
|
"DataInspectorExpanded",
|
|
"DataTableColumn",
|
|
"DataTableManager",
|
|
"DataValueExtractor",
|
|
"DefaultKeyboardAction",
|
|
"Device",
|
|
"DeviceLogEntry",
|
|
"DeviceLogListener",
|
|
"DevicePluginClient",
|
|
"DeviceType",
|
|
"Draft",
|
|
"ElementAttribute",
|
|
"ElementData",
|
|
"ElementExtraInfo",
|
|
"ElementID",
|
|
"ElementSearchResultSet",
|
|
"ElementsInspectorElement",
|
|
"ElementsInspectorProps",
|
|
"FlipperLib",
|
|
"HighlightManager",
|
|
"Idler",
|
|
"InteractionReport",
|
|
"InteractionReporter",
|
|
"LogLevel",
|
|
"LogTypes",
|
|
"Logger",
|
|
"MenuEntry",
|
|
"NormalizedMenuEntry",
|
|
"Notification",
|
|
"PluginClient",
|
|
"TrackType",
|
|
]
|
|
`);
|
|
});
|
|
|
|
test('All APIs documented', async () => {
|
|
const docs = await promisify(readFile)(
|
|
__dirname + '/../../../../docs/extending/flipper-plugin.mdx',
|
|
'utf8',
|
|
);
|
|
Object.keys(FlipperPluginModule)
|
|
.filter(
|
|
(key) =>
|
|
!key.startsWith('_') && (FlipperPluginModule as any)[key] !== undefined,
|
|
)
|
|
.forEach((key) => {
|
|
// There should be a header with this identifier
|
|
if (!new RegExp(`# ${key}\\b`).test(docs)) {
|
|
fail(`Not documented: '${key}'`);
|
|
}
|
|
});
|
|
});
|