'use strict';

const test = require('tape');
const expect = require('chai').expect;
const tracker = require('../lib/index');

test('Test tracker method', (assert) => {
	expect(tracker).to.be.a('function');
	expect(tracker.intercom).to.be.a('function');
	expect(tracker.ga).to.be.a('function');
	assert.end();
});

test('Test trackers', (assert) => {
	const intercomTracker = tracker.intercom({
		appId: 'd3bvrtmw'
	});

	const gaTracker = tracker.ga({ /* ga data */});
	const eventTracker = tracker(intercomTracker, gaTracker);

	console.log('\n\n\ngaTracker', gaTracker);
	console.log('\n\n\nintercomTracker', intercomTracker);
	console.log('\n\n\neventTracker', eventTracker);

	intercomTracker.update({
		name: 'John Doe',
		email: 'john@doe.com'
	});

	gaTracker.createEvent('eventError');

	eventTracker.createEvent('store_purchase', {
		action: 'click',
		value: 10,
		label: 'Product Name',
		url: 'http://www.url.com'
	});

	expect(gaTracker).to.have.property('createEvent');
	expect(intercomTracker).to.have.all.keys('createEvent', 'update');
	expect(eventTracker).to.have.property('createEvent');
	assert.end();
});

@@ -117,16 +117,212 @@
 index');
+%0Aconst intercom = require('../trackers/intercom');%0Aconst ga = require('../trackers/ga');%0A%0Aconst intercomServer = require('../trackers/server/intercom');%0Aconst config = require('./helpers/config');
 %0A%0Atest('
@@ -403,24 +403,16 @@
 %09expect(
-tracker.
 intercom
@@ -442,26 +442,63 @@
 %09expect(
-tracker.ga
+ga).to.be.a('function');%0A%09expect(intercomServer
 ).to.be.
@@ -593,24 +593,16 @@
 acker = 
-tracker.
 intercom
@@ -617,18 +617,20 @@
 Id: 
-'d3bvrtmw'
+config.appId
 %0A%09%7D)
@@ -643,47 +643,124 @@
 nst 
-gaTracker = tracker.ga(%7B /* ga data */%7D
+intercomTrackerServer = intercomServer(%7B%0A%09%09appId: config.appId,%0A%09%09apiKey: config.apiKey%0A%09%7D);%0A%0A%09const gaTracker = ga(
 );%0A%09
@@ -910,32 +910,93 @@
 tercomTracker);%0A
+%09console.log('%5Cn%5Cn%5CnintercomServer', intercomTrackerServer);%0A
 %09console.log('%5Cn
@@ -1282,16 +1282,162 @@
 '%0A%09%7D);%0A%0A
+%09intercomTrackerServer.createEvent('testEvent', %7B%0A%09%09action: 'someAction',%0A%09%09value: 10,%0A%09%09label: 'Product Name',%0A%09%09url: 'http://www.url.com'%0A%09%7D);%0A%0A
 %09expect(

Improve tests