mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { useCampaign } from '../useCampaign';
|
|
import { useRoute } from 'vue-router';
|
|
import { CAMPAIGN_TYPES } from '../../constants/campaign';
|
|
|
|
// Mock the useRoute composable
|
|
vi.mock('vue-router', () => ({
|
|
useRoute: vi.fn(),
|
|
}));
|
|
|
|
describe('useCampaign', () => {
|
|
it('returns the correct campaign type for ongoing campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'ongoing_campaigns' });
|
|
const { campaignType } = useCampaign();
|
|
expect(campaignType.value).toBe(CAMPAIGN_TYPES.ONGOING);
|
|
});
|
|
|
|
it('returns the correct campaign type for one-off campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'one_off' });
|
|
const { campaignType } = useCampaign();
|
|
expect(campaignType.value).toBe(CAMPAIGN_TYPES.ONE_OFF);
|
|
});
|
|
|
|
it('isOngoingType returns true for ongoing campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'ongoing_campaigns' });
|
|
const { isOngoingType } = useCampaign();
|
|
expect(isOngoingType.value).toBe(true);
|
|
});
|
|
|
|
it('isOngoingType returns false for one-off campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'one_off' });
|
|
const { isOngoingType } = useCampaign();
|
|
expect(isOngoingType.value).toBe(false);
|
|
});
|
|
|
|
it('isOneOffType returns true for one-off campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'one_off' });
|
|
const { isOneOffType } = useCampaign();
|
|
expect(isOneOffType.value).toBe(true);
|
|
});
|
|
|
|
it('isOneOffType returns false for ongoing campaigns', () => {
|
|
useRoute.mockReturnValue({ name: 'ongoing_campaigns' });
|
|
const { isOneOffType } = useCampaign();
|
|
expect(isOneOffType.value).toBe(false);
|
|
});
|
|
});
|