Skip to content

Commit 6b06f41

Browse files
author
Brian Vaughn
committed
Minor tweaks to DevTools test data
1 parent dbf29c3 commit 6b06f41

File tree

7 files changed

+156
-37
lines changed

7 files changed

+156
-37
lines changed

fixtures/devtools/standalone/index.html

+21-8
Original file line numberDiff line numberDiff line change
@@ -209,54 +209,67 @@ <h1>List</h1>
209209
}
210210

211211
const baseInheritedKeys = Object.create(Object.prototype, {
212-
value1: {
212+
enumerableStringBase: {
213213
value: 1,
214214
writable: true,
215215
enumerable: true,
216216
configurable: true,
217217
},
218-
[Symbol('value1')]: {
218+
[Symbol('enumerableSymbolBase')]: {
219219
value: 1,
220220
writable: true,
221221
enumerable: true,
222222
configurable: true,
223223
},
224+
nonEnumerableStringBase: {
225+
value: 1,
226+
writable: true,
227+
enumerable: false,
228+
configurable: true,
229+
},
230+
[Symbol('nonEnumerableSymbolBase')]: {
231+
value: 1,
232+
writable: true,
233+
enumerable: false,
234+
configurable: true,
235+
},
224236
});
225237

226238
const inheritedKeys = Object.create(baseInheritedKeys, {
227-
value2: {
239+
enumerableString: {
228240
value: 2,
229241
writable: true,
230242
enumerable: true,
231243
configurable: true,
232244
},
233-
value3: {
245+
nonEnumerableString: {
234246
value: 3,
235247
writable: true,
236248
enumerable: false,
237249
configurable: true,
238250
},
239-
3: {
251+
123: {
240252
value: 3,
241253
writable: true,
242254
enumerable: true,
243255
configurable: true,
244256
},
245-
[Symbol('value2')]: {
257+
[Symbol('nonEnumerableSymbol')]: {
246258
value: 2,
247259
writable: true,
248260
enumerable: false,
249261
configurable: true,
250262
},
251-
[Symbol('value3')]: {
263+
[Symbol('enumerableSymbol')]: {
252264
value: 3,
253265
writable: true,
254266
enumerable: true,
255267
configurable: true,
256268
},
257269
});
270+
258271
function InheritedKeys() {
259-
return <ChildComponent inheritedKeys={inheritedKeys} />;
272+
return <ChildComponent data={inheritedKeys} />;
260273
}
261274

262275
const object = {

packages/react-devtools-shared/src/__tests__/__snapshots__/inspectedElementContext-test.js.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,11 @@ exports[`InspectedElementContext should support objects with with inherited keys
623623
"hooks": null,
624624
"props": {
625625
"object": {
626-
"3": 3,
627-
"value2": 2,
628-
"Symbol(value3)": 3,
629-
"value1": 1,
630-
"Symbol(value1)": 1
626+
"123": 3,
627+
"enumerableString": 2,
628+
"Symbol(enumerableSymbol)": 3,
629+
"enumerableStringBase": 1,
630+
"Symbol(enumerableSymbolBase)": 1
631631
}
632632
},
633633
"state": null

packages/react-devtools-shared/src/__tests__/inspectedElementContext-test.js

+25-12
Original file line numberDiff line numberDiff line change
@@ -945,52 +945,65 @@ describe('InspectedElementContext', () => {
945945
const Example = () => null;
946946

947947
const base = Object.create(Object.prototype, {
948-
value1: {
948+
enumerableStringBase: {
949949
value: 1,
950950
writable: true,
951951
enumerable: true,
952952
configurable: true,
953953
},
954-
[Symbol('value1')]: {
954+
[Symbol('enumerableSymbolBase')]: {
955955
value: 1,
956956
writable: true,
957957
enumerable: true,
958958
configurable: true,
959959
},
960+
nonEnumerableStringBase: {
961+
value: 1,
962+
writable: true,
963+
enumerable: false,
964+
configurable: true,
965+
},
966+
[Symbol('nonEnumerableSymbolBase')]: {
967+
value: 1,
968+
writable: true,
969+
enumerable: false,
970+
configurable: true,
971+
},
960972
});
961973

962974
const object = Object.create(base, {
963-
value2: {
975+
enumerableString: {
964976
value: 2,
965977
writable: true,
966978
enumerable: true,
967979
configurable: true,
968980
},
969-
value3: {
981+
nonEnumerableString: {
970982
value: 3,
971983
writable: true,
972984
enumerable: false,
973985
configurable: true,
974986
},
975-
3: {
987+
[123]: {
976988
value: 3,
977989
writable: true,
978990
enumerable: true,
979991
configurable: true,
980992
},
981-
[Symbol('value2')]: {
993+
[Symbol('nonEnumerableSymbol')]: {
982994
value: 2,
983995
writable: true,
984996
enumerable: false,
985997
configurable: true,
986998
},
987-
[Symbol('value3')]: {
999+
[Symbol('enumerableSymbol')]: {
9881000
value: 3,
9891001
writable: true,
9901002
enumerable: true,
9911003
configurable: true,
9921004
},
9931005
});
1006+
9941007
const container = document.createElement('div');
9951008
await utils.actAsync(() =>
9961009
ReactDOM.render(<Example object={object} />, container),
@@ -1023,11 +1036,11 @@ describe('InspectedElementContext', () => {
10231036
expect(inspectedElement).not.toBeNull();
10241037
expect(inspectedElement).toMatchSnapshot(`1: Inspected element ${id}`);
10251038
expect(inspectedElement.props.object).toEqual({
1026-
'3': 3,
1027-
'Symbol(value1)': 1,
1028-
'Symbol(value3)': 3,
1029-
value1: 1,
1030-
value2: 2,
1039+
123: 3,
1040+
'Symbol(enumerableSymbol)': 3,
1041+
'Symbol(enumerableSymbolBase)': 1,
1042+
enumerableString: 2,
1043+
enumerableStringBase: 1,
10311044
});
10321045

10331046
done();

packages/react-devtools-shared/src/__tests__/legacy/__snapshots__/inspectElement-test.js.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ Object {
247247
"hooks": null,
248248
"props": {
249249
"data": {
250-
"3": 3,
251-
"value2": 2,
252-
"Symbol(value3)": 3,
253-
"value1": 1,
254-
"Symbol(value1)": 1
250+
"123": 3,
251+
"enumerableString": 2,
252+
"Symbol(enumerableSymbol)": 3,
253+
"enumerableStringBase": 1,
254+
"Symbol(enumerableSymbolBase)": 1
255255
}
256256
},
257257
"state": null

packages/react-devtools-shared/src/__tests__/legacy/inspectElement-test.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -436,52 +436,65 @@ describe('InspectedElementContext', () => {
436436
const Example = () => null;
437437

438438
const base = Object.create(Object.prototype, {
439-
value1: {
439+
enumerableStringBase: {
440440
value: 1,
441441
writable: true,
442442
enumerable: true,
443443
configurable: true,
444444
},
445-
[Symbol('value1')]: {
445+
[Symbol('enumerableSymbolBase')]: {
446446
value: 1,
447447
writable: true,
448448
enumerable: true,
449449
configurable: true,
450450
},
451+
nonEnumerableStringBase: {
452+
value: 1,
453+
writable: true,
454+
enumerable: false,
455+
configurable: true,
456+
},
457+
[Symbol('nonEnumerableSymbolBase')]: {
458+
value: 1,
459+
writable: true,
460+
enumerable: false,
461+
configurable: true,
462+
},
451463
});
452464

453465
const object = Object.create(base, {
454-
value2: {
466+
enumerableString: {
455467
value: 2,
456468
writable: true,
457469
enumerable: true,
458470
configurable: true,
459471
},
460-
value3: {
472+
nonEnumerableString: {
461473
value: 3,
462474
writable: true,
463475
enumerable: false,
464476
configurable: true,
465477
},
466-
3: {
478+
[123]: {
467479
value: 3,
468480
writable: true,
469481
enumerable: true,
470482
configurable: true,
471483
},
472-
[Symbol('value2')]: {
484+
[Symbol('nonEnumerableSymbol')]: {
473485
value: 2,
474486
writable: true,
475487
enumerable: false,
476488
configurable: true,
477489
},
478-
[Symbol('value3')]: {
490+
[Symbol('enumerableSymbol')]: {
479491
value: 3,
480492
writable: true,
481493
enumerable: true,
482494
configurable: true,
483495
},
484496
});
497+
485498
act(() =>
486499
ReactDOM.render(<Example data={object} />, document.createElement('div')),
487500
);

packages/react-devtools-shell/src/app/InspectableElements/InspectableElements.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import CustomObject from './CustomObject';
1717
import EdgeCaseObjects from './EdgeCaseObjects.js';
1818
import NestedProps from './NestedProps';
1919
import SimpleValues from './SimpleValues';
20+
import SymbolKeys from './SymbolKeys';
2021

2122
// TODO Add Immutable JS example
2223

@@ -32,6 +33,7 @@ export default function InspectableElements() {
3233
<CustomObject />
3334
<EdgeCaseObjects />
3435
<CircularReferences />
36+
<SymbolKeys />
3537
</Fragment>
3638
);
3739
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
import * as React from 'react';
11+
12+
const base = Object.create(Object.prototype, {
13+
enumerableStringBase: {
14+
value: 1,
15+
writable: true,
16+
enumerable: true,
17+
configurable: true,
18+
},
19+
[Symbol('enumerableSymbolBase')]: {
20+
value: 1,
21+
writable: true,
22+
enumerable: true,
23+
configurable: true,
24+
},
25+
nonEnumerableStringBase: {
26+
value: 1,
27+
writable: true,
28+
enumerable: false,
29+
configurable: true,
30+
},
31+
[Symbol('nonEnumerableSymbolBase')]: {
32+
value: 1,
33+
writable: true,
34+
enumerable: false,
35+
configurable: true,
36+
},
37+
});
38+
39+
const data = Object.create(base, {
40+
enumerableString: {
41+
value: 2,
42+
writable: true,
43+
enumerable: true,
44+
configurable: true,
45+
},
46+
nonEnumerableString: {
47+
value: 3,
48+
writable: true,
49+
enumerable: false,
50+
configurable: true,
51+
},
52+
[123]: {
53+
value: 3,
54+
writable: true,
55+
enumerable: true,
56+
configurable: true,
57+
},
58+
[Symbol('nonEnumerableSymbol')]: {
59+
value: 2,
60+
writable: true,
61+
enumerable: false,
62+
configurable: true,
63+
},
64+
[Symbol('enumerableSymbol')]: {
65+
value: 3,
66+
writable: true,
67+
enumerable: true,
68+
configurable: true,
69+
},
70+
});
71+
72+
export default function SymbolKeys() {
73+
return <ChildComponent data={data} />;
74+
}
75+
76+
function ChildComponent(props: any) {
77+
return null;
78+
}

0 commit comments

Comments
 (0)