-
Notifications
You must be signed in to change notification settings - Fork 7
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 #1669 from guardian/db/ui-indication-for-no-recipe
UI indication for no recipe
- Loading branch information
Showing
11 changed files
with
855 additions
and
282 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
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
123 changes: 123 additions & 0 deletions
123
fronts-client/src/components/card/__tests__/ChefCard.spec.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,123 @@ | ||
import React from 'react'; | ||
import { render, cleanup } from 'react-testing-library'; | ||
import configureStore from 'util/configureStore'; | ||
import { Provider } from 'react-redux'; | ||
import { theme } from '../../../constants/theme'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import 'jest-styled-components'; | ||
import { ChefCard } from '../chef/ChefCard'; | ||
|
||
const chefFixture = { | ||
backgroundHex: '#20809E', | ||
id: 'profile/yotamottolenghi', | ||
image: | ||
'https://media.guim.co.uk/266825657a291ab9c1c0b798a0391f827b6c53ec/93_150_907_907/500.jpg', | ||
bio: 'Inspiration and global flavours for special occasions', | ||
foregroundHex: '#F9F9F5', | ||
webTitle: 'Yotam Ottolenghi', | ||
}; | ||
|
||
describe('ChefCard', () => { | ||
afterEach(cleanup); | ||
|
||
it('should render a chef', async () => { | ||
const store = configureStore({ | ||
feed: {}, | ||
cards: { | ||
'test-chef-card': { | ||
id: 'test-chef-id', | ||
uuid: 'test-chef-card', | ||
meta: { | ||
chefTheme: { | ||
id: 'test-chef-theme-id', | ||
palette: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
chefs: { | ||
data: { | ||
'test-chef-id': chefFixture, | ||
}, | ||
}, | ||
}); | ||
|
||
const component = render( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<ChefCard | ||
onDelete={jest.fn()} | ||
onAddToClipboard={jest.fn()} | ||
id="test-chef-card" | ||
frontId="test-chef-id" | ||
/> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
|
||
const headline = await component.findAllByTestId('headline'); | ||
expect(headline).toHaveLength(1); | ||
expect(headline[0].textContent).toContain('Yotam Ottolenghi'); | ||
|
||
const metacontainer = await component.findAllByTestId('meta-container'); | ||
expect(metacontainer).toHaveLength(1); | ||
expect(metacontainer[0]).toHaveStyleRule( | ||
'background-color', | ||
theme.colors.white | ||
); | ||
|
||
expect(await component.findAllByText('Chef', {})).toHaveLength(1); | ||
expect(component.queryByTestId('chef-not-found-icon')).toBeNull(); | ||
}); | ||
|
||
it('should render a warning state if the chef is not defined', async () => { | ||
const store = configureStore({ | ||
feed: {}, | ||
cards: { | ||
'test-chef-card': { | ||
id: 'test-chef-id', | ||
uuid: 'test-chef-card', | ||
meta: { | ||
chefTheme: { | ||
id: 'test-chef-theme-id', | ||
palette: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
chefs: { | ||
data: {}, | ||
}, | ||
}); | ||
|
||
const component = render( | ||
<Provider store={store}> | ||
<ThemeProvider theme={theme}> | ||
<ChefCard | ||
onDelete={jest.fn()} | ||
onAddToClipboard={jest.fn()} | ||
id="test-chef-card" | ||
frontId="test-chef-id" | ||
/> | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
|
||
const headline = await component.findAllByTestId('headline'); | ||
expect(headline).toHaveLength(1); | ||
expect(headline[0].textContent).toEqual( | ||
'This chef might not load in the app, please select an alternative.' | ||
); | ||
|
||
const metacontainer = await component.findAllByTestId('meta-container'); | ||
expect(metacontainer).toHaveLength(1); | ||
expect(metacontainer[0]).toHaveStyleRule( | ||
'background-color', | ||
theme.colors.greyMediumLight | ||
); | ||
expect(component.queryByText('Chef')).toBeNull(); | ||
expect(await component.findAllByTestId('chef-not-found-icon')).toHaveLength( | ||
1 | ||
); | ||
}); | ||
}); |
Oops, something went wrong.