rx-page-objects
Advanced tools
Comparing version 2.0.0-1 to 2.0.0-2
598
exercise.js
/*jshint node:true*/ | ||
var _ = require('lodash'); | ||
var rxCheckbox = require('./index').rxCheckbox; | ||
/** | ||
* @function | ||
* @description rxCheckbox exercises | ||
* @exports encore.exercise.rxCheckbox | ||
* @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] - Determines if the checkbox is disabled | ||
* @param {Boolean} [options.selected=false] - Determines if the checkbox is selected | ||
* @param {Boolean} [options.visible=true] - Determines if the checkbox is visible | ||
* @param {Boolean} [options.valid=true] - Determines if the checkbox is valid | ||
* @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 {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 | ||
*/ | ||
@@ -32,10 +32,3 @@ exports.rxCheckbox = function (options) { | ||
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)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -95,19 +88,19 @@ | ||
var rxBulkSelect = require('./index').rxBulkSelect; | ||
/** | ||
rxBulkSelect exercises. | ||
@exports encore.exercise.rxBulkSelect | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxBulkSelect} [options.instance=] - Component to exercise. | ||
@param {string[]} [options.batchActions] - List of batch actions to exercise, will not run exercises if empty. | ||
@param {number} [options.count=10] - Number of items in the table. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxBulkSelect({ | ||
instance: myPage.bulkSelect // select one of many widgets from your page objects | ||
})); | ||
``` | ||
* @function | ||
* @description rxBulkSelect exercises. | ||
* @exports exercise/rxBulkSelect | ||
* @returns {function} A function to be passed to mocha's `describe`. | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxBulkSelect} [options.instance={@link rxBulkSelect.initialize}] - Component to exercise. | ||
* @param {string[]} [options.batchActions=[]] - List of batch actions to exercise, will not run exercises if empty. | ||
* @param {number} [options.count=10] - Number of items in the table. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxBulkSelect({ | ||
* instance: myPage.bulkSelect, // select one of many widgets from your page objects | ||
* batchActions: ['Create', 'Read', 'Update', 'Delete'] | ||
* })); | ||
*/ | ||
@@ -120,2 +113,3 @@ exports.rxBulkSelect = function (options) { | ||
options = _.defaults(options, { | ||
instance: rxBulkSelect.initialize(), | ||
count: 10, | ||
@@ -129,13 +123,3 @@ batchActions: [] | ||
before(function () { | ||
if (options.instance === undefined) { | ||
component = rxBulkSelect.main; | ||
} else { | ||
component = options.instance; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxBulkSelect.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -240,24 +224,22 @@ | ||
var rxCharacterCount = require('./index').rxCharacterCount; | ||
/** | ||
rxCharacterCount exercises. | ||
@exports encore.exercise.rxCharacterCount | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxCharacterCount} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {Number} [options.maxCharacters=254] - The total number of characters allowed. | ||
@param {Number} [options.nearLimit=10] - The number of remaining characters needed to trigger the "near-limit" class. | ||
@param {Boolean} [options.ignoreInsignificantWhitespace=false] - Whether or not the textbox ignores leading and | ||
trailing whitespace when calculating the remaining character count. | ||
@param {Boolean} [options.highlight=false] - Determines if text over the limit should be highlighted. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxCharacterCount({ | ||
instance: myPage.submission // select one of many widgets from your page objects | ||
maxCharacters: 25, | ||
nearLimit: 12, | ||
ignoreInsignificantWhitespace: false | ||
})); | ||
``` | ||
* @function | ||
* @description rxCharacterCount exercises. | ||
* @exports exercise/rxCharacterCount | ||
* @returns {function} A function to be passed to mocha's `describe`. | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxCharacterCount} options.instance - Component to exercise. | ||
* @param {Number} [options.maxCharacters=254] - The total number of characters allowed. | ||
* @param {Number} [options.nearLimit=10] - The number of remaining characters needed to trigger the "near-limit" class. | ||
* @param {Boolean} [options.ignoreInsignificantWhitespace=false] - Whether or not the textbox ignores leading and | ||
* trailing whitespace when calculating the remaining character count. | ||
* @param {Boolean} [options.highlight=false] - Determines if text over the limit should be highlighted. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxCharacterCount({ | ||
* instance: myPage.submission // select one of many widgets from your page objects | ||
* maxCharacters: 25, | ||
* nearLimit: 12, | ||
* ignoreInsignificantWhitespace: false | ||
* })); | ||
*/ | ||
@@ -280,12 +262,3 @@ exports.rxCharacterCount = function (options) { | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxCharacterCount.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxCharacterCount.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -408,20 +381,18 @@ | ||
var rxCollapse = require('./index').rxCollapse; | ||
/** | ||
rxCollapse exercises. | ||
@exports encore.exercise.rxCollapse | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxCollapse} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {String} title - The title of the rxCollapse element. | ||
@param {Boolean} expanded - Whether or not the rxCollapse element is currently expanded. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxCollapse({ | ||
instance: myPage.hiddenSection, // select one of many widgets from your page objects | ||
title: 'My Custom rxCollapse Element', | ||
expanded: true | ||
})); | ||
``` | ||
* @function | ||
* @description rxCollapse exercises. | ||
* @return {function} A function to be passed to mocha's `describe`. | ||
* @exports exercise/rxCollapse | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxCollapse} options.instance - Component to exercise. | ||
* @param {String} [options.title] - The title of the rxCollapse element. | ||
* @param {Boolean} [options.expanded=false] - Whether or not the rxCollapse element is currently expanded. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxCollapse({ | ||
* instance: myPage.hiddenSection, // select one of many widgets from your page objects | ||
* title: 'My Custom rxCollapse Element', | ||
* expanded: true | ||
* })); | ||
*/ | ||
@@ -442,12 +413,3 @@ exports.rxCollapse = function (options) { | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxCollapse.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxCollapse.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -520,13 +482,10 @@ | ||
var rxForm = require('./index').rxForm; | ||
/** | ||
* rxFieldName exercises. | ||
* @exports encore.exercise.rxFieldName | ||
* @param {Object} [options=] - Test options. Used to build valid tests. | ||
* @param {rxFieldName} [options.instance=] - Component to exercise. | ||
* @param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @param {string} [options.visible=true] - Determines if the field name is visible | ||
* @param {string} [options.present=true] - Determines if the field name is present in the DOM | ||
* @param {string} [options.required=false] - Determines if the field name displays as required | ||
* @exports exercise/rxFieldName | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxFieldName} options.instance - Component to exercise. | ||
* @param {string} [options.visible=true] - Determines if the field name is visible. | ||
* @param {string} [options.present=true] - Determines if the field name is present in the DOM. | ||
* @param {string} [options.required=false] - Determines if the field name displays as a required field. | ||
*/ | ||
@@ -548,10 +507,3 @@ exports.rxFieldName = function (options) { | ||
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 = rxForm.fieldName.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -598,16 +550,16 @@ | ||
* rxMetadata exercises | ||
* @exports encore.exercise.rxMetadata | ||
* @param {Object} [options=] Test options. Used to build valid tests. | ||
* @param {string} [options.cssSelector=] Fallback selector string to initialize widget with. | ||
* @param {Boolean} [options.present=true] Determines if the metadata is present in the DOM | ||
* @param {Boolean} [options.visible=true] Determines if the metadata is visible | ||
* @param {Object} [transformFns=] - Transformation functions to be passed to rxMetadata | ||
* @param {Object} [options.terms=] The expected label text of each metadata entry | ||
* @exports exercise/rxMetadata | ||
* @param {Object} [options] Test options. Used to build valid tests. | ||
* @param {rxMetadata} [instance={@link rxMetadata.initialize}] Component to exercise. | ||
* @param {Boolean} [options.present=true] Determines if the metadata is present in the DOM. | ||
* @param {Boolean} [options.visible=true] Determines if the metadata is visible. | ||
* @param {Object} [options.transformFns] - Transformation functions to be passed to rxMetadata. | ||
* @param {Object} [options.terms] The expected label text of each metadata entry. | ||
* @example | ||
* ```js | ||
* describe('metadata', encore.exercise.rxMetadata({ | ||
* instance: myPage.accountOverviewMetadata, | ||
* transformFns: { | ||
* 'Signup Date': function (elem) { | ||
* return elem.getText().then(function (text) { | ||
* return new Date(text); | ||
* return new Date(text).valueOf(); | ||
* }); | ||
@@ -623,3 +575,3 @@ * }, | ||
* return elem.getText().then(function (text) { | ||
* return new Date(text); | ||
* return new Date(text).valueOf(); | ||
* }); | ||
@@ -629,9 +581,8 @@ * } | ||
* terms: { | ||
* 'Signup Date': new Date('March 1st, 2011'), | ||
* 'Signup Date': new Date('March 1st, 2011').valueOf(), | ||
* 'Overdue Balance': 13256, | ||
* 'Current Due': 64400, | ||
* 'Expiration Date': new Date('January 1st, 2021') | ||
* 'Expiration Date': new Date('January 1st, 2021').valueOf() | ||
* } | ||
* })); | ||
* ``` | ||
*/ | ||
@@ -644,2 +595,3 @@ exports.rxMetadata = function (options) { | ||
options = _.defaults(options, { | ||
instance: rxMetadata.initialize(), | ||
present: true, | ||
@@ -653,8 +605,3 @@ visible: true, | ||
before(function () { | ||
if (options.cssSelector === undefined) { | ||
// don't use main -- you need to be able to supply `transformFns` via `initialize` | ||
component = rxMetadata.initialize($('rx-metadata'), options.transformFns); | ||
} else { | ||
component = rxMetadata.initialize($(options.cssSelector), options.transformFns); | ||
} | ||
component = rxMetadata.initialize(options.instance.rootElement, options.transformFns); | ||
}); | ||
@@ -690,14 +637,14 @@ | ||
/** | ||
rxMultiSelect exercises. | ||
@exports encore.exercise.rxMultiSelect | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxMultiSelect} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {Object} [options.inputs=[]] - The options of the select input. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxMultiSelect({ | ||
instance: myPage.subscriptionList, // select one of many widgets from your page objects | ||
})); | ||
``` | ||
* rxMultiSelect exercises. | ||
* @exports exercise/rxMultiSelect | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxMultiSelect} [options.instance={@link rxMultiSelect.initialize}] - Component to exercise. | ||
* @param {Object} [options.inputs=[]] - The options of the select input. | ||
* @param {Object} [options.disabled=false] - Determines if the multiselect is disabled. | ||
* @param {Object} [options.valid=true] - Determines if the multiselect is valid. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxMultiSelect({ | ||
* instance: myPage.subscriptionList, // select one of many widgets from your page objects | ||
* inputs: ['Texas', 'California', 'Virginia', 'Georgia'] | ||
* })); | ||
*/ | ||
@@ -710,3 +657,6 @@ exports.rxMultiSelect = function (options) { | ||
options = _.defaults(options, { | ||
inputs: [] | ||
instance: rxMultiSelect.initialize(), | ||
inputs: [], | ||
disabled: false, | ||
valid: true | ||
}); | ||
@@ -718,61 +668,70 @@ | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxMultiSelect.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxMultiSelect.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
it('hides the menu initially', function () { | ||
it('should hide the menu initially', function () { | ||
expect(component.isOpen()).to.eventually.be.false; | ||
}); | ||
it('shows the menu when clicked', function () { | ||
component.openMenu(); | ||
expect(component.isOpen()).to.eventually.be.true; | ||
it('should ' + (options.valid ? 'be' : 'not be') + ' valid', function () { | ||
expect(component.isValid()).to.eventually.eq(options.valid); | ||
}); | ||
it('selects no options', function () { | ||
component.deselect(['Select All']); | ||
expect(component.selectedOptions).to.eventually.be.empty; | ||
expect(component.preview).to.eventually.equal('None'); | ||
}); | ||
if (options.disabled) { | ||
it('should not show the menu when clicked', function () { | ||
component.openMenu(); | ||
expect(component.isOpen()).to.eventually.be.false; | ||
}); | ||
} else { | ||
it('should show the menu when clicked', function () { | ||
component.openMenu(); | ||
expect(component.isOpen()).to.eventually.be.true; | ||
}); | ||
it('selects a single option', function () { | ||
var input = _.first(options.inputs); | ||
component.select([input]); | ||
expect(component.selectedOptions).to.eventually.eql([input]); | ||
expect(component.preview).to.eventually.equal(input); | ||
}); | ||
it('should select all options', function () { | ||
component.select(['Select All']); | ||
expect(component.selectedOptions).to.eventually.eql(['Select All'].concat(options.inputs)); | ||
expect(component.preview).to.eventually.equal('All Selected'); | ||
}); | ||
if (options.inputs.length > 2) { | ||
it('selects multiple options', function () { | ||
var inputs = options.inputs.slice(0, 2); | ||
component.select(inputs); | ||
expect(component.selectedOptions).to.eventually.eql(inputs); | ||
expect(component.preview).to.eventually.equal('2 Selected'); | ||
it('should select no options', function () { | ||
component.deselect(['Select All']); | ||
expect(component.selectedOptions).to.eventually.be.empty; | ||
expect(component.preview).to.eventually.equal('None'); | ||
}); | ||
} | ||
it('selects all options', function () { | ||
component.select(['Select All']); | ||
expect(component.selectedOptions).to.eventually.eql(['Select All'].concat(options.inputs)); | ||
expect(component.preview).to.eventually.equal('All Selected'); | ||
}); | ||
it('should select a single option', function () { | ||
var input = _.first(options.inputs); | ||
component.select([input]); | ||
expect(component.selectedOptions).to.eventually.eql([input]); | ||
expect(component.preview).to.eventually.equal(input); | ||
}); | ||
it('deselects all options', function () { | ||
component.deselect(['Select All']); | ||
expect(component.selectedOptions).to.eventually.be.empty; | ||
expect(component.preview).to.eventually.equal('None'); | ||
}); | ||
if (options.inputs.length > 2) { | ||
it('should select multiple options', function () { | ||
var inputs = options.inputs.slice(0, 2); | ||
component.select(inputs); | ||
expect(component.selectedOptions).to.eventually.eql(inputs); | ||
expect(component.preview).to.eventually.equal('2 Selected'); | ||
}); | ||
} | ||
it('hides the menu when another element is clicked', function () { | ||
component.rootElement.element(by.xpath('../..')).click(); | ||
expect(component.isOpen()).to.eventually.be.false; | ||
}); | ||
it('should select all options', function () { | ||
component.select(['Select All']); | ||
expect(component.selectedOptions).to.eventually.eql(['Select All'].concat(options.inputs)); | ||
expect(component.preview).to.eventually.equal('All Selected'); | ||
}); | ||
it('should deselect all options', function () { | ||
component.deselect(['Select All']); | ||
expect(component.selectedOptions).to.eventually.be.empty; | ||
expect(component.preview).to.eventually.equal('None'); | ||
}); | ||
it('should hide the menu when backdrop is clicked', function () { | ||
component.rootElement.$('.backdrop').click(); | ||
expect(component.isOpen()).to.eventually.be.false; | ||
}); | ||
}//if options.disabled | ||
}; | ||
@@ -785,7 +744,6 @@ }; | ||
/** | ||
* rxOptionTable exercises. | ||
* @exports encore.exercise.rxOptionTable | ||
* @param {Object} [options=] - Test options. Used to build valid tests. | ||
* @param {rxOptionTable} [options.instance=] - Component to exercise. | ||
* @param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @description rxOptionTable exercises. | ||
* @exports exercise/rxOptionTable | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxOptionTable} [options.instance={@link rxOptionTable.initialize}] - Component to exercise. | ||
* @param {string} [options.visible=true] - Determines if the option table is visible | ||
@@ -800,2 +758,3 @@ * @param {string} [options.empty=false] - Determines if the option table is empty | ||
options = _.defaults(options, { | ||
instance: rxOptionTable.initialize(), | ||
visible: true, | ||
@@ -809,12 +768,3 @@ empty: false | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxOptionTable.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxOptionTable.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -848,21 +798,16 @@ | ||
var rxPaginate = require('./index').rxPaginate; | ||
/** | ||
rxPaginate exercises. | ||
@exports encore.exercise.rxPaginate | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxPaginate} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {string} [options.pages=6] - Estimated page size in the pagination widget. | ||
@param {number[]} [options.pageSizes=50, 200, 350, 500] - Page sizes to validate. | ||
@param {number} [options.defaultPageSize=50] - Default page size on page load. | ||
@param {number} [options.invalidPageSize=45] - For testing resizing pagination to invalid items per page. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxPaginate({ | ||
instance: myPage.pagination, // select one of many pagination instances from your page objects | ||
pages: 20 // will exercise full functionality at 6, limited functionality at 2 | ||
})); | ||
``` | ||
* rxPaginate exercises. | ||
* @exports exercise/rxPaginate | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxPaginate} options.instance - Component to exercise. | ||
* @param {String} [options.pages=6] - Estimated page size in the pagination widget. | ||
* @param {Number[]} [options.pageSizes=[50, 200, 350, 500]] - Page sizes to validate. | ||
* @param {Number} [options.defaultPageSize=50] - Default page size on page load. | ||
* @param {Number} [options.invalidPageSize=45] - For testing resizing pagination to invalid items per page. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxPaginate({ | ||
* instance: myPage.pagination, // select one of many pagination instances from your page objects | ||
* pages: 20 // will exercise full functionality at 6, limited functionality at 2 | ||
* })); | ||
*/ | ||
@@ -885,12 +830,3 @@ exports.rxPaginate = function (options) { | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
pagination = options.instance; | ||
} else { | ||
pagination = rxPaginate.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
pagination = rxPaginate.initialize($(options.cssSelector)); | ||
} | ||
pagination = options.instance; | ||
}); | ||
@@ -1033,14 +969,12 @@ | ||
var rxRadio = require('./index').rxRadio; | ||
/** | ||
* @description rxRadio exercises | ||
* @exports encore.exercise.rxRadio | ||
* @param {Object} [options=] - Test options. Used to build valid tests. | ||
* @param {rxRadio} [options.instance=] - Component to exercise. | ||
* @param {String} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @param {Boolean} [options.disabled=false] - Determines if the radio is disabled. | ||
* @param {Boolean} [options.selected=false] - Determines if the radio is selected. | ||
* @param {Boolean} [options.visible=true] - Determines if the radio is visible. | ||
* @param {Boolean} [options.valid=true] - Determines if the radio is valid. | ||
* @exports exercise/rxRadio | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxRadio} options.instance - Component to exercise. | ||
* @param {Boolean} [options.disabled=false] - Whether or not the radio button is disabled at the start of the exercise. | ||
* @param {Boolean} [options.selected=false] - Whether or not the radio button is selected at the start of the exercise. | ||
* @param {Boolean} [options.visible=true] - Whether or not the radio button is visible at the start of the exercise. | ||
* @param {Boolean} [options.valid=true] - Whether or not the radio button is valid at the start of the exercise. | ||
*/ | ||
@@ -1063,10 +997,3 @@ exports.rxRadio = function (options) { | ||
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 = rxRadio.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -1101,18 +1028,16 @@ | ||
var rxSearchBox = require('./index').rxSearchBox; | ||
/** | ||
rxSearchBox exercises. | ||
@exports encore.exercise.rxSearchBox | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {rxSearchBox} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {boolean} [options.disabled=false] - Determines if the search box is disabled | ||
@param {string} [options.placeholder='Search...'] - Expected placeholder value | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxSearchBox({ | ||
instance: myPage.searchText, // select one of many widgets from your page objects | ||
})); | ||
``` | ||
* @description rxSearchBox exercises. | ||
* @see rxSearchBox | ||
* @exports exercise/rxSearchBox | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxSearchBox} options.instance - Component to exercise. | ||
* @param {Boolean} [options.disabled=false] - Determines if the search box is disabled at the start of the exercise. | ||
* @param {String} [options.placeholder='Search...'] - Expected placeholder value. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxSearchBox({ | ||
* instance: myPage.searchText, // select one of many widgets from your page objects | ||
* placeholder: 'Filter by name...' | ||
* })); | ||
*/ | ||
@@ -1133,12 +1058,3 @@ exports.rxSearchBox = function (options) { | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxSearchBox.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxSearchBox.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -1195,14 +1111,13 @@ | ||
var rxSelect = require('./index').rxSelect; | ||
/** | ||
* @description rxSelect exercises | ||
* @exports encore.exercise.rxSelect | ||
* @param {Object} [options=] - Test options. Used to build valid tests. | ||
* @param {rxSelect} [options.instance=] - Component to exercise. | ||
* @param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
* @description rxSelect exercises. | ||
* @see rxSelect | ||
* @exports exercise/rxSelect | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxSelect} options.instance - Component to exercise. | ||
* @param {Boolean} [options.disabled=false] - Determines if the select is disabled | ||
* @param {Boolean} [options.visible=true] - Determines if the select is visible | ||
* @param {Boolean} [options.valid=true] - Determines if the select is valid | ||
* @param {String} selectedText - The expected selected text of the dropdown. | ||
* @param {String} [selectedText] - The expected selected text of the dropdown. | ||
*/ | ||
@@ -1224,10 +1139,3 @@ exports.rxSelect = function (options) { | ||
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 = rxSelect.initialize($(options.cssSelector)); | ||
} | ||
component = options.instance; | ||
}); | ||
@@ -1263,12 +1171,11 @@ | ||
* rxTags exercises | ||
* @exports encore.exercise.rxTags | ||
* @param {Object} [options=] - Test options. Used to build valid tests. | ||
* @param {rxTags} [options.instance=] - Component to Exercise. | ||
* @exports exercise/rxTags | ||
* @param {Object} [options] - Test options. Used to build valid tests. | ||
* @param {rxTags} [options.instance=rxTags.initialize()] - Component to Exercise. | ||
* @param {string} options.sampleText - A tag that can be added. | ||
* @example | ||
* <pre> | ||
* describe('default exercises', encore.exercise.rxTags({ | ||
* instance: encore.rxTags.initialize('.demo rx-tags') // select one of many widgets on page | ||
* sampleText: 'Tag text to use when creating and testing your tags' | ||
* })); | ||
* </pre> | ||
*/ | ||
@@ -1291,3 +1198,3 @@ exports.rxTags = function (options) { | ||
} else { | ||
component = rxTags.main; | ||
component = rxTags.initialize(); | ||
} | ||
@@ -1367,21 +1274,18 @@ | ||
var rxToggleSwitch = require('./index').rxToggleSwitch; | ||
/** | ||
rxToggleSwitch exercises. | ||
@exports encore.exercise.rxToggleSwitch | ||
@param {Object} [options] - Test options. Used to build valid tests. | ||
@param {rxToggleSwitch} [options.instance=] - Component to exercise. | ||
@param {string} [options.cssSelector=] - DEPRECATED: Fallback selector string to initialize widget with. | ||
@param {boolean} [options.disabled=false] - Determines if the switch can be toggled | ||
@param {boolean} [options.enabledAtStart=null] Beginning state of toggle switch. The value will be detected | ||
automatically if not given. | ||
@param {boolean} [options.enabledAtEnd=null] End state of toggle switch. The value will be detected automatically | ||
if not given. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxToggleSwitch({ | ||
instance: myPage.emailPreference // select one of many widgets from your page objects | ||
})); | ||
``` | ||
* @description rxToggleSwitch exercises. | ||
* @see rxToggleSwitch | ||
* @exports exercise/rxToggleSwitch | ||
* @param {Object} options - Test options. Used to build valid tests. | ||
* @param {rxToggleSwitch} options.instance - Component to exercise. | ||
* @param {Boolean} [options.disabled=false] - Determines if the switch can be toggled. | ||
* @param {Boolean} [options.toggledAtStart=null] - | ||
* Beginning state of toggle switch. The value will be detected automatically if not given. | ||
* @param {Boolean} [options.toggledAtEnd=null] | ||
* End state of toggle switch. The value will be detected automatically if not given. | ||
* @example | ||
* describe('default exercises', encore.exercise.rxToggleSwitch({ | ||
* instance: myPage.emailPreference // select one of many widgets from your page objects | ||
* })); | ||
*/ | ||
@@ -1394,5 +1298,5 @@ exports.rxToggleSwitch = function (options) { | ||
options = _.defaults(options, { | ||
disabled: false, | ||
enabledAtStart: null, // begins 'OFF' | ||
enabledAtEnd: null // ends 'ON' | ||
enabled: true, | ||
toggledAtStart: null, // begins 'OFF' | ||
toggledAtEnd: null // ends 'ON' | ||
}); | ||
@@ -1402,6 +1306,6 @@ | ||
var component; | ||
var enabledAtStart; | ||
var enabledAtEnd; | ||
var toggledAtStart; | ||
var toggledAtEnd; | ||
var getText = function (isEnabled) { | ||
var positionAsText = function (isEnabled) { | ||
return isEnabled ? 'ON' : 'OFF'; | ||
@@ -1411,4 +1315,4 @@ }; | ||
var toggle = function () { | ||
return component.isEnabled().then(function (enabled) { | ||
enabled ? component.disable() : component.enable(); | ||
return component.isToggled().then(function (toggled) { | ||
toggled ? component.toggleOff() : component.toggleOn(); | ||
}); | ||
@@ -1418,19 +1322,9 @@ }; | ||
before(function () { | ||
if (options.instance !== undefined) { | ||
component = options.instance; | ||
} else { | ||
component = rxToggleSwitch.main; | ||
} | ||
if (options.cssSelector !== undefined) { | ||
console.warn('Deprecated exercise option `cssSelector` will be removed in favor of `instance`'); | ||
component = rxToggleSwitch.initialize($(options.cssSelector)); | ||
} | ||
component.isEnabled().then(function (isEnabled) { | ||
component = options.instance; | ||
component.isToggled().then(function (isToggled) { | ||
// use option if available, otherwise use detected state | ||
enabledAtStart = _.isNull(options.enabledAtStart) ? isEnabled : options.enabledAtStart; | ||
toggledAtStart = _.isNull(options.toggledAtStart) ? isToggled : options.toggledAtStart; | ||
// use option if available, otherwise use inverse of enabledAtStart | ||
enabledAtEnd = _.isNull(options.enabledAtEnd) ? !enabledAtStart : options.enabledAtEnd; | ||
// use option if available, otherwise use inverse of toggledAtStart | ||
toggledAtEnd = _.isNull(options.toggledAtEnd) ? !toggledAtStart : options.toggledAtEnd; | ||
}); | ||
@@ -1443,23 +1337,27 @@ }); | ||
if (options.disabled) { | ||
it('does not change state when clicked', function () { | ||
it('should' + (options.enabled ? '' : ' not') + ' be enabled', function () { | ||
expect(component.isEnabled()).to.eventually.equal(options.enabled); | ||
}); | ||
if (!options.enabled) { | ||
it('should not change state when clicked', function () { | ||
toggle(); | ||
expect(component.isEnabled()).to.eventually.equal(enabledAtStart); | ||
expect(component.text).to.eventually.equal(getText(enabledAtStart)); | ||
expect(component.isToggled()).to.eventually.equal(toggledAtStart); | ||
expect(component.text).to.eventually.equal(positionAsText(toggledAtStart)); | ||
}); | ||
} else { | ||
it('begins in the ' + getText(enabledAtStart) + ' state', function () { | ||
expect(component.text).to.eventually.equal(getText(enabledAtStart)); | ||
it('should begin in the ' + positionAsText(toggledAtStart) + ' state', function () { | ||
expect(component.text).to.eventually.equal(positionAsText(toggledAtStart)); | ||
}); | ||
it('changes to ' + getText(enabledAtEnd) + ' when clicked', function () { | ||
it('should change to ' + positionAsText(toggledAtEnd) + ' when clicked', function () { | ||
toggle(); | ||
expect(component.isEnabled()).to.eventually.equal(enabledAtEnd); | ||
expect(component.text).to.eventually.equal(getText(enabledAtEnd)); | ||
expect(component.isToggled()).to.eventually.equal(toggledAtEnd); | ||
expect(component.text).to.eventually.equal(positionAsText(toggledAtEnd)); | ||
}); | ||
it('returns to the ' + getText(enabledAtStart) + ' when clicked again', function () { | ||
it('should return to the ' + positionAsText(toggledAtStart) + ' when clicked again', function () { | ||
toggle(); | ||
expect(component.isEnabled()).to.eventually.equal(enabledAtStart); | ||
expect(component.text).to.eventually.equal(getText(enabledAtStart)); | ||
expect(component.isToggled()).to.eventually.equal(toggledAtStart); | ||
expect(component.text).to.eventually.equal(positionAsText(toggledAtStart)); | ||
}); | ||
@@ -1466,0 +1364,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Midway test page objects for all of the Encore UI components", | ||
"version": "2.0.0-1", | ||
"version": "2.0.0-2", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "license": "Apache License, Version 2.0", |
Sorry, the diff of this file is too big to display
319539
6
8415