Skip to content

Commit

Permalink
test: update test and test libraries for react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Sep 12, 2024
1 parent 073bcac commit dd3283d
Show file tree
Hide file tree
Showing 3 changed files with 599 additions and 846 deletions.
3 changes: 1 addition & 2 deletions adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
},
"devDependencies": {
"@dhis2/cli-app-scripts": "12.0.0-alpha.13",
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react": "^16.0.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"react": "^18",
Expand Down
16 changes: 8 additions & 8 deletions adapter/src/utils/useLocale.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { renderHook } from '@testing-library/react-hooks'
import { renderHook, waitFor } from '@testing-library/react'
import moment from 'moment'
import { useCurrentUserLocale } from './useLocale.js'

Expand Down Expand Up @@ -84,7 +84,7 @@ describe('formerly problematic locales', () => {
useDataQuery.mockReturnValue({
data: { userSettings: { keyUiLocale: 'pt_BR' } },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('ltr')
// Notice different locale formats
Expand All @@ -109,7 +109,7 @@ describe('formerly problematic locales', () => {
useDataQuery.mockReturnValue({
data: { userSettings: { keyUiLocale: 'ar_EG' } },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('rtl')
expect(result.current.locale.baseName).toBe('ar-EG')
Expand All @@ -127,7 +127,7 @@ describe('formerly problematic locales', () => {
useDataQuery.mockReturnValue({
data: { userSettings: { keyUiLocale: 'uz_UZ_Cyrl' } },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('ltr')
expect(result.current.locale.baseName).toBe('uz-Cyrl-UZ')
Expand All @@ -141,7 +141,7 @@ describe('formerly problematic locales', () => {
useDataQuery.mockReturnValue({
data: { userSettings: { keyUiLocale: 'uz_UZ_Latn' } },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('ltr')
expect(result.current.locale.baseName).toBe('uz-Latn-UZ')
Expand All @@ -166,7 +166,7 @@ describe('other userSettings cases', () => {
userSettings: { keyUiLocale: 'en', keyUiLanguageTag: 'pt-BR' },
},
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('ltr')
expect(result.current.locale.baseName).toBe('pt-BR')
Expand All @@ -180,7 +180,7 @@ describe('other userSettings cases', () => {
useDataQuery.mockReturnValue({
data: { userSettings: {} },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('rtl')
expect(result.current.locale.baseName).toBe('ar-EG')
Expand All @@ -194,7 +194,7 @@ describe('other userSettings cases', () => {
useDataQuery.mockReturnValue({
data: { userSettings: { keyUiLocale: 'shouldCauseError' } },
})
const { result, waitFor } = renderHook(() => useCurrentUserLocale())
const { result } = renderHook(() => useCurrentUserLocale())

expect(result.current.direction).toBe('rtl')
expect(result.current.locale.baseName).toBe('ar-EG')
Expand Down
Loading

0 comments on commit dd3283d

Please sign in to comment.