Socket
Socket
Sign inDemoInstall

@open-wc/testing

Package Overview
Dependencies
Maintainers
3
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-wc/testing - npm Package Compare versions

Comparing version 3.1.8 to 3.2.0

1

index-no-side-effects.js

@@ -16,2 +16,3 @@ // eslint does not understand export maps yet

oneEvent,
oneDefaultPreventedEvent,
isIE,

@@ -18,0 +19,0 @@ defineCE,

2

index.d.ts

@@ -7,3 +7,3 @@ /// <reference path="./register-chai-plugins.d.ts" />

export { triggerFocusFor } from '@open-wc/testing-helpers';
export { oneEvent } from '@open-wc/testing-helpers';
export { oneEvent, oneDefaultPreventedEvent } from '@open-wc/testing-helpers';
export { isIE } from '@open-wc/testing-helpers';

@@ -10,0 +10,0 @@ export { defineCE } from '@open-wc/testing-helpers';

@@ -14,2 +14,3 @@ // remove esline-disable when https://github.com/esm-bundle/chai/pull/61 is merged

oneEvent,
oneDefaultPreventedEvent,
isIE,

@@ -16,0 +17,0 @@ defineCE,

{
"name": "@open-wc/testing",
"version": "3.1.8",
"version": "3.2.0",
"publishConfig": {

@@ -47,9 +47,9 @@ "access": "public"

"@open-wc/chai-dom-equals": "^0.12.36",
"@open-wc/semantic-dom-diff": "^0.19.7",
"@open-wc/testing-helpers": "^2.2.1",
"@open-wc/semantic-dom-diff": "^0.20.0",
"@open-wc/testing-helpers": "^2.3.0",
"@types/chai": "^4.2.11",
"@types/chai-dom": "^1.11.0",
"@types/sinon-chai": "^3.2.3",
"chai-a11y-axe": "^1.3.2"
"chai-a11y-axe": "^1.5.0"
}
}

@@ -1,438 +0,441 @@

