Robert Schäfer ffe6dc7736 Add MutationObserver to fix tests
Our build server failed because of frontend tests. However, all our
fullstack tests are passing... So maybe an issue in our test setup, not
reproducible in a real browser?

This commit:
ee4f132b0f (diff-0806c5f3fdae5e139222967601c7faca)
adds MutationObserver to their test setup. Adding it to our test suites
that touch the `editor` directly fixes our tests, too!

From what I can tell is that prosemirror is calling
`this.observer.takeRecords()`. Probably `tiptap` updated its
dependencies at some point and that's where `this.observer` was
introduced? Hard to tell. It really looks just like an issue only
present in test environments, so I think it's safe not to investigate
any further.
2019-08-02 14:32:06 +02:00

72 lines
1.5 KiB
JavaScript

import { mount, createLocalVue } from '@vue/test-utils'
import Editor from './Editor'
import Vuex from 'vuex'
import Styleguide from '@human-connection/styleguide'
import MutationObserver from 'mutation-observer'
global.MutationObserver = MutationObserver
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Styleguide)
describe('Editor.vue', () => {
let wrapper
let propsData
let mocks
let getters
beforeEach(() => {
propsData = {}
mocks = {
$t: () => {},
}
getters = {
'editor/placeholder': () => {
return 'some cool placeholder'
},
}
})
describe('mount', () => {
let Wrapper = () => {
const store = new Vuex.Store({
getters,
})
return (wrapper = mount(Editor, {
mocks,
propsData,
localVue,
sync: false,
stubs: {
transition: false,
},
store,
}))
}
it('renders', () => {
expect(Wrapper().is('div')).toBe(true)
})
describe('given a piece of text', () => {
beforeEach(() => {
propsData.value = 'I am a piece of text'
})
it.skip('renders', () => {
wrapper = Wrapper()
expect(wrapper.find('.ProseMirror').text()).toContain('I am a piece of text')
})
})
describe('uses the placeholder', () => {
it('from the store', () => {
expect(wrapper.vm.editor.extensions.options.placeholder.emptyNodeText).toEqual(
'some cool placeholder',
)
})
})
})
})