From 89508f244895c86a4518696d0356bae6be51e363 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Mon, 10 Apr 2023 14:32:54 -0700 Subject: [PATCH] Failing test for radio checked with changing names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` FAIL packages/react-dom/src/__tests__/ReactDOMInput-test.js (8.01 s) ● ReactDOMInput › shouldn't get tricked by changing radio names, part 2 expect(received).toBe(expected) // Object.is equality Expected: true Received: false 1209 | container 1210 | ); > 1211 | expect(container.querySelector('input[name="a"][value="1"]').checked).toBe(true); | ^ 1212 | expect(container.querySelector('input[name="b"][value="2"]').checked).toBe(true); 1213 | }); 1214 | at Object. (packages/react-dom/src/__tests__/ReactDOMInput-test.js:1211:79) ``` --- .../src/__tests__/ReactDOMInput-test.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index 47fca9522fac8..1d4b76a286abf 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -1190,6 +1190,28 @@ describe('ReactDOMInput', () => { expect(firstRadioNode.checked).toBe(true); }); + it("shouldn't get tricked by changing radio names, part 2", () => { + ReactDOM.render( +
+ {}} /> + {}} /> +
, + container + ); + expect(container.querySelector('input[name="a"][value="1"]').checked).toBe(true); + expect(container.querySelector('input[name="a"][value="2"]').checked).toBe(false); + + ReactDOM.render( +
+ {}} /> + {}} /> +
, + container + ); + expect(container.querySelector('input[name="a"][value="1"]').checked).toBe(true); + expect(container.querySelector('input[name="b"][value="2"]').checked).toBe(true); + }); + it('should control radio buttons if the tree updates during render', () => { const sharedParent = container; const container1 = document.createElement('div');