function createCommonjsModule(fn) {
var module = { exports: {} };
return fn(module, module.exports), module.exports;
}
function commonjsRequire (path) {
function commonjsRequire(path) {
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var chaiDom = createCommonjsModule(function (module, exports) {
(function(chaiDom) {
if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
module.exports = chaiDom;
} else {
chai.use(chaiDom);
}
}(function(chai, utils) {
var flag = utils.flag,
var chaiDomExports = {};
var chaiDom$1 = {
get exports(){ return chaiDomExports; },
set exports(v){ chaiDomExports = v; },
};
elToString = function(el) {
var desc;
if (isNodeList(el)) {
if (el.length === 0) {
return 'empty NodeList'
}
(function (module, exports) {
(function(chaiDom) {
if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
module.exports = chaiDom;
} else {
chai.use(chaiDom);
}
}(function(chai, utils) {
var flag = utils.flag,
desc = Array.prototype.slice.call(el, 0, 5).map(elToString).join(', ');
return el.length > 5 ? desc + '... (+' + (el.length - 5) + ' more)' : desc
}
if (!isHTMLElement(el)) {
return String(el)
}
elToString = function(el) {
var desc;
if (isNodeList(el)) {
if (el.length === 0) {
return 'empty NodeList'
}
desc = el.tagName.toLowerCase();
if (el.id) {
desc += '#' + el.id;
}
if (el.className) {
desc += '.' + String(el.className).replace(/\s+/g, '.');
}
Array.prototype.forEach.call(el.attributes, function(attr) {
if (attr.name !== 'class' && attr.name !== 'id') {
desc += '[' + attr.name + (attr.value ? '="' + attr.value + '"]' : ']');
}
});
return desc
},
desc = Array.prototype.slice.call(el, 0, 5).map(elToString).join(', ');
return el.length > 5 ? desc + '... (+' + (el.length - 5) + ' more)' : desc
}
if (!isHTMLElement(el)) {
return String(el)
}
attrAssert = function(name, val) {
var el = flag(this, 'object'), actual = el.getAttribute(name);
desc = el.tagName.toLowerCase();
if (el.id) {
desc += '#' + el.id;
}
if (el.className) {
desc += '.' + String(el.className).replace(/\s+/g, '.');
}
Array.prototype.forEach.call(el.attributes, function(attr) {
if (attr.name !== 'class' && attr.name !== 'id') {
desc += '[' + attr.name + (attr.value ? '="' + attr.value + '"]' : ']');
}
});
return desc
},
if (!flag(this, 'negate') || undefined === val) {
this.assert(
!!el.attributes[name]
, 'expected ' + elToString(el) + ' to have an attribute #{exp}'
, 'expected ' + elToString(el) + ' not to have an attribute #{exp}'
, name
);
}
attrAssert = function(name, val) {
var el = flag(this, 'object'), actual = el.getAttribute(name);
if (undefined !== val) {
this.assert(
val === actual
, 'expected ' + elToString(el) + ' to have an attribute ' + utils.inspect(name) + ' with the value #{exp}, but the value was #{act}'
, 'expected ' + elToString(el) + ' not to have an attribute ' + utils.inspect(name) + ' with the value #{act}'
, val
, actual
);
}
if (!flag(this, 'negate') || undefined === val) {
this.assert(
!!el.attributes[name]
, 'expected ' + elToString(el) + ' to have an attribute #{exp}'
, 'expected ' + elToString(el) + ' not to have an attribute #{exp}'
, name
);
}
flag(this, 'object', actual);
},
if (undefined !== val) {
this.assert(
val === actual
, 'expected ' + elToString(el) + ' to have an attribute ' + utils.inspect(name) + ' with the value #{exp}, but the value was #{act}'
, 'expected ' + elToString(el) + ' not to have an attribute ' + utils.inspect(name) + ' with the value #{act}'
, val
, actual
);
}
isHTMLElement = function(el) {
return el.nodeType === 1 // window.Node.ELEMENT_NODE
},
flag(this, 'object', actual);
},
isNodeList = function(obj) {
return Object.prototype.toString.call(obj) === '[object NodeList]'
};
isHTMLElement = function(el) {
return el.nodeType === 1 // window.Node.ELEMENT_NODE
},
utils.elToString = elToString;
chai.Assertion.addMethod('attr', attrAssert);
chai.Assertion.addMethod('attribute', attrAssert);
isNodeList = function(obj) {
return Object.prototype.toString.call(obj) === '[object NodeList]'
};
chai.Assertion.addMethod('class', function(className) {
var el = flag(this, 'object');
utils.elToString = elToString;
chai.Assertion.addMethod('attr', attrAssert);
chai.Assertion.addMethod('attribute', attrAssert);
if (className instanceof RegExp) {
return this.assert(
Array.from(el.classList).some(function(cls) { return className.test(cls) })
, 'expected ' + elToString(el) + ' to have class matching #{exp}'
, 'expected ' + elToString(el) + ' not to have class matching #{exp}'
, className
)
}
this.assert(
el.classList.contains(className)
, 'expected ' + elToString(el) + ' to have class #{exp}'
, 'expected ' + elToString(el) + ' not to have class #{exp}'
, className
);
});
chai.Assertion.addMethod('class', function(className) {
var el = flag(this, 'object');
chai.Assertion.addMethod('id', function(id) {
var el = flag(this, 'object');
this.assert(
el.id == id
, 'expected ' + elToString(el) + ' to have id #{exp}'
, 'expected ' + elToString(el) + ' not to have id #{exp}'
, id
);
});
if (className instanceof RegExp) {
return this.assert(
Array.from(el.classList).some(function(cls) { return className.test(cls) })
, 'expected ' + elToString(el) + ' to have class matching #{exp}'
, 'expected ' + elToString(el) + ' not to have class matching #{exp}'
, className
)
}
this.assert(
el.classList.contains(className)
, 'expected ' + elToString(el) + ' to have class #{exp}'
, 'expected ' + elToString(el) + ' not to have class #{exp}'
, className
);
});
chai.Assertion.addMethod('html', function(html) {
var el = flag(this, 'object'), actual = flag(this, 'object').innerHTML;
chai.Assertion.addMethod('id', function(id) {
var el = flag(this, 'object');
this.assert(
el.id == id
, 'expected ' + elToString(el) + ' to have id #{exp}'
, 'expected ' + elToString(el) + ' not to have id #{exp}'
, id
);
});
if (flag(this, 'contains')) {
this.assert(
actual.indexOf(html) >= 0
, 'expected #{act} to contain HTML #{exp}'
, 'expected #{act} not to contain HTML #{exp}'
, html
, actual
);
} else {
this.assert(
actual === html
, 'expected ' + elToString(el) + ' to have HTML #{exp}, but the HTML was #{act}'
, 'expected ' + elToString(el) + ' not to have HTML #{exp}'
, html
, actual
);
}
});
chai.Assertion.addMethod('html', function(html) {
var el = flag(this, 'object'), actual = flag(this, 'object').innerHTML;
chai.Assertion.addChainableMethod('trimmed', null, function() {
flag(this, 'trim-text', true);
});
if (flag(this, 'contains')) {
this.assert(
actual.indexOf(html) >= 0
, 'expected #{act} to contain HTML #{exp}'
, 'expected #{act} not to contain HTML #{exp}'
, html
, actual
);
} else {
this.assert(
actual === html
, 'expected ' + elToString(el) + ' to have HTML #{exp}, but the HTML was #{act}'
, 'expected ' + elToString(el) + ' not to have HTML #{exp}'
, html
, actual
);
}
});
chai.Assertion.addProperty('rendered', function() {
flag(this, 'rendered-text', true);
});
chai.Assertion.addChainableMethod('trimmed', null, function() {
flag(this, 'trim-text', true);
});
chai.Assertion.addMethod('text', function(text) {
var obj = flag(this, 'object'), contains = flag(this, 'contains'),
trim = flag(this, 'trim-text'), actual, result;
var property = flag(this, 'rendered-text') ? 'innerText' : 'textContent';
chai.Assertion.addProperty('rendered', function() {
flag(this, 'rendered-text', true);
});
if (isNodeList(obj)) {
actual = Array.prototype.map.call(obj, function(el) { return trim ? el[property].trim() : el[property] });
if (Array.isArray(text)) {
result = contains ?
text[flag(this, 'negate') ? 'some' : 'every'](function(t) {
return Array.prototype.some.call(obj, function(el) {
return (trim ? el[property].trim() : el[property]) === t
})
})
:
utils.eql(actual, text);
chai.Assertion.addMethod('text', function(text) {
var obj = flag(this, 'object'), contains = flag(this, 'contains'),
trim = flag(this, 'trim-text'), actual, result;
var property = flag(this, 'rendered-text') ? 'innerText' : 'textContent';
actual = actual.join();
text = text.join();
} else {
actual = actual.join('');
result = contains ? actual.indexOf(text) >= 0 : actual === text;
}
} else {
actual = trim ? obj[property].trim() : obj[property];
result = contains ? actual.indexOf(text) >= 0 : actual === text;
}
if (isNodeList(obj)) {
actual = Array.prototype.map.call(obj, function(el) { return trim ? el[property].trim() : el[property] });
if (Array.isArray(text)) {
result = contains ?
text[flag(this, 'negate') ? 'some' : 'every'](function(t) {
return Array.prototype.some.call(obj, function(el) {
return (trim ? el[property].trim() : el[property]) === t
})
})
:
utils.eql(actual, text);
var objDesc = elToString(obj);
var textMsg = '';
actual = actual.join();
text = text.join();
} else {
actual = actual.join('');
result = contains ? actual.indexOf(text) >= 0 : actual === text;
}
} else {
actual = trim ? obj[property].trim() : obj[property];
result = contains ? actual.indexOf(text) >= 0 : actual === text;
}
if (trim) {
textMsg += 'trimmed ';
}
if (flag(this, 'rendered-text')) {
textMsg += 'rendered ';
}
textMsg += 'text';
var objDesc = elToString(obj);
var textMsg = '';
if (contains) {
this.assert(
result
, 'expected ' + objDesc + ' to contain #{exp}, but the ' + textMsg + ' was #{act}'
, 'expected ' + objDesc + ' not to contain #{exp}, but the ' + textMsg + ' was #{act}'
, text
, actual
);
} else {
this.assert(
result
, 'expected ' + objDesc + ' to have ' + textMsg + ' #{exp}, but the ' + textMsg + ' was #{act}'
, 'expected ' + objDesc + ' not to have ' + textMsg + ' #{exp}'
, text
, actual
);
}
});
if (trim) {
textMsg += 'trimmed ';
}
if (flag(this, 'rendered-text')) {
textMsg += 'rendered ';
}
textMsg += 'text';
chai.Assertion.addMethod('value', function(value) {
var el = flag(this, 'object'), actual = flag(this, 'object').value;
this.assert(
flag(this, 'object').value === value
, 'expected ' + elToString(el) + ' to have value #{exp}, but the value was #{act}'
, 'expected ' + elToString(el) + ' not to have value #{exp}'
, value
, actual
);
});
if (contains) {
this.assert(
result
, 'expected ' + objDesc + ' to contain #{exp}, but the ' + textMsg + ' was #{act}'
, 'expected ' + objDesc + ' not to contain #{exp}, but the ' + textMsg + ' was #{act}'
, text
, actual
);
} else {
this.assert(
result
, 'expected ' + objDesc + ' to have ' + textMsg + ' #{exp}, but the ' + textMsg + ' was #{act}'
, 'expected ' + objDesc + ' not to have ' + textMsg + ' #{exp}'
, text
, actual
);
}
});
chai.Assertion.overwriteProperty('exist', function(_super) {
return function() {
var obj = flag(this, 'object');
if (isNodeList(obj)) {
this.assert(
obj.length > 0
, 'expected an empty NodeList to have nodes'
, 'expected ' + elToString(obj) + ' to not exist');
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.addMethod('value', function(value) {
var el = flag(this, 'object'), actual = flag(this, 'object').value;
this.assert(
flag(this, 'object').value === value
, 'expected ' + elToString(el) + ' to have value #{exp}, but the value was #{act}'
, 'expected ' + elToString(el) + ' not to have value #{exp}'
, value
, actual
);
});
chai.Assertion.overwriteProperty('empty', function(_super) {
return function() {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
this.assert(
obj.children.length === 0
, 'expected ' + elToString(obj) + ' to be empty'
, 'expected ' + elToString(obj) + ' to not be empty');
} else if (isNodeList(obj)) {
this.assert(
obj.length === 0
, 'expected ' + elToString(obj) + ' to be empty'
, 'expected ' + elToString(obj) + ' to not be empty');
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.overwriteProperty('exist', function(_super) {
return function() {
var obj = flag(this, 'object');
if (isNodeList(obj)) {
this.assert(
obj.length > 0
, 'expected an empty NodeList to have nodes'
, 'expected ' + elToString(obj) + ' to not exist');
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.overwriteChainableMethod('length',
function(_super) {
return function(length) {
var obj = flag(this, 'object');
if (isNodeList(obj) || isHTMLElement(obj)) {
var actualLength = obj.children ? obj.children.length : obj.length;
this.assert(
actualLength === length
, 'expected ' + elToString(obj) + ' to have #{exp} children but it had #{act} children'
, 'expected ' + elToString(obj) + ' to not have #{exp} children'
, length
, actualLength
);
} else {
_super.apply(this, arguments);
}
}
},
function(_super) {
return function() {
_super.call(this);
}
}
);
chai.Assertion.overwriteProperty('empty', function(_super) {
return function() {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
this.assert(
obj.children.length === 0
, 'expected ' + elToString(obj) + ' to be empty'
, 'expected ' + elToString(obj) + ' to not be empty');
} else if (isNodeList(obj)) {
this.assert(
obj.length === 0
, 'expected ' + elToString(obj) + ' to be empty'
, 'expected ' + elToString(obj) + ' to not be empty');
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.overwriteChainableMethod('length',
function(_super) {
return function(length) {
var obj = flag(this, 'object');
if (isNodeList(obj) || isHTMLElement(obj)) {
var actualLength = obj.children ? obj.children.length : obj.length;
this.assert(
actualLength === length
, 'expected ' + elToString(obj) + ' to have #{exp} children but it had #{act} children'
, 'expected ' + elToString(obj) + ' to not have #{exp} children'
, length
, actualLength
);
} else {
_super.apply(this, arguments);
}
}
},
function(_super) {
return function() {
_super.call(this);
}
}
);
chai.Assertion.overwriteMethod('match', function(_super) {
return function(selector) {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
this.assert(
obj.matches(selector)
, 'expected ' + elToString(obj) + ' to match #{exp}'
, 'expected ' + elToString(obj) + ' to not match #{exp}'
, selector
);
} else if (isNodeList(obj)) {
this.assert(
(!!obj.length && Array.prototype.every.call(obj, function(el) { return el.matches(selector) }))
, 'expected ' + elToString(obj) + ' to match #{exp}'
, 'expected ' + elToString(obj) + ' to not match #{exp}'
, selector
);
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.overwriteChainableMethod('contain',
function(_super) {
return function(subitem) {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
if (typeof subitem === 'string') {
this.assert(
!!obj.querySelector(subitem)
, 'expected ' + elToString(obj) + ' to contain #{exp}'
, 'expected ' + elToString(obj) + ' to not contain #{exp}'
, subitem);
} else {
this.assert(
obj.contains(subitem)
, 'expected ' + elToString(obj) + ' to contain ' + elToString(subitem)
, 'expected ' + elToString(obj) + ' to not contain ' + elToString(subitem));
}
} else {
_super.apply(this, arguments);
}
}
},
function(_super) {
return function() {
_super.call(this);
}
}
);
chai.Assertion.overwriteMethod('match', function(_super) {
return function(selector) {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
this.assert(
obj.matches(selector)
, 'expected ' + elToString(obj) + ' to match #{exp}'
, 'expected ' + elToString(obj) + ' to not match #{exp}'
, selector
);
} else if (isNodeList(obj)) {
this.assert(
(!!obj.length && Array.prototype.every.call(obj, function(el) { return el.matches(selector) }))
, 'expected ' + elToString(obj) + ' to match #{exp}'
, 'expected ' + elToString(obj) + ' to not match #{exp}'
, selector
);
} else {
_super.apply(this, arguments);
}
}
});
chai.Assertion.addMethod('descendant', function(subitem) {
var obj = flag(this, 'object'), actual = subitem;
chai.Assertion.overwriteChainableMethod('contain',
function(_super) {
return function(subitem) {
var obj = flag(this, 'object');
if (isHTMLElement(obj)) {
if (typeof subitem === 'string') {
this.assert(
!!obj.querySelector(subitem)
, 'expected ' + elToString(obj) + ' to contain #{exp}'
, 'expected ' + elToString(obj) + ' to not contain #{exp}'
, subitem);
} else {
this.assert(
obj.contains(subitem)
, 'expected ' + elToString(obj) + ' to contain ' + elToString(subitem)
, 'expected ' + elToString(obj) + ' to not contain ' + elToString(subitem));
}
} else {
_super.apply(this, arguments);
}
}
},
function(_super) {
return function() {
_super.call(this);
}
}
);
if (typeof subitem === 'string') {
actual = obj.querySelector(subitem);
this.assert(
!!actual
, 'expected ' + elToString(obj) + ' to have descendant #{exp}'
, 'expected ' + elToString(obj) + ' to not have descendant #{exp}'
, subitem);
} else {
this.assert(
obj.contains(subitem)
, 'expected ' + elToString(obj) + ' to contain ' + elToString(subitem)
, 'expected ' + elToString(obj) + ' to not contain ' + elToString(subitem));
}
chai.Assertion.addMethod('descendant', function(subitem) {
var obj = flag(this, 'object'), actual = subitem;
flag(this, 'object', actual);
});
if (typeof subitem === 'string') {
actual = obj.querySelector(subitem);
this.assert(
!!actual
, 'expected ' + elToString(obj) + ' to have descendant #{exp}'
, 'expected ' + elToString(obj) + ' to not have descendant #{exp}'
, subitem);
} else {
this.assert(
obj.contains(subitem)
, 'expected ' + elToString(obj) + ' to contain ' + elToString(subitem)
, 'expected ' + elToString(obj) + ' to not contain ' + elToString(subitem));
}
chai.Assertion.addMethod('descendants', function(selector) {
var obj = flag(this, 'object'),
actual = obj.querySelectorAll(selector);
this.assert(
!!actual.length
, 'expected ' + elToString(obj) + ' to have descendants #{exp}'
, 'expected ' + elToString(obj) + ' to not have descendants #{exp}'
, selector);
flag(this, 'object', actual);
});
flag(this, 'object', actual);
});
chai.Assertion.addProperty('displayed', function() {
var el = flag(this, 'object'),
actual = document.body.contains(el) ? window.getComputedStyle(el).display : el.style.display;
chai.Assertion.addMethod('descendants', function(selector) {
var obj = flag(this, 'object'),
actual = obj.querySelectorAll(selector);
this.assert(
!!actual.length
, 'expected ' + elToString(obj) + ' to have descendants #{exp}'
, 'expected ' + elToString(obj) + ' to not have descendants #{exp}'
, selector);
flag(this, 'object', actual);
});
this.assert(
actual !== 'none'
, 'expected ' + elToString(el) + ' to be displayed, but it was not'
, 'expected ' + elToString(el) + ' to not be displayed, but it was as ' + actual
, actual
);
});
chai.Assertion.addProperty('displayed', function() {
var el = flag(this, 'object'),
actual = document.body.contains(el) ? window.getComputedStyle(el).display : el.style.display;
chai.Assertion.addProperty('visible', function() {
var el = flag(this, 'object'),
actual = document.body.contains(el) ? window.getComputedStyle(el).visibility : el.style.visibility;
this.assert(
actual !== 'none'
, 'expected ' + elToString(el) + ' to be displayed, but it was not'
, 'expected ' + elToString(el) + ' to not be displayed, but it was as ' + actual
, actual
);
});
this.assert(
actual !== 'hidden' && actual !== 'collapse'
, 'expected ' + elToString(el) + ' to be visible, but it was ' + (actual === 'hidden' ? 'hidden' : 'collapsed')
, 'expected ' + elToString(el) + ' to not be visible, but it was'
, actual
);
});
chai.Assertion.addProperty('visible', function() {
var el = flag(this, 'object'),
actual = document.body.contains(el) ? window.getComputedStyle(el).visibility : el.style.visibility;
chai.Assertion.addMethod('tagName', function(tagName) {
var el = flag(this, 'object'),
actual = el.tagName;
this.assert(
actual !== 'hidden' && actual !== 'collapse'
, 'expected ' + elToString(el) + ' to be visible, but it was ' + (actual === 'hidden' ? 'hidden' : 'collapsed')
, 'expected ' + elToString(el) + ' to not be visible, but it was'
, actual
);
});
this.assert(
actual.toUpperCase() === tagName.toUpperCase()
, 'expected ' + elToString(el) + ' to have tagName ' + tagName + ', but it was ' + actual
, 'expected ' + elToString(el) + ' to not have tagName ' + tagName + ', but it was ' + actual
, actual
);
});
chai.Assertion.addMethod('tagName', function(tagName) {
var el = flag(this, 'object'),
actual = el.tagName;
chai.Assertion.addMethod('style', function (styleProp, styleValue) {
var el = flag(this, 'object'),
style = window.getComputedStyle(el),
actual = style.getPropertyValue(styleProp).trim();
this.assert(
actual.toUpperCase() === tagName.toUpperCase()
, 'expected ' + elToString(el) + ' to have tagName ' + tagName + ', but it was ' + actual
, 'expected ' + elToString(el) + ' to not have tagName ' + tagName + ', but it was ' + actual
, actual
);
});
this.assert(
actual === styleValue
, 'expected ' + elToString(el) + ' to have style property ' + styleProp + ' equal to ' + styleValue + ', but it was equal to ' + actual
, 'expected ' + elToString(el) + ' to not have style property ' + styleProp + ' equal to ' + styleValue + ', but it was equal to ' + actual
, actual
);
});
chai.Assertion.addMethod('style', function (styleProp, styleValue) {
var el = flag(this, 'object'),
style = window.getComputedStyle(el),
actual = style.getPropertyValue(styleProp).trim();
chai.Assertion.overwriteProperty('focus', function() {
return function () {
var el = flag(this, 'object'), actual = el.ownerDocument.activeElement;
this.assert(
actual === styleValue
, 'expected ' + elToString(el) + ' to have style property ' + styleProp + ' equal to ' + styleValue + ', but it was equal to ' + actual
, 'expected ' + elToString(el) + ' to not have style property ' + styleProp + ' equal to ' + styleValue + ', but it was equal to ' + actual
, actual
);
});
this.assert(
el === el.ownerDocument.activeElement
, 'expected #{this} to have focus'
, 'expected #{this} not to have focus'
, el
, actual
);
chai.Assertion.overwriteProperty('focus', function() {
return function () {
var el = flag(this, 'object'), actual = el.ownerDocument.activeElement;
}
});
this.assert(
el === el.ownerDocument.activeElement
, 'expected #{this} to have focus'
, 'expected #{this} not to have focus'
, el
, actual
);
chai.Assertion.overwriteProperty('checked', function() {
return function () {
var el = flag(this, 'object');
}
});
if(!(el instanceof HTMLInputElement && (el.type === 'checkbox' || el.type === 'radio'))) {
throw new TypeError(elToString(el) + ' is not a checkbox or radio input');
}
chai.Assertion.overwriteProperty('checked', function() {
return function () {
var el = flag(this, 'object');
this.assert(
el.checked
, 'expected ' + elToString(el) + ' to be checked'
, 'expected ' + elToString(el) + ' to not be checked');
}
});
}));
});
if(!(el instanceof HTMLInputElement && (el.type === 'checkbox' || el.type === 'radio'))) {
throw new TypeError(elToString(el) + ' is not a checkbox or radio input');
}
this.assert(
el.checked
, 'expected ' + elToString(el) + ' to be checked'
, 'expected ' + elToString(el) + ' to not be checked');
}
});
}));
} (chaiDom$1));
var chaiDom = chaiDomExports;
export { chaiDom as default };

@@ -1,156 +0,159 @@

function createCommonjsModule(fn) {
var module = { exports: {} };
return fn(module, module.exports), module.exports;
}
function commonjsRequire (path) {
function commonjsRequire(path) {
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var sinonChai = createCommonjsModule(function (module, exports) {
/* eslint-disable no-invalid-this */
var sinonChaiExports = {};
var sinonChai$1 = {
get exports(){ return sinonChaiExports; },
set exports(v){ sinonChaiExports = v; },
};
(function (sinonChai) {
// Module systems magic dance.
(function (module, exports) {
/* eslint-disable no-invalid-this */
/* istanbul ignore else */
if (typeof commonjsRequire === "function" && 'object' === "object" && 'object' === "object") {
// NodeJS
module.exports = sinonChai;
} else {
// Other environment (usually <script> tag): plug in to global chai instance directly.
/* global chai: false */
chai.use(sinonChai);
}
}(function (chai, utils) {
var slice = Array.prototype.slice;
(function (sinonChai) {
// Module systems magic dance.
function isSpy(putativeSpy) {
return typeof putativeSpy === "function" &&
typeof putativeSpy.getCall === "function" &&
typeof putativeSpy.calledWithExactly === "function";
}
/* istanbul ignore else */
if (typeof commonjsRequire === "function" && 'object' === "object" && 'object' === "object") {
// NodeJS
module.exports = sinonChai;
} else {
// Other environment (usually <script> tag): plug in to global chai instance directly.
/* global chai: false */
chai.use(sinonChai);
}
}(function (chai, utils) {
var slice = Array.prototype.slice;
function timesInWords(count) {
switch (count) {
case 1: {
return "once";
}
case 2: {
return "twice";
}
case 3: {
return "thrice";
}
default: {
return (count || 0) + " times";
}
}
}
function isSpy(putativeSpy) {
return typeof putativeSpy === "function" &&
typeof putativeSpy.getCall === "function" &&
typeof putativeSpy.calledWithExactly === "function";
}
function isCall(putativeCall) {
return putativeCall && isSpy(putativeCall.proxy);
}
function timesInWords(count) {
switch (count) {
case 1: {
return "once";
}
case 2: {
return "twice";
}
case 3: {
return "thrice";
}
default: {
return (count || 0) + " times";
}
}
}
function assertCanWorkWith(assertion) {
if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
}
}
function isCall(putativeCall) {
return putativeCall && isSpy(putativeCall.proxy);
}
function getMessages(spy, action, nonNegatedSuffix, always, args) {
var verbPhrase = always ? "always have " : "have ";
nonNegatedSuffix = nonNegatedSuffix || "";
if (isSpy(spy.proxy)) {
spy = spy.proxy;
}
function assertCanWorkWith(assertion) {
if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
}
}
function printfArray(array) {
return spy.printf.apply(spy, array);
}
function getMessages(spy, action, nonNegatedSuffix, always, args) {
var verbPhrase = always ? "always have " : "have ";
nonNegatedSuffix = nonNegatedSuffix || "";
if (isSpy(spy.proxy)) {
spy = spy.proxy;
}
return {
affirmative: function () {
return printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args));
},
negative: function () {
return printfArray(["expected %n to not " + verbPhrase + action].concat(args));
}
};
}
function printfArray(array) {
return spy.printf.apply(spy, array);
}
function sinonProperty(name, action, nonNegatedSuffix) {
utils.addProperty(chai.Assertion.prototype, name, function () {
assertCanWorkWith(this);
return {
affirmative: function () {
return printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args));
},
negative: function () {
return printfArray(["expected %n to not " + verbPhrase + action].concat(args));
}
};
}
var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
this.assert(this._obj[name], messages.affirmative, messages.negative);
});
}
function sinonProperty(name, action, nonNegatedSuffix) {
utils.addProperty(chai.Assertion.prototype, name, function () {
assertCanWorkWith(this);
function sinonPropertyAsBooleanMethod(name, action, nonNegatedSuffix) {
utils.addMethod(chai.Assertion.prototype, name, function (arg) {
assertCanWorkWith(this);
var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
this.assert(this._obj[name], messages.affirmative, messages.negative);
});
}
var messages = getMessages(this._obj, action, nonNegatedSuffix, false, [timesInWords(arg)]);
this.assert(this._obj[name] === arg, messages.affirmative, messages.negative);
});
}
function sinonPropertyAsBooleanMethod(name, action, nonNegatedSuffix) {
utils.addMethod(chai.Assertion.prototype, name, function (arg) {
assertCanWorkWith(this);
function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
return function () {
assertCanWorkWith(this);
var messages = getMessages(this._obj, action, nonNegatedSuffix, false, [timesInWords(arg)]);
this.assert(this._obj[name] === arg, messages.affirmative, messages.negative);
});
}
var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
var sinonMethodName = shouldBeAlways ? alwaysSinonMethod : sinonName;
function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
return function () {
assertCanWorkWith(this);
var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
this.assert(
this._obj[sinonMethodName].apply(this._obj, arguments),
messages.affirmative,
messages.negative
);
};
}
var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
var sinonMethodName = shouldBeAlways ? alwaysSinonMethod : sinonName;
function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
utils.addProperty(chai.Assertion.prototype, name, handler);
}
var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
this.assert(
this._obj[sinonMethodName].apply(this._obj, arguments),
messages.affirmative,
messages.negative
);
};
}
function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
utils.addMethod(chai.Assertion.prototype, chaiName, handler);
}
function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
utils.addProperty(chai.Assertion.prototype, name, handler);
}
function sinonMethod(name, action, nonNegatedSuffix) {
exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
}
function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
utils.addMethod(chai.Assertion.prototype, chaiName, handler);
}
utils.addProperty(chai.Assertion.prototype, "always", function () {
utils.flag(this, "always", true);
});
function sinonMethod(name, action, nonNegatedSuffix) {
exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
}
sinonProperty("called", "been called", " at least once, but it was never called");
sinonPropertyAsBooleanMethod("callCount", "been called exactly %1", ", but it was called %c%C");
sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
sinonMethodAsProperty("calledWithNew", "been called with new");
sinonMethod("calledBefore", "been called before %1");
sinonMethod("calledAfter", "been called after %1");
sinonMethod("calledImmediatelyBefore", "been called immediately before %1");
sinonMethod("calledImmediatelyAfter", "been called immediately after %1");
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
sinonMethod("calledWith", "been called with arguments %*", "%D");
sinonMethod("calledOnceWith", "been called exactly once with arguments %*", "%D");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%D");
sinonMethod("calledOnceWithExactly", "been called exactly once with exact arguments %*", "%D");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%D");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));
});
utils.addProperty(chai.Assertion.prototype, "always", function () {
utils.flag(this, "always", true);
});
sinonProperty("called", "been called", " at least once, but it was never called");
sinonPropertyAsBooleanMethod("callCount", "been called exactly %1", ", but it was called %c%C");
sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
sinonMethodAsProperty("calledWithNew", "been called with new");
sinonMethod("calledBefore", "been called before %1");
sinonMethod("calledAfter", "been called after %1");
sinonMethod("calledImmediatelyBefore", "been called immediately before %1");
sinonMethod("calledImmediatelyAfter", "been called immediately after %1");
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
sinonMethod("calledWith", "been called with arguments %*", "%D");
sinonMethod("calledOnceWith", "been called exactly once with arguments %*", "%D");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%D");
sinonMethod("calledOnceWithExactly", "been called exactly once with exact arguments %*", "%D");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%D");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));
} (sinonChai$1));
var sinonChai = sinonChaiExports;
export { sinonChai as default };

@@ -13,3 +13,3 @@ # Testing >> Testing Package ||10

Exposes all functions of [@open-wc/testing-helpers](https://github.com/open-wc/open-wc/blob/74f51a7bcc59a2b1adea2fd6265ec24c5b42c952/docs/docs/testing/helpers.md), so that you have a single package to import from:
Exposes all functions of [@open-wc/testing-helpers](https://github.com/open-wc/open-wc/blob/57ddb3ccfff6b00468d3a7ebabbc15cfe966f7a9/docs/docs/testing/helpers.md), so that you have a single package to import from:

@@ -16,0 +16,0 @@ ```javascript

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