electron-google-analytics
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "electron-google-analytics", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A library to implement Google Analytics in desktop apps.", | ||
"main": "src/index.js", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel src -d lib", | ||
"test": "mocha --compilers js:babel-register" | ||
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register" | ||
}, | ||
@@ -24,2 +24,3 @@ "keywords": [ | ||
"babel-core": "^6.22.1", | ||
"babel-preset-env": "^1.1.8", | ||
"babel-register": "^6.22.0", | ||
@@ -26,0 +27,0 @@ "chai": "^3.5.0", |
@@ -5,41 +5,57 @@ import chai from 'chai'; | ||
const expect = chai.expect; | ||
const trackingID = process.env.TRACKING_ID; | ||
const trackingID = (process.env.TRACKING_ID) ? process.env.TRACKING_ID : ''; | ||
describe('Analytics', function() { | ||
it('should fail sending a pageview request', function() { | ||
const analytics = new Analytics('', { debug: true }); | ||
return analytics.pageview('http://example.com', 'test', 'test') | ||
.then((response) => { | ||
return expect(response).to.be.empty; | ||
}).catch((err) => { | ||
return expect(err).to.not.be.empty; | ||
if (trackingID) { | ||
it('should send a pageview request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
return analytics.pageview('http://example.com', '/test', 'Test') | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
}); | ||
}); | ||
}); | ||
it('should send a pageview request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
it('should send a event request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
return analytics.pageview('http://example.com', '/test', 'Test') | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
return analytics.event('category', 'view').then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
}); | ||
}); | ||
}); | ||
it('should send a event request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
it('should send a screenview request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
return analytics.event('category', 'view').then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
return analytics.screen('test', '1.0.0', 'com.app.test', 'com.app.installer', 'Test') | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
}); | ||
}); | ||
}); | ||
it('should fail sending a event request', function() { | ||
it('should send a custom request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
return analytics.send('social', { sa: 'social', sn: 'facebook', st: 'home' }) | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
}); | ||
}); | ||
} | ||
it('should fail sending a pageview request', function() { | ||
const analytics = new Analytics('', { debug: true }); | ||
return analytics.event('category', 'view').then((response) => { | ||
return analytics.pageview('http://example.com', 'test', 'test') | ||
.then((response) => { | ||
return expect(response).to.be.empty; | ||
@@ -51,10 +67,9 @@ }).catch((err) => { | ||
it('should send a screenview request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
it('should fail sending a event request', function() { | ||
const analytics = new Analytics('', { debug: true }); | ||
return analytics.screen('test', '1.0.0', 'com.app.test', 'com.app.installer', 'Test') | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
return analytics.event('category', 'view').then((response) => { | ||
return expect(response).to.be.empty; | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
return expect(err).to.not.be.empty; | ||
}); | ||
@@ -74,13 +89,2 @@ }); | ||
it('should send a custom request', function() { | ||
const analytics = new Analytics(trackingID, { debug: true }); | ||
return analytics.send('social', { sa: 'social', sn: 'facebook', st: 'home' }) | ||
.then((response) => { | ||
return expect(response).to.have.property('clientID'); | ||
}).catch((err) => { | ||
return expect(err).to.be.empty; | ||
}); | ||
}); | ||
it('should fail sending a custom request', function() { | ||
@@ -87,0 +91,0 @@ const analytics = new Analytics('', { debug: true }); |
16098
10
344
7
2