@aller/blink
Version:
A library for tracking user behaviour.
40 lines (35 loc) • 932 B
text/typescript
import createBlink from '../main';
import { VERSION } from '../config/config';
import jest from 'jest-mock';
describe('Box intregration test', () => {
it('should send a single box event', () => {
const mockSend = jest.fn();
const blink = createBlink({
send: mockSend,
sendDirect: mockSend,
});
// First send of a pageInit event, to set the general state
blink.pageInit({
url: 'http://some.site',
pageView: 'the-pageview-id',
referrer: 'www.sol.no',
site: 'www.dagbladet.no',
});
blink.boxScreenEnter({
id: 'cool-box-id',
});
expect(mockSend.mock.calls[0][0]).toEqual([
{
type: 'box',
pageView: 'the-pageview-id',
site: 'www.dagbladet.no',
referrer: 'www.sol.no',
version: VERSION,
id: 'cool-box-id',
boxId: 'cool-box-id',
height: 0,
width: 0,
},
]);
});
});