Skip to content

Commit

Permalink
fix(test): unit & visual
Browse files Browse the repository at this point in the history
  • Loading branch information
matochu committed Mar 1, 2024
1 parent a081ec6 commit 583fb4b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions packages/ui/__tests__/AutocompleteFieldFormik.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('AutocompleteFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as SelectInstance
const selectInstance = wrapper.find(Select)

expect(formikBag.current?.values).toEqual({
name: null,
Expand All @@ -47,7 +47,7 @@ describe('AutocompleteFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -58,7 +58,7 @@ describe('AutocompleteFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[0], { action: 'select-option' })
selectInstance.props().onChange?.(options[0], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -83,14 +83,14 @@ describe('AutocompleteFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as SelectInstance
const selectInstance = wrapper.find(Select)

expect(wrapper.find(Error).prop('error')).toBe(undefined)

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand Down Expand Up @@ -123,12 +123,12 @@ describe('AutocompleteFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as SelectInstance
const selectInstance = wrapper.find(Select)

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/__tests__/EmptyState.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mountAndCheckA11Y } from '@hazelcast/test-helpers'
import { Figma } from '@icons-pack/react-simple-icons'
import { SiFigma } from '@icons-pack/react-simple-icons'
import React from 'react'
import cn from 'classnames'

Expand All @@ -14,7 +14,7 @@ const title = 'Figma'
const description =
'Figma is a vector graphics editor and prototyping tool, with additional offline features enabled by desktop applications for macOS and Windows.'
// Icon
const icon = Figma
const icon = SiFigma
const iconLabel = 'Icon Figma'
// Action
const action = 'Cool!'
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/__tests__/Pagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ describe('Pagination', () => {

expect(setPageSize).toHaveBeenCalledTimes(0)

const selectInstance = wrapper.find(Select).instance() as Select<SelectFieldOption<number>>
const selectInstance = wrapper.find(Select)
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.({ value: 10, label: '10' }, { action: 'select-option' })
selectInstance.props().onChange?.({ value: 10, label: '10' }, { action: 'select-option' })
})
wrapper.update()

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/__tests__/Select/MultiSelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { useUID } from 'react-uid'
import { mountAndCheckA11Y } from '@hazelcast/test-helpers'
import ReactSelect, { OptionsType } from 'react-select'
import ReactSelect, { Options } from 'react-select'
import ReactSelectCreatable from 'react-select/creatable'
import { X } from 'react-feather'

Expand All @@ -21,7 +21,7 @@ const selectId = 'selectId'
const selectName = 'selectName'
const selectLabel = 'selectLabel'

const options: OptionsType<SelectFieldOption<string>> = [
const options: Options<SelectFieldOption<string>> = [
{ value: 'darth_vader', label: 'Darth Vader' },
{ value: 'luke_skywalker', label: 'Luke Skywalker' },
{ value: 'obi', label: 'Obi-Wan Kenobi' },
Expand All @@ -33,7 +33,7 @@ const options: OptionsType<SelectFieldOption<string>> = [
const selectedOptions = [options[1]]
const selectedValues = selectedOptions.map(({ value }) => value)

describe('SelectField', () => {
describe('MultiSelectField', () => {
beforeEach(() => {
useUIDMock.mockImplementation(() => selectId)
})
Expand Down
16 changes: 8 additions & 8 deletions packages/ui/__tests__/Select/MultiSelectFieldFormik.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { createRef } from 'react'
import { Formik, Form, FormikProps } from 'formik'
import { mountAndCheckA11Y } from '@hazelcast/test-helpers'
import { act } from 'react-dom/test-utils'
import Select from 'react-select'
import ReactSelect from 'react-select'

import { MultiSelectFieldFormik } from '../../src/Select/MultiSelectFieldFormik'
import { SelectFieldOption } from '../../src/Select/helpers'
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('MultiSelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

expect(formikBag.current?.values).toEqual({
names: [],
Expand All @@ -47,7 +47,7 @@ describe('MultiSelectFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.([options[1]], { action: 'select-option' })
selectInstance.props().onChange?.([options[1]], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -58,7 +58,7 @@ describe('MultiSelectFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.([options[1], options[0]], { action: 'select-option' })
selectInstance.props().onChange?.([options[1], options[0]], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -83,14 +83,14 @@ describe('MultiSelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

expect(wrapper.find(Error).prop('error')).toBe(undefined)

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.([options[1]], { action: 'select-option' })
selectInstance.props().onChange?.([options[1]], { action: 'select-option' })
})
wrapper.update()

Expand Down Expand Up @@ -123,7 +123,7 @@ describe('MultiSelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

expect(formikBag.current?.values).toEqual({
names: [],
Expand All @@ -132,7 +132,7 @@ describe('MultiSelectFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.([options[1]], { action: 'select-option' })
selectInstance.props().onChange?.([options[1]], { action: 'select-option' })
})
wrapper.update()

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/__tests__/Select/SelectField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { useUID } from 'react-uid'
import { mountAndCheckA11Y } from '@hazelcast/test-helpers'
import ReactSelect, { OptionsType } from 'react-select'
import ReactSelect, { Options } from 'react-select'
import ReactSelectCreatable from 'react-select/creatable'

import { SelectField } from '../../src/Select/SelectField'
Expand All @@ -21,7 +21,7 @@ const selectId = 'selectId'
const selectName = 'selectName'
const selectLabel = 'selectLabel'

const options: OptionsType<SelectFieldOption<string>> = [
const options: Options<SelectFieldOption<string>> = [
{ value: 'darth_vader', label: 'Darth Vader' },
{ value: 'luke_skywalker', label: 'Luke Skywalker' },
{ value: 'obi', label: 'Obi-Wan Kenobi' },
Expand Down
18 changes: 9 additions & 9 deletions packages/ui/__tests__/Select/SelectFieldFormik.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React, { createRef } from 'react'
import { Formik, Form, FormikProps } from 'formik'
import { mountAndCheckA11Y } from '@hazelcast/test-helpers'
import { act } from 'react-dom/test-utils'
import Select from 'react-select'
import ReactSelect, { SelectInstance } from 'react-select'

import { SelectField } from '../../src/Select/SelectField'
import { SelectFieldFormik } from '../../src/Select/SelectFieldFormik'
import { SelectFieldOption } from '../../src/Select/helpers'
import { Error } from '../../src/Error'
Expand Down Expand Up @@ -38,16 +39,15 @@ describe('SelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

expect(formikBag.current?.values).toEqual({
name: null,
})

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -58,7 +58,7 @@ describe('SelectFieldFormik', () => {
// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[0], { action: 'select-option' })
selectInstance.props().onChange?.(options[0], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -83,14 +83,14 @@ describe('SelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

expect(wrapper.find(Error).prop('error')).toBe(undefined)

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand All @@ -113,12 +113,12 @@ describe('SelectFieldFormik', () => {
)

const wrapper = await mountAndCheckA11Y(<TestForm />)
const selectInstance = wrapper.find(Select).instance() as Select
const selectInstance = wrapper.find(ReactSelect)

// We need the `async` call here to wait for processing of the asynchronous 'change'
// eslint-disable-next-line @typescript-eslint/require-await
await act(async () => {
selectInstance.props.onChange?.(options[1], { action: 'select-option' })
selectInstance.props().onChange?.(options[1], { action: 'select-option' })
})
wrapper.update()

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/Select/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const SelectField = <V extends string | number = string>(props: SelectFie
onChange,
options,
placeholder,
required = false,
required,
value,
formatGroupLabel,
formatOptionLabel,
Expand Down

0 comments on commit 583fb4b

Please sign in to comment.