2021-05-17 16:08:35 +00:00
|
|
|
import {
|
|
|
|
stripTrailingSlash,
|
|
|
|
formatCampaigns,
|
|
|
|
filterCampaigns,
|
|
|
|
} from '../campaignHelper';
|
|
|
|
import campaigns from './camapginFixtures';
|
|
|
|
describe('#Campagin Helper', () => {
|
|
|
|
describe('stripTrailingSlash', () => {
|
|
|
|
it('should return striped trailing slash if url with trailing slash is passed', () => {
|
|
|
|
expect(
|
|
|
|
stripTrailingSlash({ URL: 'https://www.chatwoot.com/pricing/' })
|
|
|
|
).toBe('https://www.chatwoot.com/pricing');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('formatCampaigns', () => {
|
|
|
|
it('should return formated campaigns if camapgins are passed', () => {
|
2021-05-18 06:45:23 +00:00
|
|
|
expect(formatCampaigns({ campaigns })).toStrictEqual([
|
2021-05-17 16:08:35 +00:00
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
timeOnPage: 3,
|
|
|
|
url: 'https://www.chatwoot.com/pricing',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
timeOnPage: 6,
|
|
|
|
url: 'https://www.chatwoot.com/about',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('filterCampaigns', () => {
|
|
|
|
it('should return filtered campaigns if formatted camapgins are passed', () => {
|
|
|
|
expect(
|
|
|
|
filterCampaigns({
|
2021-05-18 06:45:23 +00:00
|
|
|
campaigns: [
|
2021-05-17 16:08:35 +00:00
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
timeOnPage: 3,
|
|
|
|
url: 'https://www.chatwoot.com/pricing',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
timeOnPage: 6,
|
|
|
|
url: 'https://www.chatwoot.com/about',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
currentURL: 'https://www.chatwoot.com/about/',
|
|
|
|
})
|
|
|
|
).toStrictEqual([
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
timeOnPage: 6,
|
|
|
|
url: 'https://www.chatwoot.com/about',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|