Chatwoot/app/javascript/shared/mixins/specs/campaignMixin.spec.js

38 lines
1 KiB
JavaScript
Raw Normal View History

2021-07-15 08:01:43 +00:00
import { shallowMount } from '@vue/test-utils';
import campaignMixin from '../campaignMixin';
describe('campaignMixin', () => {
beforeEach(() => {
global.window = Object.create(window);
});
2021-07-15 08:01:43 +00:00
it('returns the correct campaign type', () => {
const url = 'http://localhost:3000/app/accounts/1/campaigns/one_off';
Object.defineProperty(window, 'location', {
value: {
href: url,
},
});
window.location.href = url;
2021-07-15 08:01:43 +00:00
const Component = {
render() {},
mixins: [campaignMixin],
2021-07-15 08:01:43 +00:00
};
const wrapper = shallowMount(Component);
expect(wrapper.vm.campaignType).toBe('one_off');
});
it('isOnOffType returns true if campaign type is one_off', () => {
const url = 'http://localhost:3000/app/accounts/1/campaigns/one_off';
Object.defineProperty(window, 'location', {
value: {
href: url,
2021-07-15 08:01:43 +00:00
},
});
2021-07-15 08:01:43 +00:00
const Component = {
render() {},
mixins: [campaignMixin],
2021-07-15 08:01:43 +00:00
};
const wrapper = shallowMount(Component);
expect(wrapper.vm.isOnOffType).toBe(true);
});
});