Skip to content

Commit

Permalink
Added some js linting to the code
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbjensen committed Oct 31, 2013
1 parent b9a33aa commit b650a07
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 74 deletions.
106 changes: 56 additions & 50 deletions copy/socketstream_steps.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
var wrap = function (funk, cb) {
funk.end(function(err){
if (err == null || err == undefined){
cb();
} else {
cb.fail(err);
};
});
};
'use strict';



function wrap (funk, cb) {
funk.end(function(err){
if (err === null || err === undefined){
cb();
} else {
cb.fail(err);
}
});
}



module.exports = function (){

this.World = require("../support/world").World;

this.Given(/^I am on the homepage$/, function (callback){
wrap(this.browser.chain.session().open('/'), callback);
});

this.Given(/^I follow "([^"]*)"$/, function (link, callback) {
wrap(this.browser.chain.click("link=" + link), callback);
})

this.When(/^I fill in "([^"]*)" with "([^"]*)"$/, function (field, value, callback) {
wrap(this.browser.chain
.fireEvent("//input[@name=\"" + field + "\"]",'focus')
.type("//input[@name=\"" + field + "\"]", value)
.fireEvent("//input[@name=\"" + field + "\"]",'keyup')
.fireEvent("//input[@name=\"" + field + "\"]",'blur')
, callback
);
});

this.When(/^I press "([^"]*)"$/, function (name, callback){
wrap(this.browser.chain
.fireEvent("//button[text()=\"" + name + "\"]",'focus')
.click("//button[text()=\"" + name + "\"]")
, callback);
});

this.Then(/^I should see "([^"]*)"$/, function (content, callback){
wrap(this.browser.chain.assertTextPresent(content), callback);
});

// If you need to do something like clean/seed the database,
// put the code here, then callback() when done.
this.Before(function(callback){
callback();
});

// This will close the selenium browser at the end of the cucumber feature
this.After(function(callback){
wrap(this.browser.chain.testComplete(), callback);
});
this.World = require('../support/world').World;

this.Given(/^I am on the homepage$/, function (callback){
wrap(this.browser.chain.session().open('/'), callback);
});

this.Given(/^I follow "([^"]*)"$/, function (link, callback) {
wrap(this.browser.chain.click('link=' + link), callback);
});

this.When(/^I fill in "([^"]*)" with "([^"]*)"$/, function (field, value, callback) {
wrap(this.browser.chain
.fireEvent('//input[@name="' + field + '"]','focus')
.type('//input[@name="' + field + '"]', value)
.fireEvent('//input[@name="' + field + '"]','keyup')
.fireEvent('//input[@name="' + field + '"]','blur'),
callback
);
});

this.When(/^I press "([^"]*)"$/, function (name, callback) {
wrap(this.browser.chain
.fireEvent('//button[text()="' + name + '"]','focus')
.click('//button[text()="' + name + '"]'),
callback);
});

this.Then(/^I should see "([^"]*)"$/, function (content, callback){
wrap(this.browser.chain.assertTextPresent(content), callback);
});

// If you need to do something like clean/seed the database,
// put the code here, then callback() when done.
this.Before(function(callback){
callback();
});

// This will close the selenium browser at the end of the cucumber feature
this.After(function(callback){
wrap(this.browser.chain.testComplete(), callback);
});

};
74 changes: 50 additions & 24 deletions copy/world.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
process.env["SS_ENV"] = "cucumber";
'use strict';



// Set the SocketStream environement
//
process.env.SS_ENV = 'cucumber';



// Dependencies
//
var selenium = require('../../node_modules/ss-cucumber/node_modules/selenium-launcher');
var soda = require('../../node_modules/ss-cucumber/node_modules/soda');
var app = require('../../app');



// Load the SocketStream app
//
require('../../app');



var browser = null;

var World = function(callback){

if (browser == null) {
selenium(function(err,selenium){
browser = soda.createClient({
host: selenium.host,
port: selenium.port,
url: "http://localhost:3000",
browser: "firefox"
});

this.browser = browser;
callback({browser: this.browser});
process.on('exit', function(){
selenium.kill();
});
});

} else {
this.browser = browser;
callback({browser: this.browser});
}


var World = function (callback) {

if (browser === null) {

selenium(function(err,selenium){
browser = soda.createClient({
host: selenium.host,
port: selenium.port,
url: 'http://localhost:3000',
browser: 'firefox'
});

this.browser = browser;
callback({browser: this.browser});
process.on('exit', function(){
selenium.kill();
});
});

} else {

this.browser = browser;
callback({browser: this.browser});

}

};



exports.World = World;

0 comments on commit b650a07

Please sign in to comment.