Skip to content

Commit 6022257

Browse files
committed
Fix test
1 parent 20a93f7 commit 6022257

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

packages/react-dom/src/__tests__/ReactDOMComponent-test.js

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,18 +1094,12 @@ describe('ReactDOMComponent', () => {
10941094

10951095
it('should not incur unnecessary DOM mutations for boolean properties', () => {
10961096
const container = document.createElement('div');
1097-
function onChange() {
1098-
// noop
1099-
}
1100-
ReactDOM.render(
1101-
<input type="checkbox" onChange={onChange} checked={true} />,
1102-
container,
1103-
);
1097+
ReactDOM.render(<audio muted={true} />, container);
11041098

11051099
const node = container.firstChild;
11061100
let nodeValue = true;
11071101
const nodeValueSetter = jest.fn();
1108-
Object.defineProperty(node, 'checked', {
1102+
Object.defineProperty(node, 'muted', {
11091103
get: function () {
11101104
return nodeValue;
11111105
},
@@ -1114,48 +1108,11 @@ describe('ReactDOMComponent', () => {
11141108
}),
11151109
});
11161110

1117-
ReactDOM.render(
1118-
<input
1119-
type="checkbox"
1120-
onChange={onChange}
1121-
checked={true}
1122-
data-unrelated={true}
1123-
/>,
1124-
container,
1125-
);
1126-
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
1127-
1128-
expect(() => {
1129-
ReactDOM.render(
1130-
<input type="checkbox" onChange={onChange} />,
1131-
container,
1132-
);
1133-
}).toErrorDev(
1134-
'A component is changing a controlled input to be uncontrolled. This is likely caused by ' +
1135-
'the value changing from a defined to undefined, which should not happen. Decide between ' +
1136-
'using a controlled or uncontrolled input element for the lifetime of the component.',
1137-
);
1138-
// This leaves the current checked value in place, just like text inputs.
1111+
ReactDOM.render(<audio muted={true} data-unrelated="yes" />, container);
11391112
expect(nodeValueSetter).toHaveBeenCalledTimes(0);
11401113

1141-
expect(() => {
1142-
ReactDOM.render(
1143-
<input type="checkbox" onChange={onChange} checked={false} />,
1144-
container,
1145-
);
1146-
}).toErrorDev(
1147-
' A component is changing an uncontrolled input to be controlled. This is likely caused by ' +
1148-
'the value changing from undefined to a defined value, which should not happen. Decide between ' +
1149-
'using a controlled or uncontrolled input element for the lifetime of the component.',
1150-
);
1151-
1114+
ReactDOM.render(<audio muted={false} data-unrelated="ok" />, container);
11521115
expect(nodeValueSetter).toHaveBeenCalledTimes(1);
1153-
1154-
ReactDOM.render(
1155-
<input type="checkbox" onChange={onChange} checked={true} />,
1156-
container,
1157-
);
1158-
expect(nodeValueSetter).toHaveBeenCalledTimes(2);
11591116
});
11601117

11611118
it('should ignore attribute list for elements with the "is" attribute', () => {

0 commit comments

Comments
 (0)