Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

1.1 KB
Raw Blame
import { mount } from '@vue/test-utils';
import InboxSelector from '../InboxSelector.vue';
import Button from 'dashboard/components-next/button/Button.vue';
import { INBOX_TYPES } from 'dashboard/helper/inbox';

const targetInbox = {
  name: 'Support',
  email: '[email protected]',
  channelType: INBOX_TYPES.EMAIL,
};

const mountSelector = (props = {}) =>
  mount(InboxSelector, {
    props: { targetInbox, showInboxesDropdown: false, ...props },
  });

describe('InboxSelector', () => {
  it('shows the selected inbox with a remove button by default', async () => {
    const wrapper = mountSelector();

    expect(wrapper.text()).toContain('Support ([email protected])');
    await wrapper.findComponent(Button).trigger('click');
    expect(wrapper.emitted('updateInbox')).toEqual([[null]]);
  });

  it('hides the remove button when the inbox is not removable', () => {
    const wrapper = mountSelector({ removable: false });

    expect(wrapper.text()).toContain('Support ([email protected])');
    expect(wrapper.findComponent(Button).exists()).toBe(false);
  });
});