rx-page-objects
Advanced tools
Comparing version 1.47.3 to 1.48.0-0
190
exercise.js
/*jshint node:true*/ | ||
var _ = require('lodash'); | ||
var rxCheckbox = require('./index').rxCheckbox; | ||
var _ = require('lodash');var rxBulkSelect = require('./index').rxBulkSelect; | ||
/** | ||
* @function | ||
* @description rxCheckbox exercises | ||
* @exports exercise/rxCheckbox | ||
* @returns {function} A function to be passed to mocha's `describe`. | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxCheckbox} [options.instance] - Component to exercise. | ||
* @param {String} [options.cssSelector] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @param {Boolean} [options.disabled=false] - Whether the checkbox is disabled at the start of the exercise | ||
* @param {Boolean} [options.selected=false] - Whether the checkbox is selected at the start of the exercise | ||
* @param {Boolean} [options.visible=true] - Whether the checkbox is visible at the start of the exercise | ||
* @param {Boolean} [options.valid=true] - Whether the checkbox is valid at the start of the exercise | ||
*/ | ||
exports.rxCheckbox = function (options) { | ||
if (options === undefined) { | ||
options = {}; | ||
} | ||
options = _.defaults(options, { | ||
disabled: false, | ||
selected: false, | ||
visible: true, | ||
valid: true | ||
}); | ||
return function () { | ||
var component; | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxCheckbox.initialize($(options.cssSelector)); | ||
} | ||
}); | ||
it('should be present', function () { | ||
expect(component.isPresent()).to.eventually.be.true; | ||
}); | ||
it('should be a checkbox', function () { | ||
expect(component.isCheckbox()).to.eventually.be.true; | ||
}); | ||
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () { | ||
expect(component.isDisplayed()).to.eventually.eq(options.visible); | ||
}); | ||
it('should ' + (options.disabled ? 'be' : 'not be') + ' disabled', function () { | ||
expect(component.isDisabled()).to.eventually.eq(options.disabled); | ||
}); | ||
it('should ' + (options.selected ? 'be' : 'not be') + ' selected', function () { | ||
expect(component.isSelected()).to.eventually.eq(options.selected); | ||
}); | ||
if (options.disabled) { | ||
it('should not respond to selecting and unselecting', function () { | ||
component.isSelected().then(function (selected) { | ||
selected ? component.deselect() : component.select(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
// even though it "doesn't respond to selecting and unselecting" | ||
// attempt to put it back anyway in case it did actually respond. | ||
// that way nobody accidentally submits a swapped checkbox after | ||
// running these exercises. | ||
selected ? component.select() : component.deselect(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
}); | ||
}); | ||
} else { | ||
it('should respond to selecting and unselecting', function () { | ||
component.isSelected().then(function (selected) { | ||
selected ? component.deselect() : component.select(); | ||
expect(component.isSelected()).to.eventually.not.equal(selected); | ||
// exercises should never alter the state of a page. | ||
// always put it back when you're done. | ||
selected ? component.select() : component.deselect(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
}); | ||
}); | ||
} | ||
it('should ' + (options.valid ? 'be' : 'not be') + ' valid', function () { | ||
expect(component.isValid()).to.eventually.eq(options.valid); | ||
}); | ||
}; | ||
}; | ||
var rxBulkSelect = require('./index').rxBulkSelect; | ||
/** | ||
@@ -1452,1 +1358,95 @@ * @function | ||
}; | ||
var rxCheckbox = require('./index').rxCheckbox; | ||
/** | ||
* @function | ||
* @description rxCheckbox exercises | ||
* @exports exercise/rxCheckbox | ||
* @returns {function} A function to be passed to mocha's `describe`. | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxCheckbox} [options.instance] - Component to exercise. | ||
* @param {String} [options.cssSelector] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @param {Boolean} [options.disabled=false] - Whether the checkbox is disabled at the start of the exercise | ||
* @param {Boolean} [options.selected=false] - Whether the checkbox is selected at the start of the exercise | ||
* @param {Boolean} [options.visible=true] - Whether the checkbox is visible at the start of the exercise | ||
* @param {Boolean} [options.valid=true] - Whether the checkbox is valid at the start of the exercise | ||
*/ | ||
exports.rxCheckbox = function (options) { | ||
if (options === undefined) { | ||
options = {}; | ||
} | ||
options = _.defaults(options, { | ||
disabled: false, | ||
selected: false, | ||
visible: true, | ||
valid: true | ||
}); | ||
return function () { | ||
var component; | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxCheckbox.initialize($(options.cssSelector)); | ||
} | ||
}); | ||
it('should be present', function () { | ||
expect(component.isPresent()).to.eventually.be.true; | ||
}); | ||
it('should be a checkbox', function () { | ||
expect(component.isCheckbox()).to.eventually.be.true; | ||
}); | ||
it('should ' + (options.visible ? 'be' : 'not be') + ' visible', function () { | ||
expect(component.isDisplayed()).to.eventually.eq(options.visible); | ||
}); | ||
it('should ' + (options.disabled ? 'be' : 'not be') + ' disabled', function () { | ||
expect(component.isDisabled()).to.eventually.eq(options.disabled); | ||
}); | ||
it('should ' + (options.selected ? 'be' : 'not be') + ' selected', function () { | ||
expect(component.isSelected()).to.eventually.eq(options.selected); | ||
}); | ||
if (options.disabled) { | ||
it('should not respond to selecting and unselecting', function () { | ||
component.isSelected().then(function (selected) { | ||
selected ? component.deselect() : component.select(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
// even though it "doesn't respond to selecting and unselecting" | ||
// attempt to put it back anyway in case it did actually respond. | ||
// that way nobody accidentally submits a swapped checkbox after | ||
// running these exercises. | ||
selected ? component.select() : component.deselect(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
}); | ||
}); | ||
} else { | ||
it('should respond to selecting and unselecting', function () { | ||
component.isSelected().then(function (selected) { | ||
selected ? component.deselect() : component.select(); | ||
expect(component.isSelected()).to.eventually.not.equal(selected); | ||
// exercises should never alter the state of a page. | ||
// always put it back when you're done. | ||
selected ? component.select() : component.deselect(); | ||
expect(component.isSelected()).to.eventually.equal(selected); | ||
}); | ||
}); | ||
} | ||
it('should ' + (options.valid ? 'be' : 'not be') + ' valid', function () { | ||
expect(component.isValid()).to.eventually.eq(options.valid); | ||
}); | ||
}; | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "Midway test page objects for all of the Encore UI components", | ||
"version": "1.47.3", | ||
"version": "1.48.0-0", | ||
"main": "index.js", | ||
@@ -13,3 +13,3 @@ "license": "Apache License, Version 2.0", | ||
"dependencies": { | ||
"moment": "2.8.2", | ||
"moment": "2.13.0", | ||
"lodash": "2.4.1", | ||
@@ -16,0 +16,0 @@ "node-timing.js": "1.1.0" |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
338422
8826
3
+ Addedmoment@2.13.0(transitive)
- Removedmoment@2.8.2(transitive)
Updatedmoment@2.13.0