browser-monkey
Advanced tools
Comparing version 1.15.4 to 1.15.5
@@ -256,2 +256,3 @@ var retry = require('trytryagain'); | ||
Selector.prototype.containing = function (selector, options) { | ||
var message = options && JSON.stringify(options); | ||
var findElements = elementFinder(selector); | ||
@@ -277,2 +278,6 @@ var finder; | ||
} | ||
}, | ||
toString: function () { | ||
return selector + (message? ' ' + message: ''); | ||
} | ||
@@ -446,3 +451,3 @@ } | ||
for (var optionIndex = 0; optionIndex < optionList.length; optionIndex++){ | ||
if (optionList[optionIndex].text == selectOptions.text){ | ||
if (optionList[optionIndex].text.indexOf(selectOptions.text) !== -1){ | ||
selectedOption = optionList[optionIndex]; | ||
@@ -449,0 +454,0 @@ selectedOption.selected = true; |
{ | ||
"name": "browser-monkey", | ||
"version": "1.15.4", | ||
"version": "1.15.5", | ||
"description": "reliable dom testing", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,3 +22,3 @@ # browser monkey | ||
// describes the admin panel, with a search box, results and a user editor | ||
var adminPanel = browser.extend({ | ||
var adminPanel = browser.component({ | ||
searchUsers: function () { | ||
@@ -33,13 +33,10 @@ return this.find('.search'); | ||
// return the user editor, scoped to the .user-editor div. | ||
return userEditor.scope(this.find('.user-editor')); | ||
return this.find('.user-editor').component({ | ||
name: function () { this.find('.name'); }, | ||
email: function () { this.find('.email'); }, | ||
save: function () { this.find('.save'); } | ||
}); | ||
} | ||
}); | ||
// describes the user editor, with inputs for name and email, and a save button. | ||
var userEditor = browser.extend({ | ||
name: function () { this.find('.name'); }, | ||
email: function () { this.find('.email'); }, | ||
save: function () { this.find('.save'); }, | ||
}); | ||
it('can search for, edit and save a user', function () { | ||
@@ -58,3 +55,3 @@ return adminPanel.searchUsers().typeIn('bar').then(function () { | ||
// verify that the user was saved | ||
// use mockjax-router! | ||
// use mock-xhr-router! | ||
}); | ||
@@ -107,3 +104,3 @@ }); | ||
You can also create DSLs for components on the page using `scope.extend(methods)`. By extending a scope, you can add methods that represent elements of the component at a higher level than mere CSS selectors. It's probably worth noting that these methods should normally just return scopes and not perform actions or assertions. | ||
You can also create DSLs for components on the page using `scope.component(methods)`. By extending a scope, you can add methods that represent elements of the component at a higher level than mere CSS selectors. It's probably worth noting that these methods should normally just return scopes and not perform actions or assertions. | ||
@@ -306,3 +303,3 @@ ## find | ||
```js | ||
var scope = browser.extend({ | ||
var scope = browser.component({ | ||
mySelect: function(){ | ||
@@ -317,3 +314,8 @@ return this.find('.my-select'); | ||
```js | ||
scope.select([options]); | ||
``` | ||
* `options.text` - a string, text to match against the options text, this will also match partial text | ||
## elements | ||
@@ -320,0 +322,0 @@ |
@@ -201,3 +201,3 @@ var browser = require('..'); | ||
describe('select', function(){ | ||
it('should eventually select an option element', function(){ | ||
it('should eventually select an option element using the text', function(){ | ||
var promise = browser.find('.element').select({text: 'Second'}); | ||
@@ -218,2 +218,18 @@ var selectedItem = undefined; | ||
it('should eventually select an option element using a partial match', function(){ | ||
var promise = browser.find('.element').select({text: 'Seco'}); | ||
var selectedItem = undefined; | ||
eventuallyInsertHtml( | ||
$('<select class="element"><option>First</option><option>Second</option></select>').change(function (e) { | ||
var el = e.target; | ||
selectedItem = el.options[el.selectedIndex].text; | ||
}) | ||
); | ||
return promise.then(function () { | ||
expect(selectedItem).to.equal('Second'); | ||
}); | ||
}); | ||
it('should error when the specified option does not exist', function(){ | ||
@@ -220,0 +236,0 @@ var promise = browser.find('.element').select({text: 'Does not exist'}); |
50676
1033
340