diff options
| author | Henry Jameson <me@hjkos.com> | 2019-09-25 20:54:07 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2019-09-25 20:54:07 +0300 |
| commit | 836cb817d18f5e3ee6dab446633b8e05733c2a3a (patch) | |
| tree | beb8a09c2033d5c3da6dcf49a1fe259e1986c4d0 /test/unit/specs/components | |
| parent | a3305799c7ee9292550346006cf0389bed963e2c (diff) | |
fix tests
Diffstat (limited to 'test/unit/specs/components')
| -rw-r--r-- | test/unit/specs/components/emoji_input.spec.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/test/unit/specs/components/emoji_input.spec.js b/test/unit/specs/components/emoji_input.spec.js index 13a59961..368d623d 100644 --- a/test/unit/specs/components/emoji_input.spec.js +++ b/test/unit/specs/components/emoji_input.spec.js @@ -1,7 +1,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils' import EmojiInput from 'src/components/emoji_input/emoji_input.vue' -const generateInput = (value) => { +const generateInput = (value, padEmoji = true) => { const localVue = createLocalVue() localVue.directive('click-outside', () => {}) const wrapper = shallowMount(EmojiInput, { @@ -10,6 +10,15 @@ const generateInput = (value) => { enableEmojiPicker: true, value }, + mocks: { + $store: { + state: { + config: { + padEmoji + } + } + } + }, slots: { default: '<input />' }, @@ -70,13 +79,13 @@ describe('EmojiInput', () => { expect(wrapper.emitted().input[0][0]).to.eql('Spurdo :ebin: Sparde') }) - it('inserts string without any padding in spam mode', () => { + it('inserts string without any padding if padEmoji setting is set to false', () => { const initialString = 'Eat some spam!' - const [wrapper] = generateInput(initialString) + const [wrapper] = generateInput(initialString, false) const input = wrapper.find('input') input.setValue(initialString) - wrapper.setData({ caret: initialString.length }) - wrapper.vm.insert({ insertion: ':spam:', keepOpen: true }) + wrapper.setData({ caret: initialString.length, keepOpen: false }) + wrapper.vm.insert({ insertion: ':spam:' }) expect(wrapper.emitted().input[0][0]).to.eql('Eat some spam!:spam:') }) @@ -106,13 +115,13 @@ describe('EmojiInput', () => { }) }) - it('correctly sets caret after insertion in spam mode', (done) => { + it('correctly sets caret after insertion if padEmoji setting is set to false', (done) => { const initialString = '1234' - const [wrapper, vue] = generateInput(initialString) + const [wrapper, vue] = generateInput(initialString, false) const input = wrapper.find('input') input.setValue(initialString) wrapper.setData({ caret: initialString.length }) - wrapper.vm.insert({ insertion: '1234', keepOpen: true }) + wrapper.vm.insert({ insertion: '1234', keepOpen: false }) vue.nextTick(() => { expect(wrapper.vm.caret).to.eql(8) done() |
