@etsoo/materialui 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ import { getByText, render } from '@testing-library/react';
2
+ import React from 'react';
3
+ import { act } from 'react-dom/test-utils';
4
+ import { SwitchAnt } from '../src/SwitchAnt';
5
+
6
+ it('SwitchAnt Tests', () => {
7
+ const onChange = jest.fn((event: React.ChangeEvent<HTMLInputElement>) =>
8
+ expect(event.target.checked).toBeTruthy()
9
+ );
10
+
11
+ // Render component
12
+ const { baseElement } = render(
13
+ <SwitchAnt startLabel="No" endLabel="Yes" onChange={onChange} />
14
+ );
15
+
16
+ const yes = getByText(baseElement, 'Yes');
17
+
18
+ act(() => {
19
+ yes.click();
20
+ });
21
+
22
+ expect(onChange).toBeCalled();
23
+ });
package/lib/SwitchAnt.js CHANGED
@@ -32,7 +32,7 @@ export function SwitchAnt(props) {
32
32
  ? undefined
33
33
  : (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
34
34
  } }, startLabel),
35
- React.createElement(Switch, { checked: controlChecked, ref: ref, value: value, onChange: onChangeLocal, ...rest }),
35
+ React.createElement(Switch, { checked: controlChecked, inputRef: ref, value: value, onChange: onChangeLocal, ...rest }),
36
36
  React.createElement(Typography, { onClick: () => { var _a; return !controlChecked && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.click()); }, sx: {
37
37
  cursor: 'pointer',
38
38
  color: controlChecked
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/SwitchAnt.tsx CHANGED
@@ -78,7 +78,7 @@ export function SwitchAnt(props: SwitchAntProps) {
78
78
  </Typography>
79
79
  <Switch
80
80
  checked={controlChecked}
81
- ref={ref}
81
+ inputRef={ref}
82
82
  value={value}
83
83
  onChange={onChangeLocal}
84
84
  {...rest}