2021-07-15 08:01:43 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import campaignMixin from '../campaignMixin';
|
|
|
|
|
|
|
|
describe('campaignMixin', () => {
|
2021-08-11 14:59:33 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
global.window = Object.create(window);
|
|
|
|
});
|
2021-07-15 08:01:43 +00:00
|
|
|
it('returns the correct campaign type', () => {
|
2021-08-11 14:59:33 +00:00
|
|
|
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() {},
|
2021-08-11 14:59:33 +00:00
|
|
|
mixins: [campaignMixin],
|
2021-07-15 08:01:43 +00:00
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.campaignType).toBe('one_off');
|
|
|
|
});
|
2021-08-11 14:59:33 +00:00
|
|
|
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-08-11 14:59:33 +00:00
|
|
|
});
|
2021-07-15 08:01:43 +00:00
|
|
|
const Component = {
|
|
|
|
render() {},
|
2021-08-11 14:59:33 +00:00
|
|
|
mixins: [campaignMixin],
|
2021-07-15 08:01:43 +00:00
|
|
|
};
|
|
|
|
const wrapper = shallowMount(Component);
|
|
|
|
expect(wrapper.vm.isOnOffType).toBe(true);
|
|
|
|
});
|
2021-08-11 14:59:33 +00:00
|
|
|
|
2021-07-15 08:01:43 +00:00
|
|
|
});
|