Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Nov 29, 2023
1 parent 2cc9434 commit bc9b74e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/sn-controls-react/src/fieldcontrols/html-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export const HtmlEditor: React.FC<
ReactClientFieldSetting & {
theme?: Theme
setValue?: (value: string) => void
handleChange?: (value: string) => void
}
> = (props) => {
const initialState =
props.fieldValue || (props.actionName === 'new' && changeTemplatedValue(props.settings.DefaultValue)) || ''
const [value, setValue] = useState(initialState)
const readonly = props.actionName === 'browse' || props.settings.ReadOnly

const editorRef = useRef<MonacoEditor>(null)
const containerRef = useRef<HTMLDivElement>(null)
Expand All @@ -35,7 +35,6 @@ export const HtmlEditor: React.FC<
containerRef.current!.style.height = `${contentHeight}px`

Check warning on line 35 in packages/sn-controls-react/src/fieldcontrols/html-editor.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L35 was not covered by tests
})
}, [editorRef])
const readonly = props.actionName === 'browse' || props.settings.ReadOnly

const editorChangeHandler = (newValue: string) => {
setValue(newValue)
Expand All @@ -53,7 +52,7 @@ export const HtmlEditor: React.FC<
width="100%"
height="100%"
value={value}
onChange={props.handleChange || editorChangeHandler}
onChange={editorChangeHandler}
options={{
automaticLayout: true,
contextmenu: true,
Expand Down
2 changes: 0 additions & 2 deletions packages/sn-controls-react/test/html-editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('Html Editor', () => {
localization: defaultLocalization,
fieldValue: '<p>Test</p>',
fieldOnChange: onChange,
handleChange: onChange,
}

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

//should be called with onChange

expect(props.handleChange).toBeCalledWith('<p>Changed Test</p>')
expect(props.fieldOnChange).toBeCalledWith('<p>Changed Test</p>')
})
})

0 comments on commit bc9b74e

Please sign in to comment.