Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
threepointone committed May 28, 2019
1 parent 9e87e65 commit 388b03d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 90 deletions.
95 changes: 43 additions & 52 deletions src/__tests__/inspectedElementContext-test.js
Expand Up @@ -20,9 +20,8 @@ describe('InspectedElementContext', () => {
let StoreContext;
let TreeContextController;

// a version of actAsync that *doesn't* recursively flush timers
// a version of actAsync that *doesn't* recursively flush timers
async function actAsync(cb: () => *): Promise<void> {

// $FlowFixMe Flow doesn't know about "await act()" yet
await act(async () => {
await cb();
Expand All @@ -33,7 +32,6 @@ describe('InspectedElementContext', () => {
});
}


beforeEach(() => {
utils = require('./utils');
utils.beforeEachProfiling();
Expand All @@ -44,7 +42,7 @@ describe('InspectedElementContext', () => {

React = require('react');
ReactDOM = require('react-dom');
act = require('react-dom/test-utils').act
act = require('react-dom/test-utils').act;
TestRenderer = utils.requireTestRenderer();

BridgeContext = require('src/devtools/views/context').BridgeContext;
Expand Down Expand Up @@ -100,18 +98,17 @@ describe('InspectedElementContext', () => {
return null;
}

await actAsync(
() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
await actAsync(() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
);
expect(didFinish).toBe(true);

Expand All @@ -135,18 +132,17 @@ describe('InspectedElementContext', () => {
return null;
}

await actAsync(
() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
await actAsync(() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
);
expect(inspectedElement).toMatchSnapshot('2: initial render');

Expand All @@ -155,18 +151,17 @@ describe('InspectedElementContext', () => {
);

inspectedElement = null;
await actAsync(
() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
await actAsync(() =>
TestRenderer.create(
<Contexts
defaultSelectedElementID={example.id}
defaultSelectedElementIndex={0}
>
<React.Suspense fallback={null}>
<Suspender target={example} />
</React.Suspense>
</Contexts>
)
);
expect(inspectedElement).toMatchSnapshot('2: updated state');

Expand Down Expand Up @@ -227,18 +222,14 @@ describe('InspectedElementContext', () => {

targetRenderCount = 0;
inspectedElement = null;
await actAsync(
() =>
renderer.update(
<Contexts
defaultSelectedElementID={id}
defaultSelectedElementIndex={1}
>
<React.Suspense fallback={null}>
<Suspender target={id} />
</React.Suspense>
</Contexts>
)
await actAsync(() =>
renderer.update(
<Contexts defaultSelectedElementID={id} defaultSelectedElementIndex={1}>
<React.Suspense fallback={null}>
<Suspender target={id} />
</React.Suspense>
</Contexts>
)
);
expect(targetRenderCount).toBe(0);
expect(inspectedElement).toEqual(initialInspectedElement);
Expand Down
68 changes: 32 additions & 36 deletions src/__tests__/ownersListContext-test.js
Expand Up @@ -84,28 +84,26 @@ describe('OwnersListContext', () => {
return null;
}

await utils.actAsync(
() =>
TestRenderer.create(
<Contexts defaultOwnerID={parent.id}>
<React.Suspense fallback={null}>
<Suspender owner={parent} />
</React.Suspense>
</Contexts>
)
await utils.actAsync(() =>
TestRenderer.create(
<Contexts defaultOwnerID={parent.id}>
<React.Suspense fallback={null}>
<Suspender owner={parent} />
</React.Suspense>
</Contexts>
)
);
expect(didFinish).toBe(true);

didFinish = false;
await utils.actAsync(
() =>
TestRenderer.create(
<Contexts defaultOwnerID={firstChild.id}>
<React.Suspense fallback={null}>
<Suspender owner={firstChild} />
</React.Suspense>
</Contexts>
)
await utils.actAsync(() =>
TestRenderer.create(
<Contexts defaultOwnerID={firstChild.id}>
<React.Suspense fallback={null}>
<Suspender owner={firstChild} />
</React.Suspense>
</Contexts>
)
);
expect(didFinish).toBe(true);

Expand Down Expand Up @@ -146,15 +144,14 @@ describe('OwnersListContext', () => {
return null;
}

await utils.actAsync(
() =>
TestRenderer.create(
<Contexts defaultOwnerID={firstChild.id}>
<React.Suspense fallback={null}>
<Suspender owner={firstChild} />
</React.Suspense>
</Contexts>
)
await utils.actAsync(() =>
TestRenderer.create(
<Contexts defaultOwnerID={firstChild.id}>
<React.Suspense fallback={null}>
<Suspender owner={firstChild} />
</React.Suspense>
</Contexts>
)
);
expect(didFinish).toBe(true);

Expand Down Expand Up @@ -187,15 +184,14 @@ describe('OwnersListContext', () => {
return null;
}

await utils.actAsync(
() =>
TestRenderer.create(
<Contexts defaultOwnerID={grandparent.id}>
<React.Suspense fallback={null}>
<Suspender owner={grandparent} />
</React.Suspense>
</Contexts>
)
await utils.actAsync(() =>
TestRenderer.create(
<Contexts defaultOwnerID={grandparent.id}>
<React.Suspense fallback={null}>
<Suspender owner={grandparent} />
</React.Suspense>
</Contexts>
)
);
expect(didFinish).toBe(true);

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/utils.js
Expand Up @@ -16,7 +16,7 @@ export function act(callback: Function): void {
// Flush Bridge operations
TestUtils.act(() => {
jest.runAllTimers();
})
});
}

export async function actAsync(cb: () => *): Promise<void> {
Expand Down Expand Up @@ -162,4 +162,4 @@ export function exportImportHelper(bridge: Bridge, store: Store): void {
// Apply the new exported-then-reimported data so tests can re-run assertions.
profilerStore.profilingData = profilingDataFrontend;
});
}
}

0 comments on commit 388b03d

Please sign in to comment.