Sha256: a98ef32d51e403a63869c1af3c81ddeeb30bfcfeeaae31ac765026a3546f7f2a
Contents?: true
Size: 1.3 KB
Versions: 33
Compression:
Stored size: 1.3 KB
Contents
/* global describe it expect beforeEach afterEach spyOn */ var $ = window.jQuery describe('An auto event tracker', function () { 'use strict' var GOVUK = window.GOVUK var tracker, element beforeEach(function () { GOVUK.analytics = {trackEvent: function () {}} tracker = new GOVUK.Modules.AutoTrackEvent() }) afterEach(function () { delete GOVUK.analytics }) it('tracks non-interactive events on start', function () { spyOn(GOVUK.analytics, 'trackEvent') element = $( '<div ' + 'data-track-category="category"' + 'data-track-action="action">' + 'Some content' + '</div>' ) tracker.start(element) expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith( 'category', 'action', {nonInteraction: 1}) }) it('can track non-interactive events with optional label and value', function () { spyOn(GOVUK.analytics, 'trackEvent') element = $( '<div ' + 'data-track-category="category"' + 'data-track-action="action"' + 'data-track-label="label"' + 'data-track-value="10">' + 'Some content' + '</div>' ) tracker.start(element) expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith( 'category', 'action', {label: 'label', value: 10, nonInteraction: 1}) }) })
Version data entries
33 entries across 33 versions & 2 rubygems