-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests and add useMemo for checking the organization
- Loading branch information
1 parent
ed4e90a
commit 78cb0f0
Showing
3 changed files
with
72 additions
and
80 deletions.
There are no files selected for viewing
122 changes: 62 additions & 60 deletions
122
src/components/Shared/staticBanner/StaticBanner.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,81 @@ | ||
import { render } from '@testing-library/react'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
import { GetUsersOrganizationsQuery } from './getOrganizationType.generated'; | ||
import { StaticBanner } from './StaticBanner'; | ||
|
||
const mockResponse = { | ||
userOrganizationAccounts: [ | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
apiClass: 'OfflineOrg', | ||
id: '0673b517-4f4d-4c47-965e-0757a198a8a4', | ||
name: 'Cru - New Staff', | ||
oauth: false, | ||
organizationType: 'Non-Cru', | ||
const mockResponseNonCru = { | ||
GetUsersOrganizations: { | ||
userOrganizationAccounts: [ | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
organizationType: 'Non-Cru', | ||
}, | ||
}, | ||
latestDonationDate: null, | ||
lastDownloadedAt: '2023-10-25T06:14:34-07:00', | ||
username: null, | ||
}, | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
apiClass: 'OfflineOrg', | ||
id: '1a122b65-d98f-45c7-a2ab-c3c62da63405', | ||
name: 'Campus Crusade for Christ - Egypt', | ||
oauth: false, | ||
organizationType: 'Non-Cru', | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
organizationType: 'Non-Cru', | ||
}, | ||
}, | ||
latestDonationDate: null, | ||
lastDownloadedAt: '2023-10-25T06:14:34-07:00', | ||
username: null, | ||
}, | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
apiClass: 'Siebel', | ||
id: '7ab3ec4b-7108-40bf-a998-ce813d10c821', | ||
name: 'Cru - United States of America', | ||
oauth: false, | ||
organizationType: 'Non-Cru', | ||
], | ||
}, | ||
}; | ||
const mockResponseCru = { | ||
GetUsersOrganizations: { | ||
userOrganizationAccounts: [ | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
organizationType: 'Cru', | ||
}, | ||
}, | ||
latestDonationDate: null, | ||
lastDownloadedAt: '2023-10-25T06:14:35-07:00', | ||
username: null, | ||
}, | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
apiClass: 'OfflineOrg', | ||
id: 'b213e64b-7e76-4ef1-b756-075ec52b61d7', | ||
name: 'Center for Bio-Ethical Reform', | ||
oauth: false, | ||
organizationType: 'Non-Cru', | ||
{ | ||
__typename: 'OrganizationAccount', | ||
organization: { | ||
__typename: 'Organization', | ||
organizationType: 'Non-Cru', | ||
}, | ||
}, | ||
latestDonationDate: null, | ||
lastDownloadedAt: '2023-10-25T06:14:34-07:00', | ||
username: null, | ||
}, | ||
], | ||
], | ||
}, | ||
}; | ||
|
||
test('static banner displays', () => { | ||
test('static banner displays for user in Non-Cru org', async () => { | ||
const { queryByTestId } = render( | ||
<GqlMockedProvider<{ userOrganizationAccounts: GetUsersOrganizationsQuery }> | ||
<GqlMockedProvider<{ | ||
GetUsersOrganizations: GetUsersOrganizationsQuery; | ||
}> | ||
mocks={{ | ||
mockResponse, | ||
mockResponseNonCru, | ||
}} | ||
> | ||
<StaticBanner /> | ||
</GqlMockedProvider>, | ||
); | ||
|
||
expect(queryByTestId('nonCruOrgReminder')).toBeInTheDocument(); | ||
await waitFor(() => | ||
expect(queryByTestId('nonCruOrgReminder')).toBeInTheDocument(), | ||
); | ||
}); | ||
|
||
test('static banner does not display for user in a Cru org', async () => { | ||
const { queryByTestId } = render( | ||
<GqlMockedProvider<{ | ||
GetUsersOrganizations: GetUsersOrganizationsQuery; | ||
}> | ||
mocks={{ | ||
mockResponseCru, | ||
}} | ||
> | ||
<StaticBanner /> | ||
</GqlMockedProvider>, | ||
); | ||
|
||
await waitFor(() => | ||
expect(queryByTestId('nonCruOrgReminder')).not.toBeInTheDocument(), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/components/Shared/staticBanner/getOrganizationType.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
query GetUsersOrganizations { | ||
userOrganizationAccounts { | ||
organization { | ||
apiClass | ||
id | ||
name | ||
oauth | ||
organizationType | ||
} | ||
latestDonationDate | ||
lastDownloadedAt | ||
username | ||
} | ||
} |