2020-05-09 16:32:43 +00:00
|
|
|
import { createWrapper } from '@vue/test-utils';
|
|
|
|
import configMixin from '../configMixin';
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
global.chatwootWebChannel = {
|
|
|
|
avatarUrl: 'https://test.url',
|
|
|
|
hasAConnectedAgentBot: 'AgentBot',
|
2020-08-05 12:16:17 +00:00
|
|
|
enabledFeatures: ['emoji_picker', 'attachments'],
|
2021-06-30 15:39:44 +00:00
|
|
|
preChatFormOptions: { require_email: false, pre_chat_message: '' },
|
2020-05-09 16:32:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
global.chatwootWidgetDefaults = {
|
|
|
|
useInboxAvatarForBot: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('configMixin', () => {
|
|
|
|
test('returns config', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
title: 'TestComponent',
|
|
|
|
mixins: [configMixin],
|
|
|
|
};
|
|
|
|
const Constructor = Vue.extend(Component);
|
|
|
|
const vm = new Constructor().$mount();
|
|
|
|
const wrapper = createWrapper(vm);
|
2020-08-05 12:16:17 +00:00
|
|
|
expect(wrapper.vm.hasEmojiPickerEnabled).toBe(true);
|
|
|
|
expect(wrapper.vm.hasAttachmentsEnabled).toBe(true);
|
2020-05-09 16:32:43 +00:00
|
|
|
expect(wrapper.vm.hasAConnectedAgentBot).toBe(true);
|
|
|
|
expect(wrapper.vm.useInboxAvatarForBot).toBe(true);
|
|
|
|
expect(wrapper.vm.inboxAvatarUrl).toBe('https://test.url');
|
|
|
|
expect(wrapper.vm.channelConfig).toEqual({
|
|
|
|
avatarUrl: 'https://test.url',
|
|
|
|
hasAConnectedAgentBot: 'AgentBot',
|
2020-08-05 12:16:17 +00:00
|
|
|
enabledFeatures: ['emoji_picker', 'attachments'],
|
2021-06-30 15:39:44 +00:00
|
|
|
preChatFormOptions: {
|
|
|
|
pre_chat_message: '',
|
|
|
|
require_email: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.vm.preChatFormOptions).toEqual({
|
|
|
|
requireEmail: false,
|
|
|
|
preChatMessage: '',
|
2020-05-09 16:32:43 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|