Skip to content

Commit b9b8a8b

Browse files
committed
update all tests
1 parent 084f599 commit b9b8a8b

File tree

74 files changed

+1120
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1120
-1162
lines changed

static/app/actionCreators/savedSearches.spec.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ describe('useFetchRecentSearches', () => {
3535
],
3636
});
3737

38-
const {result} = renderHookWithProviders(
39-
() =>
40-
useFetchRecentSearches({
41-
savedSearchType: SavedSearchType.TRACEMETRIC,
42-
namespace,
43-
}),
44-
{organization}
45-
);
38+
const {result} = renderHookWithProviders(useFetchRecentSearches, {
39+
organization,
40+
initialProps: {
41+
savedSearchType: SavedSearchType.TRACEMETRIC,
42+
namespace,
43+
},
44+
});
4645

4746
await waitFor(() => expect(result.current.isSuccess).toBe(true));
4847

static/app/bootstrap/boostrapRequests.spec.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ describe('useBootstrapOrganizationQuery', () => {
4949
query: {detailed: 0, include_feature_flags: 1},
5050
});
5151

52-
const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
52+
const {result} = renderHook(useBootstrapOrganizationQuery, {
53+
wrapper,
54+
initialProps: orgSlug,
55+
});
5356

5457
await waitFor(() => expect(result.current.data).toBeDefined());
5558
expect(JSON.stringify(OrganizationStore.get().organization)).toEqual(
@@ -64,7 +67,10 @@ describe('useBootstrapOrganizationQuery', () => {
6467
body: {},
6568
});
6669

67-
const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
70+
const {result} = renderHook(useBootstrapOrganizationQuery, {
71+
wrapper,
72+
initialProps: orgSlug,
73+
});
6874

6975
await waitFor(() => expect(result.current.error).toBeDefined());
7076
expect(OrganizationStore.get().organization).toBeNull();
@@ -75,7 +81,10 @@ describe('useBootstrapOrganizationQuery', () => {
7581
});
7682

7783
it('does not fetch when orgSlug is null', () => {
78-
const {result} = renderHook(() => useBootstrapOrganizationQuery(null), {wrapper});
84+
const {result} = renderHook(useBootstrapOrganizationQuery, {
85+
wrapper,
86+
initialProps: null,
87+
});
7988
expect(result.current.data).toBeUndefined();
8089
});
8190

@@ -84,7 +93,10 @@ describe('useBootstrapOrganizationQuery', () => {
8493
orgSlug: org.slug,
8594
organization: Promise.resolve<ApiResult<Organization>>([org, undefined, undefined]),
8695
};
87-
const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
96+
const {result} = renderHook(useBootstrapOrganizationQuery, {
97+
wrapper,
98+
initialProps: orgSlug,
99+
});
88100
await waitFor(() => expect(result.current.data).toBeDefined());
89101
expect(window.__sentry_preload?.organization).toBeUndefined();
90102
});
@@ -105,7 +117,10 @@ describe('useBootstrapOrganizationQuery', () => {
105117
query: {detailed: 0, include_feature_flags: 1},
106118
});
107119

108-
const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper});
120+
const {result} = renderHook(useBootstrapOrganizationQuery, {
121+
wrapper,
122+
initialProps: orgSlug,
123+
});
109124
await waitFor(() => expect(result.current.data).toBeDefined());
110125
expect(JSON.stringify(OrganizationStore.get().organization?.features)).toEqual(
111126
JSON.stringify(['enable-issues'])
@@ -141,7 +156,7 @@ describe('useBootstrapTeamsQuery', () => {
141156
},
142157
});
143158

144-
const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper});
159+
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug});
145160

146161
await waitFor(() => expect(result.current.data).toBeDefined());
147162
expect(TeamStore.getState().teams).toEqual(mockTeams);
@@ -154,14 +169,14 @@ describe('useBootstrapTeamsQuery', () => {
154169
statusCode: 500,
155170
});
156171

157-
const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper});
172+
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug});
158173

159174
await waitFor(() => expect(result.current.error).toBeDefined());
160175
expect(TeamStore.getState().teams).toEqual([]);
161176
});
162177

163178
it('does not fetch when orgSlug is null', () => {
164-
const {result} = renderHook(() => useBootstrapTeamsQuery(null), {wrapper});
179+
const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: null});
165180
expect(result.current.data).toBeUndefined();
166181
});
167182
});
@@ -186,7 +201,10 @@ describe('useBootstrapProjectsQuery', () => {
186201
},
187202
});
188203

189-
const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper});
204+
const {result} = renderHook(useBootstrapProjectsQuery, {
205+
wrapper,
206+
initialProps: orgSlug,
207+
});
190208

191209
await waitFor(() => expect(result.current.data).toBeDefined());
192210
expect(ProjectsStore.getState().projects).toEqual(mockProjects);
@@ -198,14 +216,17 @@ describe('useBootstrapProjectsQuery', () => {
198216
statusCode: 500,
199217
});
200218

201-
const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper});
219+
const {result} = renderHook(useBootstrapProjectsQuery, {
220+
wrapper,
221+
initialProps: orgSlug,
222+
});
202223

203224
await waitFor(() => expect(result.current.error).toBeDefined());
204225
expect(ProjectsStore.getState().projects).toEqual([]);
205226
});
206227

207228
it('does not fetch when orgSlug is null', () => {
208-
const {result} = renderHook(() => useBootstrapProjectsQuery(null), {wrapper});
229+
const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: null});
209230
expect(result.current.data).toBeUndefined();
210231
});
211232
});

static/app/components/acl/useRole.spec.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ describe('useRole', () => {
2424
});
2525

2626
it('has a sufficient role', () => {
27-
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
27+
const {result} = renderHookWithProviders(useRole, {
2828
organization,
29+
initialProps: {role: 'attachmentsRole'},
2930
});
3031
expect(result.current.hasRole).toBe(true);
3132
expect(result.current.roleRequired).toBe('admin');
@@ -37,8 +38,9 @@ describe('useRole', () => {
3738
orgRole: 'member',
3839
});
3940
OrganizationStore.onUpdate(org, {replace: true});
40-
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
41+
const {result} = renderHookWithProviders(useRole, {
4142
organization: org,
43+
initialProps: {role: 'attachmentsRole'},
4244
});
4345
expect(result.current.hasRole).toBe(false);
4446
});
@@ -50,17 +52,19 @@ describe('useRole', () => {
5052
access: ['org:superuser'],
5153
});
5254
OrganizationStore.onUpdate(org, {replace: true});
53-
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
55+
const {result} = renderHookWithProviders(useRole, {
5456
organization: org,
57+
initialProps: {role: 'attachmentsRole'},
5558
});
5659
expect(result.current.hasRole).toBe(true);
5760
});
5861

5962
it('handles no organization.orgRoleList', () => {
6063
const org = {...organization, orgRoleList: []};
6164
OrganizationStore.onUpdate(org, {replace: true});
62-
const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), {
65+
const {result} = renderHookWithProviders(useRole, {
6366
organization: org,
67+
initialProps: {role: 'attachmentsRole'},
6468
});
6569
expect(result.current.hasRole).toBe(false);
6670
});

0 commit comments

Comments
 (0)