Skip to content

Commit

Permalink
removed duplicate submit email component and added source to props up…
Browse files Browse the repository at this point in the history
…date tests
  • Loading branch information
tmanundercover committed Oct 13, 2023
1 parent 0f9baea commit 61977ae
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/components/BusinessCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const BusinessCard: FunctionComponent<MainMenuProps> = ({anchor, homePage}) => {
<Divider/>
<ListItem>
<Grid item xs={12}>
<BusinessCardSubmitEmail emailFieldText={'Email Address'}
<BusinessCardSubmitEmail source={'Business Card'} emailFieldText={'Email Address'}
emailButtonText={'Submit'}
subscribeText={'Get an email with my contact information below'}/>
</Grid>
Expand Down
23 changes: 23 additions & 0 deletions src/components/my-digital-resume/ResumeBioSection.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {render, screen} from '@testing-library/react';
import expect from "expect";
import {ResumeBioSectionComplete} from "../../stories/digital-resume/ResumeBio.stories";

describe('Resume Bio Section', () => {
test('renders all components of bio', async () => {
render(<ResumeBioSectionComplete.render {...ResumeBioSectionComplete.args}/>)

expect(await screen.findAllByRole('button')).toHaveLength(1)
expect(await screen.findAllByRole('link')).toHaveLength(8)
expect(screen.getByTestId('bio-image')).toBeInTheDocument()
expect(screen.getByTestId('social-media-block')).toBeInTheDocument()
expect(screen.getByTestId('submit-email-block')).toBeInTheDocument()
expect((await screen.findByText('Contact Me'))).toBeInTheDocument()
expect((await screen.findByText('Meet with Me'))).toBeInTheDocument()
expect((await screen.findByText('Download Resume'))).toBeInTheDocument()
expect(await screen.findByText('James Terrell Singleton')).toBeInTheDocument()
expect(await screen.findByText('I am a Web Developer located in the Maryand, District of Columbia, and Virginia Metropolitan area. I currently work as a remote fullstack software engineer for Assembled Financial, located in Los Angeles, CA. I am looking to take on more work, to increase my skills as a Web Developer, and to make things that are great. I am open to relocation.')).toBeInTheDocument()
expect(await screen.findByText('443.992.2191')).toBeInTheDocument()
expect(await screen.findByText('terrell.singleton@gmail.com')).toBeInTheDocument()
expect(await screen.findByText('7300 Roselynn Lane, Clinton, MD 20735')).toBeInTheDocument()
});
})
6 changes: 4 additions & 2 deletions src/components/my-digital-resume/ResumeBioSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const ResumeBioSection: FunctionComponent<IProps> = (props: IProps) => {
<ThemeProvider theme={TheWebsiteTheme}><Grid container item style={{padding: TheWebsiteTheme.spacing(4)}} justifyContent='center'
className={classes.resumeSection} spacing={3}>
<Grid item xs={12}>
<BusinessCardSubmitEmail emailFieldText={'Email Address'}
<BusinessCardSubmitEmail
source={"Bio Section"}
emailFieldText={'Email Address'}
emailButtonText={'Submit'}
subscribeText={'Want a copy of my resume emailed to you?'}/>
</Grid>
Expand Down Expand Up @@ -65,7 +67,7 @@ const ResumeBioSection: FunctionComponent<IProps> = (props: IProps) => {
/>
</Grid>
</Grid>
<Grid container item md={6} style={{
<Grid data-testid='bio-image' container item md={6} style={{
backgroundImage: `url(${urlFor(props.sectionData.mainImage ?? "").url()})`,
backgroundSize: "cover",
backgroundPosition: "top right",
Expand Down
4 changes: 2 additions & 2 deletions src/components/my-digital-resume/ResumeSocialMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ interface IProps {
const ResumeSocialMedia: FunctionComponent<IProps> = (props: IProps) => {
const classes = useStyles()
return (
<ThemeProvider theme={TheWebsiteTheme}>
<Grid item xs={12} container alignItems='center' justifyContent='center'
<ThemeProvider theme={TheWebsiteTheme} >
<Grid data-testid='social-media-block' item xs={12} container alignItems='center' justifyContent='center'
spacing={props.spacing ? props.spacing : 0}>
{props.facebook && <Grid item>
<Grid item className={clsx({[classes.buttonBackground]: props.bgColor})}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Business Card Submit Email', () => {
expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledTimes(1)
expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledWith({
"email": 'terrell@gmail.com',
source: "Business Card"
source: "storybook"
})
expect(screen.getByText('Thank you for your submission!')).toBeInTheDocument()
});
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('Business Card Submit Email', () => {
expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledTimes(1)
expect(leadClient.sendBusinessCardEmail).toHaveBeenCalledWith({
"email": 'terrell@gmail.com',
source: "Business Card"
source: "storybook"
})
expect(screen.queryByText('Thank you for your submission!')).not.toBeInTheDocument()
expect(screen.getByText('Please Try your submission again later or contact hello@thehandsomestnerd.com.')).toBeInTheDocument()
Expand Down
5 changes: 3 additions & 2 deletions src/components/transform-hw/pages/BusinessCardSubmitEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface SubmitEmailIProps {
emailFieldText: string
emailButtonText: string
subscribeText: string
source: string
}

const BusinessCardSubmitEmail: FunctionComponent<SubmitEmailIProps> = (props: SubmitEmailIProps) => {
Expand All @@ -57,7 +58,7 @@ const BusinessCardSubmitEmail: FunctionComponent<SubmitEmailIProps> = (props: Su
setIsLoading(true)
setIsError(false)

const response = await leadClient.sendBusinessCardEmail({email, source: "Business Card"});
const response = await leadClient.sendBusinessCardEmail({email, source: props.source});
console.log(response)

if (response.status === "400") {
Expand Down Expand Up @@ -99,7 +100,7 @@ const BusinessCardSubmitEmail: FunctionComponent<SubmitEmailIProps> = (props: Su
}


return (<Grid container item justifyContent='center'>
return (<Grid container item justifyContent='center' data-testid='submit-email-block'>
<Grid item container justifyContent='center'>
<Typography color='primary' gutterBottom variant='body2'
align='center'
Expand Down
96 changes: 0 additions & 96 deletions src/components/transform-hw/pages/SubmitEmail.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import clsx from "clsx";
import CssFadeToColor from "../../../css-fade-to-color/CssFadeToColor";
import {SanityRef, SanityUnderConstructionPageType} from "../../../../common/sanityIo/Types";
import cmsClient from "../../../block-content-ui/cmsClient";
import SubmitEmail from "../SubmitEmail";
import Logo from "../../../logo/Logo";
import {urlFor} from "../../../block-content-ui/static-pages/cmsStaticPagesClient";
import MailTo from "../../../mail-to/MailTo";
import {COLORS} from "../../../../theme/common/ColorPalette";
import CustomizedThemeContext from "../../../customized-theme-provider/CustomizedThemeContext";
import BusinessCardSubmitEmail from "../BusinessCardSubmitEmail";

interface IProps {
email?: string
Expand Down Expand Up @@ -84,7 +84,7 @@ const UnderConstruction: FunctionComponent<IProps> = (props) => {
</Grid>
<Grid container item justifyContent='center'>
<Grid container item justifyContent='center' style={{marginTop: customizedThemeContext.customizedTheme.spacing(5.75)}}>
<SubmitEmail emailFieldText={cmsPageData?.emailFieldText ?? ""}
<BusinessCardSubmitEmail source="Under Construction Page" emailFieldText={cmsPageData?.emailFieldText ?? ""}
emailButtonText={cmsPageData?.emailButtonText ?? ""}
subscribeText={cmsPageData?.subscribeText ?? ""}/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/stories/digital-resume/SubmitEmail.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const BusinessCardSubmitEmailStory: Story = {
subscribeText: "Want a copy of my resume emailed to you?"
},
render: ({emailFieldText, emailButtonText, subscribeText}: PropsWithChildren<SubmitEmailIProps>) =>
<BusinessCardSubmitEmail emailFieldText={emailFieldText}
<BusinessCardSubmitEmail source={'storybook'} emailFieldText={emailFieldText}
emailButtonText={emailButtonText}
subscribeText={subscribeText}/>,
};

0 comments on commit 61977ae

Please sign in to comment.