diff --git a/jest/mock.tsx b/jest/mock.tsx index ccad0d77..ed01019f 100644 --- a/jest/mock.tsx +++ b/jest/mock.tsx @@ -1,7 +1,11 @@ -/* global jest */ +import { jest } from '@jest/globals'; import React, { useContext } from 'react'; import type { Metrics } from '../src/SafeArea.types'; -import type { SafeAreaProviderProps } from '../src/SafeAreaContext'; +import type { + SafeAreaProviderProps, + SafeAreaInsetsContext, + SafeAreaFrameContext, +} from '../src/SafeAreaContext'; const MOCK_INITIAL_METRICS: Metrics = { frame: { @@ -18,7 +22,10 @@ const MOCK_INITIAL_METRICS: Metrics = { }, }; -const RNSafeAreaContext = jest.requireActual('react-native-safe-area-context'); +const RNSafeAreaContext = jest.requireActual<{ + SafeAreaInsetsContext: typeof SafeAreaInsetsContext; + SafeAreaFrameContext: typeof SafeAreaFrameContext; +}>('react-native-safe-area-context'); export default { ...RNSafeAreaContext, diff --git a/package.json b/package.json index e77e11aa..11e51b98 100644 --- a/package.json +++ b/package.json @@ -60,11 +60,11 @@ }, "devDependencies": { "@commitlint/config-conventional": "^18.4.3", + "@jest/globals": "^29.7.0", "@react-native-community/eslint-config": "^3.2.0", "@react-native/babel-preset": "^0.73.18", "@react-native/eslint-plugin-specs": "^0.74.0", "@release-it/conventional-changelog": "^8.0.1", - "@types/jest": "^29.5.11", "@types/react": "^18.2.45", "@types/react-dom": "^18.2.17", "@types/react-test-renderer": "^18.0.7", diff --git a/src/__tests__/InitialWindow-test.tsx b/src/__tests__/InitialWindow-test.tsx index c2f9f137..3097eab3 100644 --- a/src/__tests__/InitialWindow-test.tsx +++ b/src/__tests__/InitialWindow-test.tsx @@ -1,3 +1,4 @@ +import { describe, expect, it, jest } from '@jest/globals'; import type { Metrics } from '../SafeArea.types'; describe('InitialWindow', () => { diff --git a/src/__tests__/SafeAreaContext-test.tsx b/src/__tests__/SafeAreaContext-test.tsx index b7c9a8ae..be8daa8b 100644 --- a/src/__tests__/SafeAreaContext-test.tsx +++ b/src/__tests__/SafeAreaContext-test.tsx @@ -1,13 +1,14 @@ +import { describe, expect, it, jest } from '@jest/globals'; import * as React from 'react'; import { View } from 'react-native'; import * as ReactTestRenderer from 'react-test-renderer'; import { NativeSafeAreaProvider } from '../NativeSafeAreaProvider'; +import type { Metrics } from '../SafeArea.types'; import { SafeAreaProvider, - useSafeAreaInsets, useSafeAreaFrame, + useSafeAreaInsets, } from '../SafeAreaContext'; -import type { Metrics } from '../SafeArea.types'; const TEST_METRICS_1: Metrics = { insets: { top: 1, left: 2, right: 3, bottom: 4 }, diff --git a/src/__tests__/SafeAreaView-test.tsx b/src/__tests__/SafeAreaView-test.tsx index 4a667b54..85090ac4 100644 --- a/src/__tests__/SafeAreaView-test.tsx +++ b/src/__tests__/SafeAreaView-test.tsx @@ -1,9 +1,10 @@ +import { describe, expect, it } from '@jest/globals'; import * as React from 'react'; import { View } from 'react-native'; import * as ReactTestRenderer from 'react-test-renderer'; +import type { Metrics } from '../SafeArea.types'; import { SafeAreaProvider } from '../SafeAreaContext'; import { SafeAreaView } from '../SafeAreaView'; -import type { Metrics } from '../SafeArea.types'; const INITIAL_METRICS: Metrics = { insets: { top: 1, left: 2, right: 3, bottom: 4 }, diff --git a/yarn.lock b/yarn.lock index 9dce48de..76c620f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2370,14 +2370,6 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^29.5.11": - version "29.5.11" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.11.tgz#0c13aa0da7d0929f078ab080ae5d4ced80fa2f2c" - integrity sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ== - dependencies: - expect "^29.0.0" - pretty-format "^29.0.0" - "@types/json-schema@^7.0.12", "@types/json-schema@^7.0.9": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" @@ -4562,7 +4554,7 @@ exit@^0.1.2: resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== -expect@^29.0.0, expect@^29.7.0: +expect@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/expect/-/expect-29.7.0.tgz#578874590dcb3214514084c08115d8aee61e11bc" integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== @@ -7606,7 +7598,7 @@ pretty-format@^26.5.2, pretty-format@^26.6.2: ansi-styles "^4.0.0" react-is "^17.0.1" -pretty-format@^29.0.0, pretty-format@^29.7.0: +pretty-format@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==