-
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.
Set the initial dropdown value according to the same logic as in the …
…Angular app
- Loading branch information
1 parent
c8e0a00
commit 54f1cea
Showing
4 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
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,135 @@ | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import { render } from '@testing-library/react'; | ||
import theme from 'src/theme'; | ||
import Contact from './Contact'; | ||
import { | ||
ContactPrimaryAddressFragment, | ||
ContactPrimaryPersonFragment, | ||
} from './GetInvalidNewsletter.generated'; | ||
|
||
const TestComponent = ({ | ||
primaryPerson, | ||
primaryAddress, | ||
}: { | ||
primaryPerson: ContactPrimaryPersonFragment; | ||
primaryAddress: ContactPrimaryAddressFragment; | ||
}) => ( | ||
<ThemeProvider theme={theme}> | ||
<Contact | ||
id="" | ||
name="" | ||
primaryPerson={primaryPerson} | ||
status="" | ||
primaryAddress={primaryAddress} | ||
updateFunction={jest.fn()} | ||
setContactFocus={jest.fn()} | ||
/> | ||
</ThemeProvider> | ||
); | ||
|
||
describe('Fix Newsletter - Contact', () => { | ||
describe('inital value for dropdown', () => { | ||
let primaryPerson = {} as ContactPrimaryPersonFragment; | ||
let primaryAddress = {} as ContactPrimaryAddressFragment; | ||
|
||
beforeEach(() => { | ||
primaryPerson = { | ||
firstName: '', | ||
lastName: '', | ||
primaryEmailAddress: { | ||
email: '', | ||
}, | ||
optoutEnewsletter: false, | ||
} as ContactPrimaryPersonFragment; | ||
|
||
primaryAddress = { | ||
street: '', | ||
city: '', | ||
state: '', | ||
postalCode: '', | ||
source: '', | ||
createdAt: '', | ||
} as ContactPrimaryAddressFragment; | ||
}); | ||
|
||
it('should be None', () => { | ||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['None']); | ||
}); | ||
|
||
it('should be Physical', () => { | ||
primaryAddress.street = '100 Test St'; | ||
|
||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['Physical']); | ||
}); | ||
|
||
it('should be Email', () => { | ||
primaryPerson.primaryEmailAddress = { email: '[email protected]' }; | ||
|
||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['Email']); | ||
}); | ||
|
||
it('should be None when opting out of emails', () => { | ||
primaryPerson.primaryEmailAddress = { email: '[email protected]' }; | ||
primaryPerson.optoutEnewsletter = true; | ||
|
||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['None']); | ||
}); | ||
|
||
it('should be Both', () => { | ||
primaryAddress.street = '100 Test St'; | ||
primaryPerson.primaryEmailAddress = { email: '[email protected]' }; | ||
|
||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['Both']); | ||
}); | ||
|
||
it('should be Physical when opting out of emails', () => { | ||
primaryAddress.street = '100 Test St'; | ||
primaryPerson.primaryEmailAddress = { email: '[email protected]' }; | ||
primaryPerson.optoutEnewsletter = true; | ||
|
||
const { getByRole } = render( | ||
<TestComponent | ||
primaryPerson={primaryPerson} | ||
primaryAddress={primaryAddress} | ||
/>, | ||
); | ||
|
||
expect(getByRole('combobox')).toHaveDisplayValue(['Physical']); | ||
}); | ||
}); | ||
}); |
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
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 |
---|---|---|
|
@@ -37,4 +37,5 @@ fragment ContactPrimaryPerson on Person { | |
primaryEmailAddress { | ||
} | ||
optoutEnewsletter | ||
} |