mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
chore: Execute campaigns based on matching URL (#2254)
This commit is contained in:
59
app/javascript/widget/helpers/specs/campaignHelper.spec.js
Normal file
59
app/javascript/widget/helpers/specs/campaignHelper.spec.js
Normal file
@@ -0,0 +1,59 @@
|
||||
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', () => {
|
||||
expect(formatCampaigns({ campagins: campaigns })).toStrictEqual([
|
||||
{
|
||||
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({
|
||||
campagins: [
|
||||
{
|
||||
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',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user