@aller/blink
Version:
A library for tracking user behaviour.
100 lines • 3.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var player_1 = require("../player");
describe('getUniqueVideoIdsForPlayer', function () {
it('should return unique ids from an array of events that includes duplicates', function () {
var events = [
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid1',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid2',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid1',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid3',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
];
var uniqueIds = player_1.getUniqueVideoIdsForPlayer(events, 'player1');
var expected = ['vid1', 'vid2', 'vid3'];
expect(uniqueIds).toEqual(expected);
});
it('should not include ids from events belonging to other playerIds', function () {
var events = [
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid1',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid2',
playerId: 'player2',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid1',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
{
type: 'stop',
reason: 'pause',
time: new Date(),
videoId: 'vid3',
playerId: 'player1',
muted: true,
volume: 50,
position: 10,
},
];
var uniqueIds = player_1.getUniqueVideoIdsForPlayer(events, 'player1');
var expected = ['vid1', 'vid3'];
expect(uniqueIds).toEqual(expected);
});
});
//# sourceMappingURL=player.test.js.map