rx-page-objects
Advanced tools
Comparing version 1.19.0 to 1.20.0
/*jshint node:true*/ | ||
var _ = require('lodash'); | ||
var rxBulkSelect = require('./index').rxBulkSelect; | ||
/** | ||
rxBulkSelect exercises. | ||
@exports encore.exercise.rxBulkSelect | ||
@param {Object} [options=] - Test options. Used to build valid tests. | ||
@param {string} [options.cssSelector=] - Fallback selector string to initialize widget with. | ||
@example | ||
```js | ||
describe('default exercises', encore.exercise.rxBulkSelect({ | ||
cssSelector: 'table.servers[rx-bulk-select]' // select one of many widgets on page | ||
})); | ||
``` | ||
*/ | ||
exports.rxBulkSelect = function (options) { | ||
if (options === undefined) { | ||
options = {}; | ||
} | ||
options = _.defaults(options, {}); | ||
return function () { | ||
var component; | ||
before(function () { | ||
if (options.cssSelector === undefined) { | ||
component = rxBulkSelect.main; | ||
} else { | ||
component = rxBulkSelect.initialize($(options.cssSelector)); | ||
} | ||
}); | ||
it('has no selected rows, a hidden message, and a disabled batch actions link', function () { | ||
expect(component.anySelected()).to.eventually.be.false; | ||
expect(component.bulkMessage).to.eventually.be.null; | ||
expect(component.isEnabled()).to.eventually.be.false; | ||
}); | ||
it('shows the message and enables the batch actions link when a row is selected', function () { | ||
component.row(0).select(); | ||
expect(component.bulkMessage).to.eventually.match(/^1 \w+ is selected.$/); | ||
expect(component.isEnabled()).to.eventually.be.true; | ||
}); | ||
it('updates the message as rows are selected', function () { | ||
component.selectByIndex([1, 2]); | ||
expect(component.bulkMessage).to.eventually.match(/^3 \w+s are selected.$/); | ||
}); | ||
it('hides the message and disables the batch actions link when all rows are deselected', function () { | ||
component.deselectByIndex([0, 1, 2]); | ||
expect(component.bulkMessage).to.eventually.be.null; | ||
expect(component.isEnabled()).to.eventually.be.false; | ||
}); | ||
it('selects all rows via the header checkbox', function () { | ||
component.selectAllCheckbox.select(); | ||
expect(component.allSelected()).to.eventually.be.true; | ||
expect(component.bulkMessage).to.eventually.match(/^10 \w+s are selected.$/); | ||
expect(component.isEnabled()).to.eventually.be.true; | ||
}); | ||
it('clears the selection via the header checkbox', function () { | ||
component.selectAllCheckbox.deselect(); | ||
expect(component.anySelected()).to.eventually.be.false; | ||
expect(component.bulkMessage).to.eventually.be.null; | ||
expect(component.isEnabled()).to.eventually.be.false; | ||
}); | ||
it('selects all rows via the button in the message', function () { | ||
component.row(0).select(); | ||
component.selectAll(); | ||
expect(component.allSelected()).to.eventually.be.true; | ||
expect(component.selectAllCheckbox.isSelected()).to.eventually.be.true; | ||
expect(component.bulkMessage).to.eventually.match(/^10 \w+s are selected.$/); | ||
expect(component.isEnabled()).to.eventually.be.true; | ||
}); | ||
it('clears the selection via the button in the message', function () { | ||
component.clearSelections(); | ||
expect(component.anySelected()).to.eventually.be.false; | ||
expect(component.selectAllCheckbox.isSelected()).to.eventually.be.false; | ||
expect(component.bulkMessage).to.eventually.be.null; | ||
expect(component.isEnabled()).to.eventually.be.false; | ||
}); | ||
}; | ||
}; | ||
var rxCharacterCount = require('./index').rxCharacterCount; | ||
@@ -4,0 +93,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Midway test page objects for all of the Encore UI components", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "license": "Apache License, Version 2.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
310619
5039