Skip to content

Commit

Permalink
use @jest/globals
Browse files Browse the repository at this point in the history
  • Loading branch information
trajano authored and janicduplessis committed Dec 13, 2023
1 parent 252c123 commit 9cd3927
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
13 changes: 10 additions & 3 deletions jest/mock.tsx
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/InitialWindow-test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it, jest } from '@jest/globals';
import type { Metrics } from '../SafeArea.types';

describe('InitialWindow', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/SafeAreaContext-test.tsx
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/SafeAreaView-test.tsx
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
12 changes: 2 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit 9cd3927

Please sign in to comment.