Move tests to internal repo

Summary:
Some of the tests need to mock behavior of fb-internal dependencies.
These fb deps get swapped out with a babel transform and it's become hard to maintain now that we're mocking them as well.

For simplicity of mocking, moving them out of the public repo, they'll get run on PRs.

Reviewed By: priteshrnandgaonkar

Differential Revision: D18086247

fbshipit-source-id: 001e258e00da67a112cb754e851253e5480e578a
This commit is contained in:
John Knox
2019-10-23 10:30:47 -07:00
committed by Facebook Github Bot
parent f6dc82f2af
commit 2cd6be2d0f
4 changed files with 0 additions and 449 deletions

View File

@@ -1,59 +0,0 @@
/**
* 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
*/
jest.mock('../../fb-stubs/Logger');
try {
jest.mock('../../fb/Logger');
} catch {
// Allowed to fail when fb modules are not present.
}
import {default as PluginInstaller, PluginDefinition} from '../PluginInstaller';
import React from 'react';
import {render, waitForElement} from '@testing-library/react';
import configureStore from 'redux-mock-store';
const mockStore = configureStore([])({application: {sessionId: 'mysession'}});
import {Provider} from 'react-redux';
const SEARCH_RESULTS = ({
hits: [
{name: 'flipper-plugin-hello', version: '0.1.0', description: 'World?'},
{name: 'flipper-plugin-world', version: '0.2.0', description: 'Hello?'},
],
} as unknown) as algoliasearch.Response<any>;
// *Very* incomplete mock, but that's all we use.
const indexMock: algoliasearch.Index = ({
search: jest.fn(),
} as unknown) as algoliasearch.Index;
beforeEach(() => {
indexMock.search = jest.fn(async () => SEARCH_RESULTS);
});
test('load PluginInstaller list', async () => {
const component = (
<Provider store={mockStore}>
<PluginInstaller
getInstalledPlugins={async () => new Map<string, PluginDefinition>()}
searchIndexFactory={() => indexMock}
// Bit ugly to have this as an effectively test-only option, but
// without, we rely on height information from Electron which we don't
// have, causing no items to be rendered.
autoHeight={true}
/>
</Provider>
);
const {container, getByText} = render(component);
await waitForElement(() => getByText('flipper-plugin-hello'));
expect((indexMock.search as jest.Mock).mock.calls.length).toBe(2);
expect(container).toMatchSnapshot();
});

View File

@@ -1,238 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`load PluginInstaller list 1`] = `
<div>
<div
class="css-1nm3y77"
>
<div
class="css-4zga7z"
>
<div
class="css-e0frhe"
>
<input
class="css-ww9vf1"
placeholder="Search Flipper plugins..."
type="text"
value=""
/>
</div>
</div>
<div
class="css-1nekdsz"
>
<div
class="css-1k4677w"
>
<div
class="css-vd30c4"
>
<div
class="css-1vb6sy6"
title="name"
width="25%"
>
<div
class="css-glr1wj"
style="z-index: auto; right: 0px; bottom: 0px; width: 100%; height: 100%;"
>
<div
class="css-1db3q1"
>
Name
</div>
</div>
</div>
<div
class="css-1xchw24"
title="version"
width="10%"
>
<div
class="css-glr1wj"
style="z-index: auto; right: 0px; bottom: 0px; width: 100%; height: 100%;"
>
<div
class="css-1db3q1"
>
Version
</div>
</div>
</div>
<div
class="css-173sh01"
title="description"
width="flex"
>
<div
class="css-glr1wj"
style="z-index: auto; right: 0px; bottom: 0px; width: 100%; height: 100%;"
>
<div
class="css-1db3q1"
>
Description
</div>
</div>
</div>
<div
class="css-f0p3z5"
title="install"
width="15%"
>
<div
class="css-glr1wj"
style="z-index: auto; right: 0px; bottom: 0px; width: 100%; height: 100%;"
>
<div
class="css-1db3q1"
>
</div>
</div>
</div>
</div>
</div>
<div
class="css-1nekdsz"
>
<div
class="css-1jjayz9"
data-key="flipper-plugin-hello"
>
<div
class="css-1jes4os"
title=""
width="25%"
>
<span
class="css-1pso8q0"
>
flipper-plugin-hello
</span>
</div>
<div
class="css-1kkefm9"
title=""
width="10%"
>
<span
class="css-1pso8q0"
>
0.1.0
</span>
</div>
<div
class="css-v10b1x"
title=""
width="flex"
>
<div
class="css-9qtipk"
>
<span
class="css-1pso8q0"
>
World?
</span>
<div
class="css-12zzrdt"
/>
<span
class="css-1b8mb9l"
>
<div
class="css-1fev88q"
color="#bec2c9"
size="16"
src="https://external.xx.fbcdn.net/assets/?name=info-circle&variant=filled&size=16&set=facebook_icons&density=1x"
/>
</span>
</div>
</div>
<div
class="css-yt1ntn"
title=""
width="15%"
>
<div
class="css-z1ci4f"
type="primary"
>
Install
</div>
</div>
</div>
<div
class="css-1ut44ht"
data-key="flipper-plugin-world"
>
<div
class="css-1jes4os"
title=""
width="25%"
>
<span
class="css-1pso8q0"
>
flipper-plugin-world
</span>
</div>
<div
class="css-1kkefm9"
title=""
width="10%"
>
<span
class="css-1pso8q0"
>
0.2.0
</span>
</div>
<div
class="css-v10b1x"
title=""
width="flex"
>
<div
class="css-9qtipk"
>
<span
class="css-1pso8q0"
>
Hello?
</span>
<div
class="css-12zzrdt"
/>
<span
class="css-1b8mb9l"
>
<div
class="css-1fev88q"
color="#bec2c9"
size="16"
src="https://external.xx.fbcdn.net/assets/?name=info-circle&variant=filled&size=16&set=facebook_icons&density=1x"
/>
</span>
</div>
</div>
<div
class="css-yt1ntn"
title=""
width="15%"
>
<div
class="css-z1ci4f"
type="primary"
>
Install
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;