@samitouri / QOS-React-2 / commits / 388b03dd12

prettier

Sunil Pai committed May 28, 2019 at 20:24 UTC 388b03dd1244199a00601171256662057c3f5997
3 files changed +77 -90
src/__tests__/inspectedElementContext-test.js
+43 -52
@@ -20,9 +20,8 @@ describe('InspectedElementContext', () => {
20 let StoreContext;
21 let TreeContextController;
22
23 - // a version of actAsync that *doesn't* recursively flush timers
23 + // a version of actAsync that *doesn't* recursively flush timers
24 async function actAsync(cb: () => *): Promise<void> {
25 -
25 // $FlowFixMe Flow doesn't know about "await act()" yet
26 await act(async () => {
27 await cb();
@@ -33,7 +32,6 @@ describe('InspectedElementContext', () => {
32 });
33 }
34
36 -
35 beforeEach(() => {
36 utils = require('./utils');
37 utils.beforeEachProfiling();
@@ -44,7 +42,7 @@ describe('InspectedElementContext', () => {
42
43 React = require('react');
44 ReactDOM = require('react-dom');
47 - act = require('react-dom/test-utils').act
45 + act = require('react-dom/test-utils').act;
46 TestRenderer = utils.requireTestRenderer();
47
48 BridgeContext = require('src/devtools/views/context').BridgeContext;
@@ -100,18 +98,17 @@ describe('InspectedElementContext', () => {
98 return null;
99 }
100
103 - await actAsync(
104 - () =>
105 - TestRenderer.create(
106 - <Contexts
107 - defaultSelectedElementID={example.id}
108 - defaultSelectedElementIndex={0}
109 - >
110 - <React.Suspense fallback={null}>
111 - <Suspender target={example} />
112 - </React.Suspense>
113 - </Contexts>
114 - )
101 + await actAsync(() =>
102 + TestRenderer.create(
103 + <Contexts
104 + defaultSelectedElementID={example.id}
105 + defaultSelectedElementIndex={0}
106 + >
107 + <React.Suspense fallback={null}>
108 + <Suspender target={example} />
109 + </React.Suspense>
110 + </Contexts>
111 + )
112 );
113 expect(didFinish).toBe(true);
114
@@ -135,18 +132,17 @@ describe('InspectedElementContext', () => {
132 return null;
133 }
134
138 - await actAsync(
139 - () =>
140 - TestRenderer.create(
141 - <Contexts
142 - defaultSelectedElementID={example.id}
143 - defaultSelectedElementIndex={0}
144 - >
145 - <React.Suspense fallback={null}>
146 - <Suspender target={example} />
147 - </React.Suspense>
148 - </Contexts>
149 - )
135 + await actAsync(() =>
136 + TestRenderer.create(
137 + <Contexts
138 + defaultSelectedElementID={example.id}
139 + defaultSelectedElementIndex={0}
140 + >
141 + <React.Suspense fallback={null}>
142 + <Suspender target={example} />
143 + </React.Suspense>
144 + </Contexts>
145 + )
146 );
147 expect(inspectedElement).toMatchSnapshot('2: initial render');
148
@@ -155,18 +151,17 @@ describe('InspectedElementContext', () => {
151 );
152
153 inspectedElement = null;
158 - await actAsync(
159 - () =>
160 - TestRenderer.create(
161 - <Contexts
162 - defaultSelectedElementID={example.id}
163 - defaultSelectedElementIndex={0}
164 - >
165 - <React.Suspense fallback={null}>
166 - <Suspender target={example} />
167 - </React.Suspense>
168 - </Contexts>
169 - )
154 + await actAsync(() =>
155 + TestRenderer.create(
156 + <Contexts
157 + defaultSelectedElementID={example.id}
158 + defaultSelectedElementIndex={0}
159 + >
160 + <React.Suspense fallback={null}>
161 + <Suspender target={example} />
162 + </React.Suspense>
163 + </Contexts>
164 + )
165 );
166 expect(inspectedElement).toMatchSnapshot('2: updated state');
167
@@ -227,18 +222,14 @@ describe('InspectedElementContext', () => {
222
223 targetRenderCount = 0;
224 inspectedElement = null;
230 - await actAsync(
231 - () =>
232 - renderer.update(
233 - <Contexts
234 - defaultSelectedElementID={id}
235 - defaultSelectedElementIndex={1}
236 - >
237 - <React.Suspense fallback={null}>
238 - <Suspender target={id} />
239 - </React.Suspense>
240 - </Contexts>
241 - )
225 + await actAsync(() =>
226 + renderer.update(
227 + <Contexts defaultSelectedElementID={id} defaultSelectedElementIndex={1}>
228 + <React.Suspense fallback={null}>
229 + <Suspender target={id} />
230 + </React.Suspense>
231 + </Contexts>
232 + )
233 );
234 expect(targetRenderCount).toBe(0);
235 expect(inspectedElement).toEqual(initialInspectedElement);
src/__tests__/ownersListContext-test.js
+32 -36
@@ -84,28 +84,26 @@ describe('OwnersListContext', () => {
84 return null;
85 }
86
87 - await utils.actAsync(
88 - () =>
89 - TestRenderer.create(
90 - <Contexts defaultOwnerID={parent.id}>
91 - <React.Suspense fallback={null}>
92 - <Suspender owner={parent} />
93 - </React.Suspense>
94 - </Contexts>
95 - )
87 + await utils.actAsync(() =>
88 + TestRenderer.create(
89 + <Contexts defaultOwnerID={parent.id}>
90 + <React.Suspense fallback={null}>
91 + <Suspender owner={parent} />
92 + </React.Suspense>
93 + </Contexts>
94 + )
95 );
96 expect(didFinish).toBe(true);
97
98 didFinish = false;
100 - await utils.actAsync(
101 - () =>
102 - TestRenderer.create(
103 - <Contexts defaultOwnerID={firstChild.id}>
104 - <React.Suspense fallback={null}>
105 - <Suspender owner={firstChild} />
106 - </React.Suspense>
107 - </Contexts>
108 - )
99 + await utils.actAsync(() =>
100 + TestRenderer.create(
101 + <Contexts defaultOwnerID={firstChild.id}>
102 + <React.Suspense fallback={null}>
103 + <Suspender owner={firstChild} />
104 + </React.Suspense>
105 + </Contexts>
106 + )
107 );
108 expect(didFinish).toBe(true);
109
@@ -146,15 +144,14 @@ describe('OwnersListContext', () => {
144 return null;
145 }
146
149 - await utils.actAsync(
150 - () =>
151 - TestRenderer.create(
152 - <Contexts defaultOwnerID={firstChild.id}>
153 - <React.Suspense fallback={null}>
154 - <Suspender owner={firstChild} />
155 - </React.Suspense>
156 - </Contexts>
157 - )
147 + await utils.actAsync(() =>
148 + TestRenderer.create(
149 + <Contexts defaultOwnerID={firstChild.id}>
150 + <React.Suspense fallback={null}>
151 + <Suspender owner={firstChild} />
152 + </React.Suspense>
153 + </Contexts>
154 + )
155 );
156 expect(didFinish).toBe(true);
157
@@ -187,15 +184,14 @@ describe('OwnersListContext', () => {
184 return null;
185 }
186
190 - await utils.actAsync(
191 - () =>
192 - TestRenderer.create(
193 - <Contexts defaultOwnerID={grandparent.id}>
194 - <React.Suspense fallback={null}>
195 - <Suspender owner={grandparent} />
196 - </React.Suspense>
197 - </Contexts>
198 - )
187 + await utils.actAsync(() =>
188 + TestRenderer.create(
189 + <Contexts defaultOwnerID={grandparent.id}>
190 + <React.Suspense fallback={null}>
191 + <Suspender owner={grandparent} />
192 + </React.Suspense>
193 + </Contexts>
194 + )
195 );
196 expect(didFinish).toBe(true);
197
src/__tests__/utils.js
+2 -2
@@ -16,7 +16,7 @@ export function act(callback: Function): void {
16 // Flush Bridge operations
17 TestUtils.act(() => {
18 jest.runAllTimers();
19 - })
19 + });
20 }
21
22 export async function actAsync(cb: () => *): Promise<void> {
@@ -162,4 +162,4 @@ export function exportImportHelper(bridge: Bridge, store: Store): void {
162 // Apply the new exported-then-reimported data so tests can re-run assertions.
163 profilerStore.profilingData = profilingDataFrontend;
164 });
165 -}
\ No newline at end of file
165 +}