diff options
author | marco <marcoambrosini@pm.me> | 2022-03-24 15:23:29 +0300 |
---|---|---|
committer | marco <marcoambrosini@pm.me> | 2022-03-24 16:01:45 +0300 |
commit | d1b8e3ea3c3b545c1facdf386cca2720efa354ef (patch) | |
tree | f0836da60f91416c6e11c3fe203e647c9db263c8 /src/components/MessagesList/MessagesGroup/Message/Message.spec.js | |
parent | cdfe363f2e2e4248dc6e05217c85a7e71d5921bf (diff) |
Use conditional rendering only to show and hide the MessageButtonsBar component
Signed-off-by: marco <marcoambrosini@pm.me>
Diffstat (limited to 'src/components/MessagesList/MessagesGroup/Message/Message.spec.js')
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/Message.spec.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.spec.js b/src/components/MessagesList/MessagesGroup/Message/Message.spec.js index 519eec383..b08ff8f71 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/Message.spec.js @@ -563,7 +563,7 @@ describe('Message.vue', () => { expect(messageButtonsBar.exists()).toBe(false) }) - test('Buttons bar becomes visible on mouse over', async () => { + test('Buttons bar is rendered on mouse over', async () => { messageProps.sendingFailure = 'timeout' const wrapper = mount(Message, { localVue, @@ -571,26 +571,23 @@ describe('Message.vue', () => { propsData: messageProps, }) - await wrapper.vm.$nextTick() - - const messageButtonsBar = wrapper.findComponent(MessageButtonsBar) - + // Initial state expect(wrapper.vm.showMessageButtonsBar).toBe(false) - expect(messageButtonsBar.isVisible()).toBe(false) + expect(wrapper.findComponent(MessageButtonsBar).exists()).toBe(false) + // Mouseover await wrapper.find('.message').trigger('mouseover') - expect(wrapper.vm.showMessageButtonsBar).toBe(true) - expect(messageButtonsBar.isVisible()).toBe(true) - - await wrapper.find('.message').trigger('mouseleave') + expect(wrapper.findComponent(MessageButtonsBar).exists()).toBe(true) - expect(wrapper.vm.showMessageButtonsBar).toBe(false) - expect(messageButtonsBar.isVisible()).toBe(false) - - // actions are always present and rendered + // actions are present and rendered when the buttonsBar is renderend const actions = wrapper.findAllComponents({ name: 'Actions' }) expect(actions.length).toBe(2) + + // Mouseleave + await wrapper.find('.message').trigger('mouseleave') + expect(wrapper.vm.showMessageButtonsBar).toBe(false) + expect(wrapper.findComponent(MessageButtonsBar).exists()).toBe(false) }) }) @@ -616,6 +613,9 @@ describe('Message.vue', () => { propsData: messageProps, }) + // Hover the messages in order to render the MessageButtonsBar + // component + await wrapper.find('.message').trigger('mouseover') wrapper.find(MessageButtonsBar).vm.$emit('delete') expect(deleteMessage).toHaveBeenCalledWith(expect.anything(), { |