Skip to content

Commit

Permalink
adding isVisible; tests; minor release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Breed committed Sep 24, 2013
1 parent 2a5480c commit 18fc72d
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true
}
26 changes: 26 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
config =

jshint:
all: [
'tasks/**/*.js'
],
options:
jshintrc: '.jshintrc'

mochaSelenium:
options:
timeout: 30e3
usePromises: true
all:
src: ['test/index.js']

module.exports = (grunt) ->

grunt.initConfig(config)

grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-mocha-selenium')

grunt.registerTask('test', ['mochaSelenium'])

grunt.registerTask('default', ['jshint', 'test'])
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
wd-query
========

jQuery style selectors for [wd]().
jQuery style selectors for [wd](https://github.com/admc/wd).

### tl;dr

Expand All @@ -19,7 +19,7 @@ browser.init()
return $('#login-form').submit();
})
.then(function(){
return $('body').hasClass('loggedIn');
return $('.loggedIn').isVisible('loggedIn');
})
.then(function(body){
assert.ok(body);
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,28 @@ module.exports = function(browser){
click: function(){
return this.get()
.then(function(elem){
elem.click();
return elem.click();
});
},


submit: function(){
return this.get()
.then(function(elem){
elem.submit();
return elem.submit();
});
},

tap: function(){
return this.get()
.then(function(elem){
elem.tap();
return elem.tap();
});
},

isVisible: function(){
return this.get()
.then(function(elem){
return elem.isVisible();
});
}

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "wd-query",
"version": "0.0.1",
"version": "0.0.2",
"description": "A jQuery-esue wrapper for wd",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "grunt"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +22,8 @@
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-mocha-selenium": "~0.4.0"
"grunt-mocha-selenium": "~0.4.0",
"grunt-cli": "~0.1.9",
"grunt-contrib-jshint": "~0.6.4"
}
}
34 changes: 34 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var assert = require('assert');
var wdQuery = require('../index.js');

describe('wd-query', function () {

describe('injected browser executing a Google Search', function () {
var browser, $;

before(function(){
browser = this.browser;
$ = wdQuery(browser);
});

it('performs as expected', function (done) {
browser.get('http://google.com')
.then(function () {
return $('input[name=q]').val('webdriver');
})
.then(function () {
return $('input[name=q]').val();
})
.then(function (val) {
return assert.equal(val, 'webdriver');
})
.then(function(){
return $('body').isVisible();
})
.then(function(isVisible){
assert.ok(isVisible);
done();
});
});
});
});

0 comments on commit 18fc72d

Please sign in to comment.