mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
by setting up localVue with all required plugins (such as styleguide and vuex) in a separate testSetup file we can avoid doing this individually in all component tests the testSetup is executed before each test suite, so each test file gets a fresh instance of localVue
33 lines
972 B
JavaScript
33 lines
972 B
JavaScript
import { config, shallowMount } from '@vue/test-utils'
|
|
|
|
import MasonryGridItem from './MasonryGridItem'
|
|
|
|
const localVue = global.localVue
|
|
|
|
config.stubs['ds-grid-item'] = '<span><slot /></span>'
|
|
|
|
describe('MasonryGridItem', () => {
|
|
let wrapper
|
|
|
|
beforeEach(() => {
|
|
wrapper = shallowMount(MasonryGridItem, { localVue })
|
|
wrapper.vm.$parent.$emit = jest.fn()
|
|
})
|
|
|
|
it('emits "calculating-item-height" when starting calculation', async () => {
|
|
wrapper.vm.calculateItemHeight()
|
|
await wrapper.vm.$nextTick()
|
|
|
|
const firstCallArgument = wrapper.vm.$parent.$emit.mock.calls[0][0]
|
|
expect(firstCallArgument).toBe('calculating-item-height')
|
|
})
|
|
|
|
it('emits "finished-calculating-item-height" after the calculation', async () => {
|
|
wrapper.vm.calculateItemHeight()
|
|
await wrapper.vm.$nextTick()
|
|
|
|
const secondCallArgument = wrapper.vm.$parent.$emit.mock.calls[1][0]
|
|
expect(secondCallArgument).toBe('finished-calculating-item-height')
|
|
})
|
|
})
|