2020-05-09 16:32:43 +00:00
|
|
|
import { createWrapper } from '@vue/test-utils';
|
|
|
|
import configMixin from '../configMixin';
|
|
|
|
import Vue from 'vue';
|
2022-04-19 07:17:29 +00:00
|
|
|
const preChatFields = [
|
|
|
|
{
|
|
|
|
label: 'Email Id',
|
|
|
|
name: 'emailAddress',
|
|
|
|
type: 'email',
|
|
|
|
field_type: 'standard',
|
|
|
|
required: false,
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Full name',
|
|
|
|
name: 'fullName',
|
|
|
|
type: 'text',
|
|
|
|
field_type: 'standard',
|
|
|
|
required: true,
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
];
|
2020-05-09 16:32:43 +00:00
|
|
|
global.chatwootWebChannel = {
|
|
|
|
avatarUrl: 'https://test.url',
|
|
|
|
hasAConnectedAgentBot: 'AgentBot',
|
2022-04-06 08:24:55 +00:00
|
|
|
enabledFeatures: ['emoji_picker', 'attachments', 'end_conversation'],
|
2022-04-19 07:17:29 +00:00
|
|
|
preChatFormOptions: { pre_chat_fields: preChatFields, pre_chat_message: '' },
|
|
|
|
preChatFormEnabled: true,
|
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);
|
2022-04-06 08:24:55 +00:00
|
|
|
expect(wrapper.vm.hasEndConversationEnabled).toBe(true);
|
2020-08-05 12:16:17 +00:00
|
|
|
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');
|
2022-04-19 07:17:29 +00:00
|
|
|
|
2020-05-09 16:32:43 +00:00
|
|
|
expect(wrapper.vm.channelConfig).toEqual({
|
|
|
|
avatarUrl: 'https://test.url',
|
|
|
|
hasAConnectedAgentBot: 'AgentBot',
|
2022-04-06 08:24:55 +00:00
|
|
|
enabledFeatures: ['emoji_picker', 'attachments', 'end_conversation'],
|
2021-06-30 15:39:44 +00:00
|
|
|
preChatFormOptions: {
|
|
|
|
pre_chat_message: '',
|
2022-04-19 07:17:29 +00:00
|
|
|
pre_chat_fields: preChatFields,
|
2021-06-30 15:39:44 +00:00
|
|
|
},
|
2022-04-19 07:17:29 +00:00
|
|
|
preChatFormEnabled: true,
|
2021-06-30 15:39:44 +00:00
|
|
|
});
|
|
|
|
expect(wrapper.vm.preChatFormOptions).toEqual({
|
|
|
|
preChatMessage: '',
|
2022-04-19 07:17:29 +00:00
|
|
|
preChatFields: preChatFields,
|
2020-05-09 16:32:43 +00:00
|
|
|
});
|
2022-04-19 07:17:29 +00:00
|
|
|
expect(wrapper.vm.preChatFormEnabled).toEqual(true);
|
|
|
|
expect(wrapper.vm.shouldShowPreChatForm).toEqual(true);
|
2020-05-09 16:32:43 +00:00
|
|
|
});
|
|
|
|
});
|