import prepareVideoPlayEvent, {
  PrepareVideoPlayEventInput,
} from '../prepare-video-play-event';
import { VERSION } from '../../config/config';
import { BlinkEvent } from '../../types';

describe('prepareVideoPlayEvent', () => {
  it('should format properly based on state', () => {
    const input: PrepareVideoPlayEventInput = {
      page: {
        id: 'default',
        state: {
          general: {
            pageView: 'some-pageview-uuid',
            site: 'www.dagbladet.no',
            referrer: 'www.dinside.no',
          },
        },
      },
      videoId: '123',
      time: new Date(2),
      position: 11.2,
      viewable: true,
      reason: 'interaction',
      muted: true,
      streamingMode: 'live',
      channelId: 'LaksIW2',
    };

    const expected: BlinkEvent = {
      customUserAgent: undefined,
      type: 'videoPlay',
      pageView: 'some-pageview-uuid',
      site: 'www.dagbladet.no',
      referrer: 'www.dinside.no',
      version: VERSION,
      id: '123',
      videoId: '123',
      time: new Date(2),
      videoPlayMuted: true,
      videoPlayPosition: 11.2,
      videoPlayReason: 'interaction',
      videoViewable: true,
      streamingMode: 'live',
      channelId: 'LaksIW2',
    };

    expect(prepareVideoPlayEvent(input)).toEqual(expected);
  });
});
