import test from 'ava' import mixgather from '../index' import { updateDebug, mergeDeep } from '../index' const TEST_LABEL = 'test' const USER_ID = 'sune' // @TODO: Add UTs for gathers test.beforeEach((t) => { updateDebug(false) mixgather.init({ debug: false, google: { id: TEST_LABEL }, mixpanel: { token: TEST_LABEL } }) }) test('index - Check Options', (t) => { t.is(mixgather.options.debug, false) t.is(mixgather.options.google.id, TEST_LABEL) t.is(mixgather.options.mixpanel.token, TEST_LABEL) t.is(mixgather.options.appName, undefined) }) test('index - Set User', (t) => { mixgather.setUser({ id: USER_ID }) t.pass() }) test('index - Track', (t) => { const pageMeta = mixgather.page('/test', 'Test') const eventMeta = mixgather.event('testAction') t.is(eventMeta.page, pageMeta.title) const anotherPage = mixgather.page('/another') const anotherEvent = mixgather.event('anotherAction', { a: 1 }) t.is(anotherPage.title, '') t.is(anotherEvent.a, 1) }) test('utils - mergeDeep()', (t) => { const a = { a: 1, c: { a: 1 } } const b = { b: 1, c: { b: 1 } } const c = mergeDeep(a, b) t.deepEqual(c, { a: 1, b: 1, c: { b: 1, a: 1 } }) })