Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lint client module.

  • Loading branch information...
commit 5f1c6d69249ae673260b242c73441755165903ae 1 parent d5ebc19
@reid reid authored
Showing with 113 additions and 113 deletions.
  1. +113 −113 lib/client.js
View
226 lib/client.js
@@ -12,118 +12,6 @@ var EventEmitter2 = require("eventemitter2").EventEmitter2;
var Blizzard = require("./blizzard");
/**
- * The Client submits test batches to a Yeti Hub and tracks their progress.
- *
- * @class Client
- * @constructor
- * @extends EventEmitter2
- * @param {String} url Yeti Hub HTTP URL.
- */
-function Client(url) {
- EventEmitter2.call(this);
-
- this.session = null;
-
- this.url = url;
-
- this.blizzard = new Blizzard();
-
- this.blizzard.on("error", this.handleBlizzardError.bind(this));
-}
-
-util.inherits(Client, EventEmitter2);
-
-/**
- * Something went wrong.
- * @event error
- * @param {Error} error The error object.
- */
-
-/**
- * An agent connected to the Hub.
- * @event agentConnect
- * @param {String} agent Agent name.
- */
-
-/**
- * An agent requested a page (test or capture) from the connected Hub.
- * @event agentSeen
- * @param {String} agent Agent name.
- */
-
-/**
- * An agent disconnected from the Hub.
- * @event agentDisconnect
- * @param {String} agent Agent name.
- */
-
-/**
- * Connect to the Yeti Hub.
- *
- * @method connect
- * @param {Function} cb Callback function.
- */
-Client.prototype.connect = function (cb) {
- var self = this;
- self.blizzard.connect(self.url, function (err, session) {
- if (err) {
- cb(err);
- return;
- }
-
- session.incomingBridge(self, "agentConnect");
- session.incomingBridge(self, "agentSeen");
- session.incomingBridge(self, "agentDisconnect");
-
- self.session = session;
-
- cb(err);
- });
-};
-
-/**
- * @method handleBlizzardError
- * @protected
- */
-Client.prototype.handleBlizzardError = function (err) {
- if (err.code === "ECONNRESET") {
- this.emit("error", new Error("Server does not speak Yeti's protocol. Version mismatch?"));
- return;
- }
- this.emit("error", err);
-};
-
-/**
- * Create and submit a batch of tests to the Hub.
- *
- * @method createBatch
- * @param {Object} config Batch information.
- * Must contain tests (Array) property.
- * Must also contain either:
- * - basedir (String) -- Root path for test filenames.
- * - useProxy (Boolean) --
- * True if tests are filenames to proxy to the Hub,
- * false if they are literal URL pathnames.
- * Optional. Defaults to true.
- * @return {ClientBatch} batch The new ClientBatch object.
- */
-Client.prototype.createBatch = function (config) {
- // TODO check if connection happened!
- // this.session may not yet exist
- if (!this.session) {
- // TODO Refactor to make this impossible.
- throw new Error("Session started too soon -- Yeti bug.");
- }
-
- if (!("useProxy" in config)) {
- // Use the proxy by default.
- config.useProxy = true;
- }
-
- return new ClientBatch(this.session, config.basedir, config.tests, config.useProxy);
-};
-
-/**
* The ClientBatch represents a batch on the Hub.
*
* @class ClientBatch
@@ -159,7 +47,7 @@ function ClientBatch(session, basedir, tests, useProxy) {
tests: tests,
useProxy: useProxy
}, this.emit.bind(this, "ack"));
-};
+}
util.inherits(ClientBatch, EventEmitter2);
@@ -241,6 +129,118 @@ ClientBatch.prototype.provideTests = function () {
};
/**
+ * The Client submits test batches to a Yeti Hub and tracks their progress.
+ *
+ * @class Client
+ * @constructor
+ * @extends EventEmitter2
+ * @param {String} url Yeti Hub HTTP URL.
+ */
+function Client(url) {
+ EventEmitter2.call(this);
+
+ this.session = null;
+
+ this.url = url;
+
+ this.blizzard = new Blizzard();
+
+ this.blizzard.on("error", this.handleBlizzardError.bind(this));
+}
+
+util.inherits(Client, EventEmitter2);
+
+/**
+ * Something went wrong.
+ * @event error
+ * @param {Error} error The error object.
+ */
+
+/**
+ * An agent connected to the Hub.
+ * @event agentConnect
+ * @param {String} agent Agent name.
+ */
+
+/**
+ * An agent requested a page (test or capture) from the connected Hub.
+ * @event agentSeen
+ * @param {String} agent Agent name.
+ */
+
+/**
+ * An agent disconnected from the Hub.
+ * @event agentDisconnect
+ * @param {String} agent Agent name.
+ */
+
+/**
+ * Connect to the Yeti Hub.
+ *
+ * @method connect
+ * @param {Function} cb Callback function.
+ */
+Client.prototype.connect = function (cb) {
+ var self = this;
+ self.blizzard.connect(self.url, function (err, session) {
+ if (err) {
+ cb(err);
+ return;
+ }
+
+ session.incomingBridge(self, "agentConnect");
+ session.incomingBridge(self, "agentSeen");
+ session.incomingBridge(self, "agentDisconnect");
+
+ self.session = session;
+
+ cb(err);
+ });
+};
+
+/**
+ * @method handleBlizzardError
+ * @protected
+ */
+Client.prototype.handleBlizzardError = function (err) {
+ if (err.code === "ECONNRESET") {
+ this.emit("error", new Error("Server does not speak Yeti's protocol. Version mismatch?"));
+ return;
+ }
+ this.emit("error", err);
+};
+
+/**
+ * Create and submit a batch of tests to the Hub.
+ *
+ * @method createBatch
+ * @param {Object} config Batch information.
+ * Must contain tests (Array) property.
+ * Must also contain either:
+ * - basedir (String) -- Root path for test filenames.
+ * - useProxy (Boolean) --
+ * True if tests are filenames to proxy to the Hub,
+ * false if they are literal URL pathnames.
+ * Optional. Defaults to true.
+ * @return {ClientBatch} batch The new ClientBatch object.
+ */
+Client.prototype.createBatch = function (config) {
+ // TODO check if connection happened!
+ // this.session may not yet exist
+ if (!this.session) {
+ // TODO Refactor to make this impossible.
+ throw new Error("Session started too soon -- Yeti bug.");
+ }
+
+ if (undefined === config.useProxy) {
+ // Use the proxy by default.
+ config.useProxy = true;
+ }
+
+ return new ClientBatch(this.session, config.basedir, config.tests, config.useProxy);
+};
+
+/**
* @class exports
* @static
*/
Please sign in to comment.
Something went wrong with that request. Please try again.