Created
June 6, 2024 00:11
-
-
Save faddah/b24128fc8855ee2bf2b880eb30e27e71 to your computer and use it in GitHub Desktop.
Faddah's code for HousingInfo.test.jsx ± error result
This file contains hidden or 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
it('clears all input fields when you click the clear button', async () => { | |
const user = userEvent.setup(); | |
const mockClear = vi.fn(); | |
const address = { | |
lastPermanentStreet: '20th ave', | |
lastPermanentCity: 'Portland', | |
lastPermanentState: 'Oregon', | |
lastPermanentZIP: '97205', | |
monthsHomeless: '1 Month', | |
timesHomeless: 'One Time', | |
timeToHousingLoss: '7-13 Days' | |
}; | |
useCivicProfile.mockReturnValue({ | |
add: mockClear, | |
isSuccess: true, | |
storedDataset: {}, | |
refetch: vi.fn() | |
}); | |
useNotification.mockReturnValue({ addNotification: vi.fn() }); | |
const { getByRole } = render(<HousingInfo />); | |
const cityField = getByRole('textbox', { name: 'City:' }); | |
const streetField = getByRole('textbox', { name: 'Street:' }); | |
const stateField = getByRole('textbox', { name: 'State:' }); | |
const zipField = getByRole('textbox', { name: 'ZIP Code:' }); | |
const monthsHomelessField = getByRole('combobox', { name: 'Months Houseless Past 3 Years:' }); | |
const timesHomelessField = getByRole('combobox', { | |
name: 'Number of Times Houseless Past 3 Years:' | |
}); | |
const timeToHousingLossField = getByRole('combobox', { name: 'Time Until Loss of Housing:' }); | |
const clearButton = getByRole('button', { name: 'Clear button' }); | |
await user.type(streetField, address.lastPermanentStreet); | |
await user.type(cityField, address.lastPermanentCity); | |
await user.type(stateField, address.lastPermanentState); | |
await user.type(zipField, address.lastPermanentZIP); | |
await user.click(monthsHomelessField); | |
await user.click(screen.getByRole('option', { name: address.monthsHomeless })); | |
await user.click(timesHomelessField); | |
await user.click(screen.getByRole('option', { name: address.timesHomeless })); | |
await user.click(timeToHousingLossField); | |
await user.click(screen.getByRole('option', { name: address.timeToHousingLoss })); | |
await user.click(clearButton); | |
expect(streetField.value).toBe(''); | |
expect(cityField.value).toBe(''); | |
expect(stateField.value).toBe(''); | |
expect(zipField.value).toBe(''); | |
expect(monthsHomelessField.value).toBe(99); | |
expect(timesHomelessField.value).toBe(99); | |
expect(timeToHousingLossField.value).toBe(99); | |
expect(await screen.findByText(/Data not collected/i)).toBeInTheDocument(); | |
expect(await screen.findByText(/Data not collected/i)).toBeInTheDocument(); | |
expect(await screen.findByText(/Data not collected/i)).toBeInTheDocument(); | |
}); |
This file contains hidden or 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
❯ test/components/CivicProfileForms/HousingInfo.test.jsx (4) 2030ms | |
❯ Housing info form (4) 2029ms | |
✓ renders | |
✓ submits an address update when you click the submit button 724ms | |
✓ does not submit when storedDataset is null 577ms | |
× clears all input fields when you click the clear button 600ms | |
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ | |
FAIL test/components/CivicProfileForms/HousingInfo.test.jsx > Housing info form > clears all input fields when you click the clear button | |
AssertionError: expected undefined to be 99 // Object.is equality | |
- Expected: | |
99 | |
+ Received: | |
undefined | |
❯ test/components/CivicProfileForms/HousingInfo.test.jsx:169:39 | |
167| expect(stateField.value).toBe(''); | |
168| expect(zipField.value).toBe(''); | |
169| expect(monthsHomelessField.value).toBe(99); | |
| ^ | |
170| expect(timesHomelessField.value).toBe(99); | |
171| expect(timeToHousingLossField.value).toBe(99); | |
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ | |
Test Files 1 failed (1) | |
Tests 1 failed | 3 passed (4) | |
Start at 00:06:24 | |
Duration 2.53s | |
FAIL Tests failed. Watching for file changes... | |
press h to show help, press q to quit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment