Skip to content

Commit bc9b74e

Browse files
committed
unit tests
1 parent 2cc9434 commit bc9b74e

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

packages/sn-controls-react/src/fieldcontrols/html-editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export const HtmlEditor: React.FC<
1515
ReactClientFieldSetting & {
1616
theme?: Theme
1717
setValue?: (value: string) => void
18-
handleChange?: (value: string) => void
1918
}
2019
> = (props) => {
2120
const initialState =
2221
props.fieldValue || (props.actionName === 'new' && changeTemplatedValue(props.settings.DefaultValue)) || ''
2322
const [value, setValue] = useState(initialState)
23+
const readonly = props.actionName === 'browse' || props.settings.ReadOnly
2424

2525
const editorRef = useRef<MonacoEditor>(null)
2626
const containerRef = useRef<HTMLDivElement>(null)
@@ -35,7 +35,6 @@ export const HtmlEditor: React.FC<
3535
containerRef.current!.style.height = `${contentHeight}px`
3636
})
3737
}, [editorRef])
38-
const readonly = props.actionName === 'browse' || props.settings.ReadOnly
3938

4039
const editorChangeHandler = (newValue: string) => {
4140
setValue(newValue)
@@ -53,7 +52,7 @@ export const HtmlEditor: React.FC<
5352
width="100%"
5453
height="100%"
5554
value={value}
56-
onChange={props.handleChange || editorChangeHandler}
55+
onChange={editorChangeHandler}
5756
options={{
5857
automaticLayout: true,
5958
contextmenu: true,

packages/sn-controls-react/test/html-editor.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ describe('Html Editor', () => {
3333
localization: defaultLocalization,
3434
fieldValue: '<p>Test</p>',
3535
fieldOnChange: onChange,
36-
handleChange: onChange,
3736
}
3837

3938
const wrapper = mount(<HtmlEditor {...props} />)
@@ -52,7 +51,6 @@ describe('Html Editor', () => {
5251

5352
//should be called with onChange
5453

55-
expect(props.handleChange).toBeCalledWith('<p>Changed Test</p>')
5654
expect(props.fieldOnChange).toBeCalledWith('<p>Changed Test</p>')
5755
})
5856
})

0 commit comments

Comments
 (0)