Fix broken DataInspector test (#1100)

Summary:
Looks like we don't have a lint for `jest.mock` imports.
Pull Request resolved: https://github.com/facebook/flipper/pull/1100

Test Plan: yarn test

Reviewed By: jknoxville

Differential Revision: D21378747

Pulled By: passy

fbshipit-source-id: 118372596d6247282b1ddad1f22ed3916d303bb1
This commit is contained in:
Pascal Hartig
2020-05-04 05:32:55 -07:00
committed by Facebook GitHub Bot
parent fbc5d922b5
commit c1b360cb0f

View File

@@ -10,7 +10,12 @@
import * as React from 'react'; import * as React from 'react';
import {render, fireEvent, waitFor, act} from '@testing-library/react'; import {render, fireEvent, waitFor, act} from '@testing-library/react';
try {
jest.mock('../../../../fb/Logger'); jest.mock('../../../../fb/Logger');
} catch {
jest.mock('../../../../fb-stubs/Logger');
}
import ManagedDataInspector from '../ManagedDataInspector'; import ManagedDataInspector from '../ManagedDataInspector';
import {sleep} from '../../../../utils'; import {sleep} from '../../../../utils';
@@ -54,8 +59,16 @@ const json = {
}, },
}; };
describe('DataInspector', () => {
if (process.platform === 'win32') {
test('Skipping on Windows due to mocking not working', () => {});
return;
}
test('changing collapsed property works', async () => { test('changing collapsed property works', async () => {
const res = render(<ManagedDataInspector data={json} collapsed expandRoot />); const res = render(
<ManagedDataInspector data={json} collapsed expandRoot />,
);
expect(await res.findByText(/is/)).toBeTruthy(); // from expandRoot expect(await res.findByText(/is/)).toBeTruthy(); // from expandRoot
expect((await res.queryAllByText(/cool/)).length).toBe(0); expect((await res.queryAllByText(/cool/)).length).toBe(0);
@@ -71,7 +84,9 @@ test('changing collapsed property works', async () => {
}); });
test('can manually collapse properties', async () => { test('can manually collapse properties', async () => {
const res = render(<ManagedDataInspector data={json} collapsed expandRoot />); const res = render(
<ManagedDataInspector data={json} collapsed expandRoot />,
);
await res.findByText(/is/); // previewed as key, like: "data: {is, and}" await res.findByText(/is/); // previewed as key, like: "data: {is, and}"
expect((await res.queryAllByText(/awesomely/)).length).toBe(0); expect((await res.queryAllByText(/awesomely/)).length).toBe(0);
@@ -172,3 +187,4 @@ test('can filter for data', async () => {
await res.findByText(/awesomely/); await res.findByText(/awesomely/);
await res.findByText(/json/); await res.findByText(/json/);
}); });
});