I'm working on writing a unit test case for integrating lotame analytics. Can anyone offer some assistance on how to write a test case for this integration? I've been stuck on this for quite some time now and keep receiving
TypeError: Cannot read property 'cmd' of undefined
.
app.ts
declare global {
interface Window {
lotame_123: {
cmd: any;
collect: any;
};
}
}
export const collectLotameData = (title: string, name: string) => {
window.lotame_123.cmd.push(function () {
window.lotame_123.collect({
behaviors: {
act: [`tracking : ${title} : ${name}`]
}
});
});
};
app.spec.ts
describe('collectLotameData', () => {
beforeEach(() => {
window.lotame_123 = {
cmd: 'sdas',
collect: 'any'
};
});
});