2020-08-05 12:16:17 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import inboxMixin from '../inboxMixin';
|
|
|
|
|
|
|
|
describe('inboxMixin', () => {
|
|
|
|
it('returns the correct channel type', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::WebWidget' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.channelType).toBe('Channel::WebWidget');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isAPIInbox returns true if channel type is API', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::Api' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isAPIInbox).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isATwitterInbox returns true if channel type is twitter', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::TwitterProfile' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwitterInbox).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isAFacebookInbox returns true if channel type is Facebook', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::FacebookPage' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isAFacebookInbox).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isAWebWidgetInbox returns true if channel type is Facebook', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::WebWidget' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isAWebWidgetInbox).toBe(true);
|
|
|
|
});
|
|
|
|
|
2022-03-02 09:39:56 +00:00
|
|
|
it('isASmsInbox returns true if channel type is sms', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return { inbox: { channel_type: 'Channel::Sms' } };
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isASmsInbox).toBe(true);
|
|
|
|
});
|
|
|
|
|
2020-08-05 12:16:17 +00:00
|
|
|
it('isATwilioChannel returns true if channel type is Twilio', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: {
|
|
|
|
channel_type: 'Channel::TwilioSms',
|
2021-09-29 07:26:45 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwilioChannel).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isATwilioSMSChannel returns true if channel type is Twilio and medium is SMS', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: {
|
|
|
|
channel_type: 'Channel::TwilioSms',
|
|
|
|
medium: 'sms',
|
2020-08-05 12:16:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwilioChannel).toBe(true);
|
|
|
|
expect(wrapper.vm.isATwilioSMSChannel).toBe(true);
|
2022-03-02 09:39:56 +00:00
|
|
|
expect(wrapper.vm.isASmsInbox).toBe(true);
|
2020-08-05 12:16:17 +00:00
|
|
|
});
|
|
|
|
|
2021-09-29 07:26:45 +00:00
|
|
|
it('isATwilioWhatsappChannel returns true if channel type is Twilio and medium is whatsapp', () => {
|
2020-08-05 12:16:17 +00:00
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: {
|
|
|
|
channel_type: 'Channel::TwilioSms',
|
2021-09-29 07:26:45 +00:00
|
|
|
medium: 'whatsapp',
|
2020-08-05 12:16:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwilioChannel).toBe(true);
|
|
|
|
expect(wrapper.vm.isATwilioWhatsappChannel).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('isAnEmailChannel returns true if channel type is email', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: { channel_type: 'Channel::Email' },
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isAnEmailChannel).toBe(true);
|
|
|
|
});
|
2021-09-29 07:26:45 +00:00
|
|
|
|
|
|
|
it('isTwitterInboxTweet returns true if Twitter channel type is tweet', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
chat: {
|
|
|
|
channel_type: 'Channel::TwitterProfile',
|
|
|
|
additional_attributes: {
|
|
|
|
type: 'tweet',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isTwitterInboxTweet).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('twilioBadge returns string sms if channel type is Twilio and medium is sms', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: {
|
|
|
|
channel_type: 'Channel::TwilioSms',
|
|
|
|
medium: 'sms',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwilioSMSChannel).toBe(true);
|
|
|
|
expect(wrapper.vm.twilioBadge).toBe('sms');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('twitterBadge returns string twitter-tweet if Twitter channel type is tweet', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
chat: {
|
|
|
|
id: 1,
|
|
|
|
additional_attributes: {
|
|
|
|
type: 'tweet',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isTwitterInboxTweet).toBe(true);
|
|
|
|
expect(wrapper.vm.twitterBadge).toBe('twitter-tweet');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('inboxBadge returns string Channel::Telegram if isATwilioChannel and isATwitterInbox is false', () => {
|
|
|
|
const Component = {
|
|
|
|
render() {},
|
|
|
|
mixins: [inboxMixin],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inbox: {
|
|
|
|
channel_type: 'Channel::Telegram',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isATwilioChannel).toBe(false);
|
|
|
|
expect(wrapper.vm.isATwitterInbox).toBe(false);
|
|
|
|
expect(wrapper.vm.channelType).toBe('Channel::Telegram');
|
|
|
|
});
|
2020-08-05 12:16:17 +00:00
|
|
|
});
|