1
0
mirror of https://git.pleroma.social/sjw/pleroma-fe.git synced 2024-12-23 17:25:39 +01:00

EmojiInput tests should be checking the input value on the last input event, not the first

This commit is contained in:
xenofem 2020-02-16 16:35:04 -05:00
parent 59dd7f1320
commit c1e38a4423

View File

@ -36,7 +36,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: initialString.length }) wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false }) wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
expect(wrapper.emitted().input[0][0]).to.eql('Testing (test) ') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Testing (test) ')
}) })
it('inserts string at the end with trailing space (source has a trailing space)', () => { it('inserts string at the end with trailing space (source has a trailing space)', () => {
@ -46,7 +47,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: initialString.length }) wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false }) wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
expect(wrapper.emitted().input[0][0]).to.eql('Testing (test) ') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Testing (test) ')
}) })
it('inserts string at the begginning without leading space', () => { it('inserts string at the begginning without leading space', () => {
@ -56,7 +58,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: 0 }) wrapper.setData({ caret: 0 })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false }) wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
expect(wrapper.emitted().input[0][0]).to.eql('(test) Testing') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('(test) Testing')
}) })
it('inserts string between words without creating extra spaces', () => { it('inserts string between words without creating extra spaces', () => {
@ -66,7 +69,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: 6 }) wrapper.setData({ caret: 6 })
wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false }) wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false })
expect(wrapper.emitted().input[0][0]).to.eql('Spurdo :ebin: Sparde') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Spurdo :ebin: Sparde')
}) })
it('inserts string between words without creating extra spaces (other caret)', () => { it('inserts string between words without creating extra spaces (other caret)', () => {
@ -76,7 +80,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: 7 }) wrapper.setData({ caret: 7 })
wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false }) wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false })
expect(wrapper.emitted().input[0][0]).to.eql('Spurdo :ebin: Sparde') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Spurdo :ebin: Sparde')
}) })
it('inserts string without any padding if padEmoji setting is set to false', () => { it('inserts string without any padding if padEmoji setting is set to false', () => {
@ -86,7 +91,8 @@ describe('EmojiInput', () => {
input.setValue(initialString) input.setValue(initialString)
wrapper.setData({ caret: initialString.length, keepOpen: false }) wrapper.setData({ caret: initialString.length, keepOpen: false })
wrapper.vm.insert({ insertion: ':spam:' }) wrapper.vm.insert({ insertion: ':spam:' })
expect(wrapper.emitted().input[0][0]).to.eql('Eat some spam!:spam:') const inputEvents = wrapper.emitted().input
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Eat some spam!:spam:')
}) })
it('correctly sets caret after insertion at beginning', (done) => { it('correctly sets caret after insertion at beginning', (done) => {