| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and 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 | * @emails react-core |
| 8 | */ |
| 9 | |
| 10 | 'use strict'; |
| 11 | |
| 12 | let React; |
| 13 | let ReactNoop; |
| 14 | |
| 15 | describe('arity', () => { |
| 16 | beforeEach(() => { |
| 17 | jest.resetModules(); |
| 18 | |
| 19 | React = require('react'); |
| 20 | ReactNoop = require('react-noop-renderer'); |
| 21 | }); |
| 22 | |
| 23 | it("ensure useState setter's arity is correct", () => { |
| 24 | function Component() { |
| 25 | const [, setState] = React.useState(() => 'Halo!'); |
| 26 | |
| 27 | expect(setState.length).toBe(1); |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | ReactNoop.render(<Component />); |
| 32 | }); |
| 33 | |
| 34 | it("ensure useReducer setter's arity is correct", () => { |
| 35 | function Component() { |
| 36 | const [, dispatch] = React.useReducer(() => 'Halo!'); |
| 37 | |
| 38 | expect(dispatch.length).toBe(1); |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | ReactNoop.render(<Component />); |
| 43 | }); |
| 44 | }); |