Skip to content

Commit

Permalink
Merge pull request YahooArchive#51 from SOASTA/eslint-test-js
Browse files Browse the repository at this point in the history
ESLint test/*.js

Reviewed By: Charlie
  • Loading branch information
nicjansma committed Apr 28, 2015
2 parents fb00f9e + c3a7afa commit 1f9f2f6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = function (grunt) {
"tests/unit/*.js",
"tests/e2e/*.js",
"tests/server/*.js",
"tests/*.js",
"tests/page-templates/**/*.js"
]
},
Expand Down
15 changes: 7 additions & 8 deletions tests/boomerang-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
page_ready: function() {
this.fired_page_ready = true;
},
before_beacon: function(data) {
},
onbeacon: function(data) {
this.beacons.push(_.clone(data));
this.fired_onbeacon = true;
Expand All @@ -42,12 +40,11 @@
this.fired_before_unload = true;
},
init: function() {
if(this.initialized) {
if (this.initialized) {
return this;
}

BOOMR.subscribe("page_ready", this.page_ready, null, this);
BOOMR.subscribe("before_beacon", this.before_beacon, null, this);
BOOMR.subscribe("onbeacon", this.onbeacon, null, this);
BOOMR.subscribe("before_unload", this.before_unload, null, this);

Expand Down Expand Up @@ -164,7 +161,8 @@
window.document.addEventListener("onBoomerangLoaded", function() {
t.init(config);
});
} else if (window.document.attachEvent) {
}
else if (window.document.attachEvent) {
window.document.attachEvent("onBoomerangLoaded", function() {
t.init(config);
});
Expand All @@ -188,7 +186,7 @@
"h.d": "localhost",
"h.t": new Date().getTime(),
"h.cr": "abc"
})
});

// setup Mocha
window.mocha.globals(["BOOMR", "PageGroupVariable"]);
Expand All @@ -205,13 +203,14 @@
}

BOOMR.subscribe("onbeacon", function() {
if (++beaconsSeen == config.testAfterOnBeacon) {
if (++beaconsSeen === config.testAfterOnBeacon) {
// wait a few more ms so the beacon fires
// TODO: Trim this timing down if we can make it more reliable
setTimeout(t.runTests, 1000);
}
});
} else {
}
else {
BOOMR.setImmediate(t.runTests);
}

Expand Down
28 changes: 19 additions & 9 deletions tests/builder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*eslint-env node*/
//
// Imports
//
Expand Down Expand Up @@ -65,9 +66,6 @@ module.exports = function() {
//make grunt know this task is async.
var done = this.async();

// options we'll be passing thru
var opts = {};

async.waterfall([
//
// First, load all static template variables
Expand Down Expand Up @@ -120,11 +118,15 @@ module.exports = function() {
var templateDir = dir.replace(testTemplatesDir + path.sep, "");
var supportDir = path.join(testTemplatesDir, templateDir, "support");

rootIndexHtml += '<p><a href="' + templateDir + '/index.html">' + templateDir + '</a></p>';
rootIndexHtml += "<p><a href='" + templateDir + "/index.html'>" + templateDir + "</a></p>";

// copy support files over
if (grunt.file.exists(supportDir)) {
getFiles(supportDir, "", function(err, files) {
if (err) {
return cb2(err);
}

var supportDirDest = path.join(testPagesDir, templateDir, "support");

if (!grunt.file.exists(supportDirDest)) {
Expand All @@ -144,6 +146,10 @@ module.exports = function() {

// get all files for this dir
getFiles(dir, ".html", function(err, files) {
if (err) {
return cb2(err);
}

var indexHtml = "";
var indexFile = path.join(testPagesDir, templateDir, "index.html");
var indexFileName = path.join(templateDir, "index.html");
Expand Down Expand Up @@ -182,8 +188,8 @@ module.exports = function() {
//
// Index.html
//
indexHtml += '<p><a href="' + templateFileName + '">' + templateFileName + '</a></p>';
indexHtml += '<iframe src="' + templateFileName + '" style="width: 100%"></iframe>\n'
indexHtml += "<p><a href='" + templateFileName + "'>" + templateFileName + "</a></p>";
indexHtml += "<iframe src='" + templateFileName + "' style='width: 100%'></iframe>\n";

// if the .js file exists, copy that too
if (grunt.file.exists(jsFile)) {
Expand All @@ -206,10 +212,14 @@ module.exports = function() {
// test definitions
grunt.file.write(e2eJsonPath, JSON.stringify(testDefinitions));

cb(null, opts);
cb(err, opts);
});
},
], function(err, opts) {
}
], function(err) {
if (err) {
console.log(err);
}

done();
});
};

0 comments on commit 1f9f2f6

Please sign in to comment.