@availity/hooks 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [6.0.1](https://github.com/Availity/availity-react/compare/@availity/hooks@6.0.0...@availity/hooks@6.0.1) (2026-06-16)
6
+
7
+
8
+
5
9
  # [6.0.0](https://github.com/Availity/availity-react/compare/@availity/hooks@5.2.0...@availity/hooks@6.0.0) (2026-06-12)
6
10
 
7
11
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DependencyList, EffectCallback } from 'react';
2
2
  import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ import { User, ProvidersResponse as ProvidersResponse$1, PermissionsResponse as PermissionsResponse$1, Organization as Organization$1, OrganizationsResponse as OrganizationsResponse$1, AriesPaginatedResponse } from '@availity/api-axios';
3
4
 
4
5
  /**
5
6
  * @deprecated useEffectAsync is an anti-pattern. Use useEffect with an IIFE or extract async logic into a separate function instead.
@@ -18,180 +19,26 @@ interface CurrentRegion {
18
19
  }
19
20
  declare function useCurrentRegion(options?: Omit<UseQueryOptions<CurrentRegion, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<CurrentRegion, unknown>;
20
21
 
21
- interface CurrentUser {
22
- akaname: string;
23
- createDate: string;
24
- currentRegion: string;
25
- email: string;
26
- firstName: string;
27
- lastName: string;
28
- id: string;
29
- jobTitle: string;
30
- userHasSecurityException: boolean;
31
- userId: string;
32
- userValidated: boolean;
33
- }
34
- declare function useCurrentUser(options?: Omit<UseQueryOptions<CurrentUser, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<CurrentUser, unknown>;
35
-
36
- interface AriesHookBase {
37
- data: {
38
- totalCount: number;
39
- count: number;
40
- offSet: number;
41
- links: {
42
- next: {
43
- href: string;
44
- };
45
- last: {
46
- href: string;
47
- };
48
- self: {
49
- href: string;
50
- };
51
- };
52
- };
53
- }
22
+ /** @deprecated Use `User` from `@availity/api-axios` instead */
23
+ type CurrentUser = User;
24
+ declare function useCurrentUser(options?: Omit<UseQueryOptions<User, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<User, unknown>;
54
25
 
55
- interface ProvidersResponse extends AriesHookBase {
56
- data: AriesHookBase['data'] & {
57
- providers: {
58
- id: string;
59
- lastName: string;
60
- firstName: string;
61
- middleName: string;
62
- uiDisplayName: string;
63
- atypical: boolean;
64
- npi: string;
65
- customerIds: string[];
66
- roles: {
67
- code: string;
68
- value: string;
69
- }[];
70
- primarySpecialty: {
71
- code: string;
72
- value: string;
73
- };
74
- primaryFax: {
75
- internationalCellularCode: string;
76
- areaCode: string;
77
- phoneNumber: string;
78
- };
79
- primaryAddress: {
80
- line1: string;
81
- line2: string;
82
- city: string;
83
- state: string;
84
- stateCode: string;
85
- zip: {
86
- code: string;
87
- addon: string;
88
- };
89
- };
90
- }[];
91
- };
92
- }
26
+ /** @deprecated Use `ProvidersResponse` from `@availity/api-axios` instead */
27
+ type ProvidersResponse = ProvidersResponse$1;
93
28
  interface AvProvidersConfig {
94
29
  customerId: string;
95
30
  [key: string]: unknown;
96
31
  }
97
32
  declare function useProviders(config: AvProvidersConfig, options?: Omit<UseQueryOptions<ProvidersResponse, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<ProvidersResponse, unknown>;
98
33
 
99
- interface PermissionsResponse extends AriesHookBase {
100
- data: AriesHookBase['data'] & {
101
- permissions: {
102
- id: string;
103
- description: string;
104
- links: {
105
- self: {
106
- href: string;
107
- };
108
- };
109
- }[];
110
- };
111
- }
34
+ /** @deprecated Use `PermissionsResponse` from `@availity/api-axios` instead */
35
+ type PermissionsResponse = PermissionsResponse$1;
112
36
  declare function usePermissions(config: string | string[], options?: Omit<UseQueryOptions<PermissionsResponse, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<PermissionsResponse, unknown>;
113
37
 
114
- interface Organization {
115
- links: {
116
- permissions: {
117
- href: string;
118
- };
119
- patients: {
120
- href: string;
121
- };
122
- self: {
123
- href: string;
124
- };
125
- admin: {
126
- href: string;
127
- };
128
- businessArrangements: {
129
- href: string;
130
- };
131
- users: {
132
- href: string;
133
- };
134
- };
135
- id: string;
136
- customerId: string;
137
- name: string;
138
- status: string;
139
- statusCode: string;
140
- types: {
141
- code: string;
142
- value: string;
143
- }[];
144
- primaryControllingAuthority: {
145
- lastName: string;
146
- firstName: string;
147
- primaryPhone: string;
148
- email: string;
149
- };
150
- physicalAddress: {
151
- line1: string;
152
- city: string;
153
- state: string;
154
- stateCode: string;
155
- zipCode: string;
156
- };
157
- mailingAddress: {
158
- line1: string;
159
- city: string;
160
- state: string;
161
- stateCode: string;
162
- zipCode: string;
163
- };
164
- billingAddress: {
165
- line1: string;
166
- city: string;
167
- state: string;
168
- stateCode: string;
169
- zipCode: string;
170
- };
171
- regions: {
172
- code: string;
173
- value: string;
174
- }[];
175
- npis: {
176
- number: string;
177
- }[];
178
- taxIds: {
179
- number: string;
180
- type: string;
181
- }[];
182
- phoneNumber: {
183
- areaCode: string;
184
- exchange: string;
185
- phoneNumber: string;
186
- };
187
- numberOfLicensedPhysicians: string;
188
- numberOfLicensedClinicians: string;
189
- }
190
- interface OrganizationsResponse extends AriesHookBase {
191
- data: AriesHookBase['data'] & {
192
- organizations: Organization[];
193
- };
194
- }
38
+ /** @deprecated Use `Organization` from `@availity/api-axios` instead */
39
+ type Organization = Organization$1;
40
+ /** @deprecated Use `OrganizationsResponse` from `@availity/api-axios` instead */
41
+ type OrganizationsResponse = OrganizationsResponse$1;
195
42
  declare function useOrganizations(config: Record<string, unknown>, options?: Omit<UseQueryOptions<OrganizationsResponse, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<OrganizationsResponse, unknown>;
196
43
 
197
44
  declare const useUpdateNav: () => void;
@@ -205,4 +52,7 @@ declare function useWindowDimensions(): Dimensions;
205
52
  type StashData = Record<string, unknown>;
206
53
  declare function useStash(sessionId: string, options?: Omit<UseQueryOptions<StashData, unknown>, 'queryKey' | 'queryFn'>): UseQueryResult<StashData, unknown>;
207
54
 
55
+ /** @deprecated Use `AriesPaginatedResponse` from `@availity/api-axios` instead */
56
+ type AriesHookBase = AriesPaginatedResponse;
57
+
208
58
  export { type AriesHookBase, type AvProvidersConfig, type CurrentRegion, type CurrentUser, type Dimensions, type Organization, type OrganizationsResponse, type PermissionsResponse, type ProvidersResponse, useCurrentRegion, useCurrentUser, useEffectAsync, useMount, useOrganizations, usePermissions, useProviders, useStash, useTimeout, useToggle, useUpdateNav, useWindowDimensions };
package/dist/index.js CHANGED
@@ -86,7 +86,9 @@ function usePermissions(config, options) {
86
86
 
87
87
  // src/useOrganizations.ts
88
88
  import { useQuery as useQuery5 } from "@tanstack/react-query";
89
- import { avOrganizationsApi } from "@availity/api-axios";
89
+ import {
90
+ avOrganizationsApi
91
+ } from "@availity/api-axios";
90
92
  var fetchOrganization = async (config) => avOrganizationsApi.getOrganizations(config);
91
93
  function useOrganizations(config, options) {
92
94
  return useQuery5({ queryKey: ["organizations", config], queryFn: () => fetchOrganization(config), ...options });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/hooks",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "A group of pre-built hooks that are common in most apps",
5
5
  "keywords": [
6
6
  "react",
@@ -27,8 +27,8 @@
27
27
  "clean": "rm -rf dist"
28
28
  },
29
29
  "devDependencies": {
30
- "@availity/api-axios": "^13.0.2",
31
- "@availity/message-core": "^9.0.2",
30
+ "@availity/api-axios": "^13.2.0",
31
+ "@availity/message-core": "^9.2.0",
32
32
  "@tanstack/react-query": "^5.75.5",
33
33
  "axios": "^1.17.0",
34
34
  "react": "^18.3.1",
@@ -47,13 +47,13 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
+ "main": "./dist/index.js",
50
51
  "exports": {
51
52
  ".": {
52
53
  "source": "./src/index.ts",
53
- "import": {
54
- "types": "./dist/index.d.ts",
55
- "default": "./dist/index.js"
56
- }
57
- }
54
+ "types": "./dist/index.d.ts",
55
+ "import": "./dist/index.js"
56
+ },
57
+ "./package.json": "./package.json"
58
58
  }
59
59
  }
package/project.json CHANGED
@@ -27,15 +27,12 @@
27
27
  "lint": {
28
28
  "executor": "@nx/eslint:lint",
29
29
  "options": {
30
- "eslintConfig": ".eslintrc.yaml",
31
30
  "silent": false,
32
31
  "fix": false,
33
32
  "cache": true,
34
33
  "cacheLocation": "./node_modules/.cache/hooks/.eslintcache",
35
34
  "maxWarnings": -1,
36
35
  "quiet": false,
37
- "noEslintrc": false,
38
- "hasTypeAwareRules": true,
39
36
  "cacheStrategy": "metadata"
40
37
  }
41
38
  },
package/src/types.ts CHANGED
@@ -1,12 +1,4 @@
1
- export interface AriesHookBase {
2
- data: {
3
- totalCount: number;
4
- count: number;
5
- offSet: number;
6
- links: {
7
- next: { href: string };
8
- last: { href: string };
9
- self: { href: string };
10
- };
11
- };
12
- }
1
+ import { AriesPaginatedResponse } from '@availity/api-axios';
2
+
3
+ /** @deprecated Use `AriesPaginatedResponse` from `@availity/api-axios` instead */
4
+ export type AriesHookBase = AriesPaginatedResponse;
@@ -1,5 +1,5 @@
1
1
  import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
- import { avRegionsApi } from '@availity/api-axios';
2
+ import { avRegionsApi, Region } from '@availity/api-axios';
3
3
 
4
4
  export interface CurrentRegion {
5
5
  code: string;
@@ -8,7 +8,7 @@ export interface CurrentRegion {
8
8
 
9
9
  async function fetchRegion(): Promise<CurrentRegion> {
10
10
  const response = await avRegionsApi.getCurrentRegion();
11
- const data = response?.data as { regions?: { id?: string; value?: string }[] };
11
+ const data = response?.data as { regions?: Region[] };
12
12
 
13
13
  return {
14
14
  code: data?.regions?.[0]?.id || '',
@@ -1,24 +1,13 @@
1
- import { avUserApi } from '@availity/api-axios';
1
+ import { avUserApi, User } from '@availity/api-axios';
2
2
  import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
3
 
4
- export interface CurrentUser {
5
- akaname: string;
6
- createDate: string;
7
- currentRegion: string;
8
- email: string;
9
- firstName: string;
10
- lastName: string;
11
- id: string;
12
- jobTitle: string;
13
- userHasSecurityException: boolean;
14
- userId: string;
15
- userValidated: boolean;
16
- }
4
+ /** @deprecated Use `User` from `@availity/api-axios` instead */
5
+ export type CurrentUser = User;
17
6
 
18
- const fetchUser = async () => avUserApi.me() as unknown as CurrentUser;
7
+ const fetchUser = async () => avUserApi.me() as unknown as User;
19
8
 
20
9
  export default function useCurrentUser(
21
- options?: Omit<UseQueryOptions<CurrentUser, unknown>, 'queryKey' | 'queryFn'>
22
- ): UseQueryResult<CurrentUser, unknown> {
10
+ options?: Omit<UseQueryOptions<User, unknown>, 'queryKey' | 'queryFn'>
11
+ ): UseQueryResult<User, unknown> {
23
12
  return useQuery({ queryKey: ['user'], queryFn: fetchUser, ...options });
24
13
  }
@@ -1,66 +1,15 @@
1
1
  import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
- import { avOrganizationsApi } from '@availity/api-axios';
3
- import { AriesHookBase } from './types';
2
+ import {
3
+ avOrganizationsApi,
4
+ Organization as ApiOrganization,
5
+ OrganizationsResponse as ApiOrganizationsResponse,
6
+ } from '@availity/api-axios';
4
7
 
5
- export interface Organization {
6
- links: {
7
- permissions: { href: string };
8
- patients: { href: string };
9
- self: { href: string };
10
- admin: { href: string };
11
- businessArrangements: { href: string };
12
- users: { href: string };
13
- };
14
- id: string;
15
- customerId: string;
16
- name: string;
17
- status: string;
18
- statusCode: string;
19
- types: { code: string; value: string }[];
20
- primaryControllingAuthority: {
21
- lastName: string;
22
- firstName: string;
23
- primaryPhone: string;
24
- email: string;
25
- };
26
- physicalAddress: {
27
- line1: string;
28
- city: string;
29
- state: string;
30
- stateCode: string;
31
- zipCode: string;
32
- };
33
- mailingAddress: {
34
- line1: string;
35
- city: string;
36
- state: string;
37
- stateCode: string;
38
- zipCode: string;
39
- };
40
- billingAddress: {
41
- line1: string;
42
- city: string;
43
- state: string;
44
- stateCode: string;
45
- zipCode: string;
46
- };
47
- regions: { code: string; value: string }[];
48
- npis: { number: string }[];
49
- taxIds: { number: string; type: string }[];
50
- phoneNumber: {
51
- areaCode: string;
52
- exchange: string;
53
- phoneNumber: string;
54
- };
55
- numberOfLicensedPhysicians: string;
56
- numberOfLicensedClinicians: string;
57
- }
8
+ /** @deprecated Use `Organization` from `@availity/api-axios` instead */
9
+ export type Organization = ApiOrganization;
58
10
 
59
- export interface OrganizationsResponse extends AriesHookBase {
60
- data: AriesHookBase['data'] & {
61
- organizations: Organization[];
62
- };
63
- }
11
+ /** @deprecated Use `OrganizationsResponse` from `@availity/api-axios` instead */
12
+ export type OrganizationsResponse = ApiOrganizationsResponse;
64
13
 
65
14
  const fetchOrganization = async (config: Record<string, unknown>) =>
66
15
  avOrganizationsApi.getOrganizations(config) as unknown as OrganizationsResponse;
@@ -1,16 +1,8 @@
1
1
  import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
- import { avPermissionsApi } from '@availity/api-axios';
3
- import { AriesHookBase } from './types';
2
+ import { avPermissionsApi, PermissionsResponse as ApiPermissionsResponse } from '@availity/api-axios';
4
3
 
5
- export interface PermissionsResponse extends AriesHookBase {
6
- data: AriesHookBase['data'] & {
7
- permissions: {
8
- id: string;
9
- description: string;
10
- links: { self: { href: string } };
11
- }[];
12
- };
13
- }
4
+ /** @deprecated Use `PermissionsResponse` from `@availity/api-axios` instead */
5
+ export type PermissionsResponse = ApiPermissionsResponse;
14
6
 
15
7
  const fetchPermissions = async (config: string | string[]) =>
16
8
  avPermissionsApi.getPermissions(config) as unknown as PermissionsResponse;
@@ -1,36 +1,8 @@
1
1
  import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
- import { avProvidersApi } from '@availity/api-axios';
3
- import { AriesHookBase } from './types';
2
+ import { avProvidersApi, ProvidersResponse as ApiProvidersResponse } from '@availity/api-axios';
4
3
 
5
- export interface ProvidersResponse extends AriesHookBase {
6
- data: AriesHookBase['data'] & {
7
- providers: {
8
- id: string;
9
- lastName: string;
10
- firstName: string;
11
- middleName: string;
12
- uiDisplayName: string;
13
- atypical: boolean;
14
- npi: string;
15
- customerIds: string[];
16
- roles: { code: string; value: string }[];
17
- primarySpecialty: { code: string; value: string };
18
- primaryFax: {
19
- internationalCellularCode: string;
20
- areaCode: string;
21
- phoneNumber: string;
22
- };
23
- primaryAddress: {
24
- line1: string;
25
- line2: string;
26
- city: string;
27
- state: string;
28
- stateCode: string;
29
- zip: { code: string; addon: string };
30
- };
31
- }[];
32
- };
33
- }
4
+ /** @deprecated Use `ProvidersResponse` from `@availity/api-axios` instead */
5
+ export type ProvidersResponse = ApiProvidersResponse;
34
6
 
35
7
  export interface AvProvidersConfig {
36
8
  customerId: string;
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { waitFor, cleanup } from '@testing-library/react';
3
+ import { QueryClient } from '@tanstack/react-query';
4
+ import { http, HttpResponse } from 'msw';
5
+ import { server } from '@availity/mock/src/server';
6
+ import { REGIONS } from '@availity/mock/src/routes';
7
+ import { useCurrentRegion } from '../src/index';
8
+ import renderWithClient from './util';
9
+
10
+ const queryClient = new QueryClient();
11
+
12
+ afterEach(() => {
13
+ cleanup();
14
+ queryClient.clear();
15
+ });
16
+
17
+ const Component = () => {
18
+ const { data, error, status } = useCurrentRegion({ gcTime: 0, retry: false });
19
+
20
+ return (
21
+ <div>
22
+ <h1>Status: {status}</h1>
23
+ <h1>Data: {JSON.stringify(data)}</h1>
24
+ <h1>Error: {error?.message}</h1>
25
+ </div>
26
+ );
27
+ };
28
+
29
+ describe('useCurrentRegion', () => {
30
+ test('handle error', async () => {
31
+ server.use(http.get(REGIONS, () => HttpResponse.error()));
32
+
33
+ const { getByText } = renderWithClient(queryClient, <Component />);
34
+
35
+ getByText('Status: pending');
36
+ await waitFor(() => {
37
+ expect(getByText('Status: error')).toBeDefined();
38
+ });
39
+ });
40
+
41
+ test('handle success', async () => {
42
+ const { getByText } = renderWithClient(queryClient, <Component />);
43
+
44
+ getByText('Status: pending');
45
+ await waitFor(() => {
46
+ expect(getByText(`Data: ${JSON.stringify({ code: 'FL', value: 'Florida' })}`)).toBeDefined();
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { waitFor, cleanup } from '@testing-library/react';
3
+ import { QueryClient } from '@tanstack/react-query';
4
+ import { http, HttpResponse } from 'msw';
5
+ import { server } from '@availity/mock/src/server';
6
+ import { USER_A2 } from '@availity/mock/src/routes';
7
+ import { useCurrentUser } from '../src/index';
8
+ import renderWithClient from './util';
9
+
10
+ const queryClient = new QueryClient();
11
+
12
+ afterEach(() => {
13
+ cleanup();
14
+ queryClient.clear();
15
+ });
16
+
17
+ const Component = () => {
18
+ const { data, error, status } = useCurrentUser({ gcTime: 0, retry: false });
19
+
20
+ return (
21
+ <div>
22
+ <h1>Status: {status}</h1>
23
+ <h1>Data: {JSON.stringify(data)}</h1>
24
+ <h1>Error: {error?.message}</h1>
25
+ </div>
26
+ );
27
+ };
28
+
29
+ describe('useCurrentUser', () => {
30
+ test('should set error on rejected promise', async () => {
31
+ server.use(http.get(USER_A2, () => HttpResponse.error()));
32
+
33
+ const { getByText } = renderWithClient(queryClient, <Component />);
34
+
35
+ getByText('Status: pending');
36
+ await waitFor(() => {
37
+ expect(getByText('Status: error')).toBeDefined();
38
+ });
39
+ });
40
+
41
+ test('should return user', async () => {
42
+ const { getByText } = renderWithClient(queryClient, <Component />);
43
+
44
+ getByText('Status: pending');
45
+ await waitFor(() => {
46
+ expect(getByText(/aka123456789/)).toBeDefined();
47
+ });
48
+ await waitFor(() => {
49
+ expect(getByText(/Sanchez/)).toBeDefined();
50
+ });
51
+ });
52
+ });
@@ -4,8 +4,7 @@ import { useEffectAsync } from '../src/index';
4
4
 
5
5
  afterEach(cleanup);
6
6
 
7
- // eslint-disable-next-line react/prop-types
8
- const Component = ({ asyncFunc }) => {
7
+ const Component = ({ asyncFunc }: { asyncFunc: () => Promise<string> }) => {
9
8
  const [state, setState] = useState('Hello');
10
9
 
11
10
  useEffectAsync(async () => {
@@ -20,17 +19,12 @@ const asyncFunc = () => Promise.resolve('World');
20
19
 
21
20
  describe('useEffectAsync', () => {
22
21
  test('should render "Hello" then "World"', async () => {
23
- // Create Async Method
24
- // Render
25
22
  const { getByTestId } = render(<Component asyncFunc={asyncFunc} />);
26
23
 
27
- // Expect the component to render "Hello"
28
24
  expect(getByTestId('effect-test').textContent).toEqual('Hello');
29
25
 
30
- // Wait for the Async Function to be called after mounting
31
26
  await waitFor(() => getByTestId('effect-test'));
32
27
 
33
- // Expect the component to render "World"
34
28
  expect(getByTestId('effect-test').textContent).toEqual('World');
35
29
  });
36
30
  });
@@ -4,9 +4,8 @@ import { useMount } from '../src/index';
4
4
 
5
5
  afterEach(cleanup);
6
6
 
7
- // eslint-disable-next-line react/prop-types
8
7
  const Component = () => {
9
- const [state, setState] = useState();
8
+ const [state, setState] = useState<string | undefined>();
10
9
 
11
10
  useMount(() => {
12
11
  setState('test');
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { waitFor, cleanup } from '@testing-library/react';
3
+ import { QueryClient } from '@tanstack/react-query';
4
+ import { http, HttpResponse } from 'msw';
5
+ import { server } from '@availity/mock/src/server';
6
+ import { USER_A2 } from '@availity/mock/src/routes';
7
+ import renderWithClient from './util';
8
+ import { useOrganizations } from '../src/index';
9
+
10
+ const queryClient = new QueryClient();
11
+
12
+ afterEach(() => {
13
+ cleanup();
14
+ queryClient.clear();
15
+ });
16
+
17
+ const Component = () => {
18
+ const { data, error, status } = useOrganizations({}, { gcTime: 0, retry: false });
19
+
20
+ return (
21
+ <div>
22
+ <h1>Status: {status}</h1>
23
+ <h1>Data: {JSON.stringify(data?.data)}</h1>
24
+ <h1>Error: {error?.message}</h1>
25
+ </div>
26
+ );
27
+ };
28
+
29
+ describe('useOrganizations', () => {
30
+ test('should return an error', async () => {
31
+ server.use(http.get(USER_A2, () => HttpResponse.error()));
32
+
33
+ const { getByText } = renderWithClient(queryClient, <Component />);
34
+
35
+ getByText('Status: pending');
36
+ await waitFor(() => {
37
+ expect(getByText('Status: error')).toBeDefined();
38
+ });
39
+ });
40
+
41
+ test('should return organizations', async () => {
42
+ const { getByText } = renderWithClient(queryClient, <Component />);
43
+
44
+ getByText('Status: pending');
45
+ await waitFor(() => {
46
+ expect(getByText(/Techmania/)).toBeDefined();
47
+ });
48
+ });
49
+ });