2014-07-31 22:45:00 +04:00
|
|
|
describe('telemetry-js-node', function() {
|
|
|
|
var Telemetry = require('./');
|
|
|
|
var Promise = require('promise');
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
// Set timeout
|
|
|
|
this.timeout(10 * 1000);
|
|
|
|
|
|
|
|
it('should load', function() {
|
|
|
|
return new Promise(function(accept) {
|
|
|
|
Telemetry.init(accept);
|
|
|
|
}).then(function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
assert(Telemetry.getVersions, "No versions method available");
|
2014-07-31 22:45:00 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('have versions > 0', function() {
|
|
|
|
return new Promise(function(accept) {
|
|
|
|
Telemetry.init(accept);
|
|
|
|
}).then(function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
assert(Telemetry.getVersions().length > 0, "No versions available");
|
2014-07-31 22:45:00 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('be reloadable', function() {
|
|
|
|
var versionFunction = null;
|
|
|
|
return new Promise(function(accept) {
|
|
|
|
Telemetry.init(accept);
|
|
|
|
}).then(function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
versionFunction = Telemetry.getVersions;
|
|
|
|
assert(Telemetry.getVersions, "No versions method available");
|
2014-07-31 22:45:00 +04:00
|
|
|
return new Promise(function(accept) {
|
|
|
|
Telemetry.init(accept);
|
|
|
|
});
|
|
|
|
}).then(function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
assert(Telemetry.getVersions, "No versions method available");
|
|
|
|
assert(Telemetry.getVersions !== versionFunction,
|
2014-07-31 22:45:00 +04:00
|
|
|
"versions() functions should not be the same");
|
|
|
|
});
|
|
|
|
});
|
2014-07-31 23:24:12 +04:00
|
|
|
|
|
|
|
it('can filter()', function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
var version = "nightly/41";
|
|
|
|
var measure = "GC_MS";
|
2014-07-31 23:24:12 +04:00
|
|
|
return new Promise(function(accept) {
|
|
|
|
Telemetry.init(accept);
|
|
|
|
}).then(function() {
|
2015-07-28 00:23:06 +03:00
|
|
|
assert(Telemetry.getVersions()[0], "Should be a version");
|
2014-07-31 23:24:12 +04:00
|
|
|
return new Promise(function(accept) {
|
2015-07-28 00:23:06 +03:00
|
|
|
var parts = version.split("/");
|
|
|
|
return Telemetry.getFilterOptions(parts[0], parts[1], accept);
|
2014-07-31 23:24:12 +04:00
|
|
|
});
|
2015-07-28 00:23:06 +03:00
|
|
|
}).then(function(filters) {
|
|
|
|
assert(filters.metric[0], "Should have a measure");
|
2014-07-31 23:24:12 +04:00
|
|
|
return new Promise(function(accept) {
|
2015-07-28 00:23:06 +03:00
|
|
|
var parts = version.split("/");
|
|
|
|
return Telemetry.getEvolution(parts[0], parts[1], measure, {}, false, accept);
|
2014-07-31 23:24:12 +04:00
|
|
|
});
|
2015-07-28 00:23:06 +03:00
|
|
|
}).then(function(evolutionMap) {
|
|
|
|
var evolution = evolutionMap[""];
|
|
|
|
assert(evolution.dates, "Has dates");
|
2014-07-31 23:24:12 +04:00
|
|
|
});
|
|
|
|
});
|
2014-07-31 22:45:00 +04:00
|
|
|
});
|