-
Notifications
You must be signed in to change notification settings - Fork 0
/
Restaurant.test.js
56 lines (43 loc) · 1.59 KB
/
Restaurant.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react'
import '@testing-library/jest-dom'
import { render } from '@testing-library/react'
import { Provider } from 'react-redux'
import configureStore from 'redux-mock-store'
import Restaurant from './Restaurant'
import { initialStateTestData } from '../../test-data'
describe('Restaurant', () => {
let RestaurantComponent, store, mockStore, initialState, restaurant
beforeEach(() => {
initialState = initialStateTestData
restaurant = initialStateTestData.restaurants[0]
mockStore = configureStore()
store = mockStore(initialState)
RestaurantComponent = render(
<Provider store={store}>
<Restaurant restaurant={restaurant} />
</Provider>,
)
})
it('Restaurant Component should successfully render', () => {
const { getByText } = RestaurantComponent
expect(getByText(restaurant.name)).toBeInTheDocument()
expect(
getByText(`${restaurant.city} , ${restaurant.state}`),
).toBeInTheDocument()
expect(getByText(`+1 ${restaurant.telephone}`)).toBeInTheDocument()
for (const genre of restaurant.genreArray) {
expect(getByText(genre)).toBeInTheDocument()
}
expect(
getByText(
`${restaurant.address1} ${restaurant.city} ${restaurant.state} ${restaurant.zip}`,
),
).toBeInTheDocument()
expect(getByText(restaurant.hours)).toBeInTheDocument()
expect(getByText(restaurant.website)).toBeInTheDocument()
for (const tag of restaurant.tagsArray) {
expect(getByText(`# ${tag}`)).toBeInTheDocument()
}
expect(getByText(restaurant.attire)).toBeInTheDocument()
})
})