@helpscout/cyan
Version:
Cypress-like Testing for React + JSDOM
67 lines (52 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _is = require("../utils/is.utils");
function getAttribute(attr) {
var node = this.__getNode('getAttribute', attr);
return node.getAttribute(attr);
}
function getComputedStyle(prop) {
var node = this.__getNode('getComputedStyle');
var styles = window.getComputedStyle(node);
return prop ? styles[prop] : styles;
}
function getId() {
return this.getAttribute('id');
}
function getTagName() {
var node = this.__getNode('getTagName');
return node.tagName.toLowerCase();
}
function getValue(nextValue) {
if ((0, _is.isDefined)(nextValue)) {
this.type(nextValue);
}
var node = this.__getNode('getValue', nextValue);
return node.value;
}
function getText() {
var node = this.__getNode('getText');
return node.textContent || '';
}
var commands = {
getAttribute: getAttribute,
getAttr: getAttribute,
getComputedStyle: getComputedStyle,
getId: getId,
getTagName: getTagName,
getValue: getValue,
getText: getText,
// Aliases
attr: getAttribute,
id: getId,
style: getComputedStyle,
tagName: getTagName,
tag: getTagName,
text: getText,
value: getValue
};
var _default = commands;
exports.default = _default;