-
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.
Merge pull request #977 from CruGlobal/MPDX-8022-fix-newsletter-status
MPDX-8022 - Fix Send Newsletter: Contact Status Display Value
- Loading branch information
Showing
3 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/components/Tool/FixSendNewsletter/FindSendNewsletter.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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import { SnackbarProvider } from 'notistack'; | ||
import TestRouter from '__tests__/util/TestRouter'; | ||
import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
import { StatusEnum } from 'src/graphql/types.generated'; | ||
import theme from 'src/theme'; | ||
import FixSendNewsletter from './FixSendNewsletter'; | ||
import { | ||
GetInvalidNewsletterQuery, | ||
useGetInvalidNewsletterQuery, | ||
} from './GetInvalidNewsletter.generated'; | ||
|
||
jest.mock('./GetInvalidNewsletter.generated'); | ||
|
||
const mockEnqueue = jest.fn(); | ||
jest.mock('notistack', () => ({ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
...jest.requireActual('notistack'), | ||
useSnackbar: () => { | ||
return { | ||
enqueueSnackbar: mockEnqueue, | ||
}; | ||
}, | ||
})); | ||
|
||
const accountListId = 'account-id'; | ||
const contactId = 'contact-id'; | ||
const router = { | ||
isReady: true, | ||
}; | ||
const setContactFocus = jest.fn(); | ||
|
||
const TestComponent = () => ( | ||
<SnackbarProvider> | ||
<TestRouter router={router}> | ||
<ThemeProvider theme={theme}> | ||
<GqlMockedProvider<{ InvalidNewsletters: GetInvalidNewsletterQuery }>> | ||
<FixSendNewsletter | ||
accountListId={accountListId} | ||
setContactFocus={setContactFocus} | ||
/> | ||
</GqlMockedProvider> | ||
</ThemeProvider> | ||
</TestRouter> | ||
</SnackbarProvider> | ||
); | ||
|
||
describe('FixSendNewsletter', () => { | ||
beforeEach(() => { | ||
setContactFocus.mockClear(); | ||
}); | ||
beforeEach(() => { | ||
(useGetInvalidNewsletterQuery as jest.Mock).mockReturnValue({ | ||
data: { | ||
contacts: { | ||
nodes: [ | ||
{ | ||
id: contactId, | ||
name: 'Contact Name', | ||
status: StatusEnum.PartnerPray, | ||
}, | ||
], | ||
}, | ||
constant: { | ||
status: [{ id: StatusEnum.PartnerPray, value: 'Partner - Pray' }], | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
describe('render', () => { | ||
it('should show the readable value of contact status', async () => { | ||
const { getByText } = render(<TestComponent />); | ||
|
||
await waitFor(() => { | ||
expect(getByText('Partner - Pray')).toBeVisible(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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