browser-monkey
Advanced tools
Comparing version 1.6.0 to 1.7.0
23
index.js
@@ -80,2 +80,3 @@ var retry = require('trytryagain'); | ||
var value = optionsObject && options.hasOwnProperty('value')? options.value: undefined; | ||
var html = optionsObject && options.hasOwnProperty('html')? options.html: undefined; | ||
@@ -96,3 +97,6 @@ if (typeof options === 'string') { | ||
if (!els.is(css)) { | ||
throw new Error(message || ('expected elements to have css ' + css)); | ||
var elements = els.toArray().map(function (el) { | ||
return el.outerHTML.replace(el.innerHTML, ''); | ||
}); | ||
throw new Error(message || ('expected elements ' + elements.join(', ') + ' to have css ' + css)); | ||
} | ||
@@ -109,2 +113,6 @@ } | ||
if (html) { | ||
assertElementProperties(els, html, function (e) { return e.html(); }); | ||
} | ||
if (length !== undefined) { | ||
@@ -163,3 +171,3 @@ if (els.length !== length) { | ||
Extension.prototype = new Selector(); | ||
Extension.prototype = this; | ||
Object.keys(methods).forEach(function (method) { | ||
@@ -287,2 +295,13 @@ Extension.prototype[method] = methods[method]; | ||
Selector.prototype.shouldNotHave = function(options) { | ||
var resolveOptions; | ||
if (typeof options === 'object') { | ||
resolveOptions = JSON.parse(JSON.stringify(options)); | ||
resolveOptions.allowMultiple = true; | ||
} else { | ||
resolveOptions = {allowMultiple: true}; | ||
} | ||
return this.addFinder(elementTester(options)).shouldNotExist(resolveOptions); | ||
}; | ||
Selector.prototype.click = function(options) { | ||
@@ -289,0 +308,0 @@ return this.resolve(options).then(function($element) { |
{ | ||
"name": "browser-monkey", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "reliable dom testing", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ function dispatchEvent(el, type, char) { | ||
sendkey = function sendkey(el, char) { | ||
function sendkey(el, char) { | ||
dispatchEvent(el, "keydown", char); | ||
@@ -11,0 +11,0 @@ dispatchEvent(el, "keyup", char); |
@@ -290,2 +290,27 @@ var browser = require('..'); | ||
it('can extend another component', function () { | ||
var user = browser.component({ | ||
name: function () { | ||
return this.find('.user-name'); | ||
}, | ||
address: function () { | ||
return this.find('.user-address'); | ||
} | ||
}); | ||
var bossUser = user.component({ | ||
secondAddress: function () { | ||
return this.find('.user-second-address'); | ||
} | ||
}); | ||
var name = bossUser.name().shouldExist(); | ||
var secondAddress = bossUser.secondAddress().shouldExist(); | ||
eventuallyInsertHtml('<div class="user"><div class="user-name">bob</div><div class="user-address">bob\'s address</div><div class="user-second-address">bob\'s second address</div></div>'); | ||
return Promise.all([name, secondAddress]); | ||
}); | ||
it('can return new scoped selectors', function () { | ||
@@ -292,0 +317,0 @@ var admin = browser.component({ |
32876
655