Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Apr 12, 2021
1 parent c424f33 commit 8b7b064
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/unit/specs/components/ImageDetails/image-info.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ describe('Image Info', () => {
const wrapper = render(ImageInfo, options)

expect(wrapper.html()).toContain(`${props.imageWidth}`)
expect(wrapper.html()).toContain(`${props.imageHeight} pixels`)
expect(wrapper.html()).toContain(`${props.imageHeight}`)
})
})
4 changes: 3 additions & 1 deletion test/unit/specs/components/filter-display.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ describe('FilterDisplay', () => {
it('should render filter by caption label', () => {
options.mocks.$store.state.isFilterApplied = true
const wrapper = render(FilterDisplay, options)
expect(wrapper.find('.caption').element.textContent).toBe('Filter By')
expect(wrapper.find('.caption').element.textContent).toBe(
'filters.filter-by'
)
})
})
17 changes: 6 additions & 11 deletions test/unit/specs/components/search-grid-cell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,17 @@ describe('SearchGridCell', () => {
)
})

it('links to the details page', () => {
const routerMock = {
push: jest.fn(),
params: {
location: window.scrollY,
},
}
it('links to the details page', async () => {
const localeRouteMock = jest.fn()
const wrapper = render(SearchGridCell, {
propsData: props,
mocks: { $router: routerMock },
mocks: { localeRoute: localeRouteMock },
})
const link = wrapper.find('.search-grid_image-ctr')
link.trigger('click')
expect(routerMock.push).toHaveBeenCalledWith({
await link.trigger('click')
expect(localeRouteMock).toHaveBeenCalledWith({
name: 'photo-detail-page',
params: { id: 0, location: routerMock.params.location },
params: { id: 0, location: 0 },
})
})
})
4 changes: 3 additions & 1 deletion test/unit/test-utils/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const render = (Component, options = { localVue, i18n }) => {
const store = new Vuex.Store(sampleStore)
options.store = store
}

if (!options.i18n) {
options.i18n = i18n
}
return shallowMount(Component, options)
}

Expand Down

0 comments on commit 8b7b064

Please sign in to comment.