Skip to content

Commit 74b0941

Browse files
committed
split test in to two
1 parent 4ee3b94 commit 74b0941

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

src/formatter/sortObject.spec.js

+42-17
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,48 @@ describe('sortObject', () => {
4444
});
4545
});
4646

47-
it('should remove _owner key from react elements', () => {
48-
const fixture = {
49-
_owner: "_owner that doesn't belong to react element",
50-
component: <div />,
51-
};
52-
53-
expect(JSON.stringify(sortObject(fixture))).toEqual(
54-
JSON.stringify({
47+
describe('_owner key', () => {
48+
it('should preserve the _owner key for objects that are not react elements', () => {
49+
const fixture = {
5550
_owner: "_owner that doesn't belong to react element",
56-
component: {
57-
$$typeof: Symbol('react.transitional.element'),
58-
type: 'div',
59-
key: null,
60-
props: {},
61-
_store: {},
62-
},
63-
})
64-
);
51+
foo: 'bar',
52+
};
53+
54+
expect(JSON.stringify(sortObject(fixture))).toEqual(
55+
JSON.stringify({
56+
_owner: "_owner that doesn't belong to react element",
57+
foo: 'bar',
58+
})
59+
);
60+
});
61+
62+
it('should remove the _owner key from top level react element', () => {
63+
const fixture = {
64+
reactElement: (
65+
<div>
66+
<span></span>
67+
</div>
68+
),
69+
};
70+
71+
expect(JSON.stringify(sortObject(fixture))).toEqual(
72+
JSON.stringify({
73+
reactElement: {
74+
type: 'div',
75+
key: null,
76+
props: {
77+
children: {
78+
type: 'span',
79+
key: null,
80+
props: {},
81+
_owner: null,
82+
_store: {},
83+
},
84+
},
85+
_store: {},
86+
},
87+
})
88+
);
89+
});
6590
});
6691
});

0 commit comments

Comments
 (0)