New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rx-page-objects

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rx-page-objects - npm Package Compare versions

Comparing version 1.40.0 to 1.41.0-0

rx-page-objects-1.41.0-0.tgz

188

exercise.js
/*jshint node:true*/
var _ = require('lodash');var rxBulkSelect = require('./index').rxBulkSelect;
var _ = require('lodash');
var rxCheckbox = require('./index').rxCheckbox;
/**
* @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.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;
/**

@@ -310,94 +402,2 @@ rxBulkSelect exercises.

var rxCheckbox = require('./index').rxCheckbox;
/**
* @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.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 rxCollapse = require('./index').rxCollapse;

@@ -1353,3 +1353,3 @@

describe('default exercises', encore.exercise.rxToggleSwitch({
cssSelector: myPage.emailPreference // select one of many widgets from your page objects
instance: myPage.emailPreference // select one of many widgets from your page objects
}));

@@ -1356,0 +1356,0 @@ ```

@@ -5,3 +5,3 @@ {

"description": "Midway test page objects for all of the Encore UI components",
"version": "1.40.0",
"version": "1.41.0-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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc