Socket
Socket
Sign inDemoInstall

jasmine-dom-spec

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-dom-spec - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

dist/jasmine-dom-spec.d.ts

2

bower.json
{
"name": "jasmine-dom-spec",
"version": "0.5.0",
"version": "0.6.0",
"authors": [

@@ -5,0 +5,0 @@ "Mickael Jeanroy"

/**
* The MIT License (MIT)
*
* Copyright (c) 2014-2018 Mickael Jeanroy
* Copyright (c) 2014-2019 Mickael Jeanroy
*

@@ -36,3 +36,2 @@ * Permission is hereby granted, free of charge, to any person obtaining a copy

}
/**

@@ -42,2 +41,4 @@ * Major version of Jasmine being imported.

*/
var version = _version;

@@ -65,8 +66,2 @@

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
return typeof obj;
} : function(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
/**

@@ -78,4 +73,5 @@ * Check that a given value is an object.

*/
function isObject(obj) {
return !isNull(obj) && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
return !isNull(obj) && typeof obj === 'object';
}

@@ -87,4 +83,4 @@

*/
var ELEMENT_NODE = 1;
/**

@@ -96,2 +92,3 @@ * Check if an object is a DOM node.

*/
function isDomElement(actual) {

@@ -111,2 +108,3 @@ if (isNull(actual) || isUndefined(actual)) {

*/
function pp(value) {

@@ -125,3 +123,2 @@ try {

var PLACEHOLDER = '[NOT]';
/**

@@ -136,2 +133,3 @@ * Return message with the appropriate negation:

*/
function negateMessage(isNot, message) {

@@ -142,3 +140,3 @@ if (!message) {

var notKey = isNot ? PLACEHOLDER : PLACEHOLDER + ' ';
var notKey = isNot ? PLACEHOLDER : PLACEHOLDER + " ";
var notValue = isNot ? 'not' : '';

@@ -158,2 +156,3 @@ return message.replace(notKey, notValue);

*/
function jasmine1MatcherFactory(fn) {

@@ -167,19 +166,13 @@ /**

// The `this` object is equals to the current test context.
// eslint-disable-next-line no-invalid-this
var env = this.env;
var env = this.env; // eslint-disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
var equals_ = this.env.equals_;
var equals_ = this.env.equals_; // eslint-disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
var actual = this.actual;
var actual = this.actual; // eslint-disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
var isNot = this.isNot;
var ctx = {
actual: actual,
isNot: isNot,
// Adapter for `callCount`

@@ -190,4 +183,2 @@ // https://jasmine.github.io/1.3/introduction#section-Spies

},
// Adapter for `argsFor`

@@ -198,7 +189,5 @@ // https://jasmine.github.io/1.3/introduction#section-Spies

},
// Adapter for custom equality.
equals: function equals() {
for (var _len2 = arguments.length, equalsArgs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, equalsArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
equalsArgs[_key2] = arguments[_key2];

@@ -211,3 +200,3 @@ }

for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -240,2 +229,3 @@ }

*/
function jasmine2MatcherFactory(fn) {

@@ -257,4 +247,2 @@ /**

},
// Adapter for `argsFor`.

@@ -265,4 +253,2 @@ // See: https://jasmine.github.io/2.5/introduction#section-Spies

},
// Adapter for custom equals functions.

@@ -274,3 +260,2 @@ // See: https://jasmine.github.io/2.5/custom_equality.html

};
return {

@@ -289,7 +274,7 @@ /**

for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var result = fn.apply(undefined, [ctx].concat(args));
var result = fn.apply(void 0, [ctx].concat(args));
return {

@@ -303,3 +288,2 @@ pass: result.pass,

/**

@@ -317,7 +301,7 @@ * Jasmine2 compare function that will be called when a custom matcher is used with:

for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
var result = fn.apply(undefined, [ctx].concat(args));
var result = fn.apply(void 0, [ctx].concat(args));
return {

@@ -336,5 +320,6 @@ pass: !result.pass,

1: jasmine1MatcherFactory,
2: jasmine2MatcherFactory
// Api for custom matchers with jasmine 2 and jasmine 3 is the same.
2: jasmine2MatcherFactory,
3: jasmine2MatcherFactory
};
/**

@@ -347,2 +332,3 @@ * Create Jasmine matcher.

*/
function createMatcher(matcher) {

@@ -383,3 +369,2 @@ return (factories[version] || jasmine2MatcherFactory)(matcher);

// Use a fallback for `Object.keys` if needed (for old browsers).
var objectKeys = Object.keys || function _keys(o) {

@@ -396,3 +381,2 @@ var results = [];

};
/**

@@ -404,2 +388,4 @@ * Get all own and enumerable keys of an object.

*/
function keys(obj) {

@@ -410,2 +396,30 @@ return objectKeys(obj);

/**
* Check if a key is a property of a given object or an inherited property.
*
* @param {Object} object Object to check.
* @param {string} prop Property (a.k.a key) to look for.
* @return {boolean} `true` if `prop` is a key in `object`, `false` otherwise.
*/
function hasIn(object, prop) {
return prop in object;
}
/**
* Check that given object has given property in its prototype chain.
*
* @param {Object} o The object.
* @param {string} prop Property name.
* @param {string} message The error message.
* @return {Object} The original object.
*/
function ensureHasIn(o, prop, message) {
if (!hasIn(o, prop)) {
throw new Error(message);
}
return o;
}
/**
* Return the tag name of the object (a.k.a the result of `Object.prototype.toString`).

@@ -416,5 +430,5 @@ *

*/
function tagName(obj) {
// Handle null and undefined since it may fail on some browser.
if (isNull(obj)) {

@@ -428,21 +442,19 @@ return '[object Null]';

var tag = Object.prototype.toString.call(obj);
// IE11 on Win10 returns `[object Object]` with `Map` and `Set`.
var tag = Object.prototype.toString.call(obj); // IE11 on Win10 returns `[object Object]` with `Map` and `Set`.
// IE8 returns `[object Object]` with NodeList and HTMLCollection.
// Try to patch this bug and return the appropriate tag value.
if (tag === '[object Object]') {
// -- IE8 Patch
// Handle NodeList (IE8 only).
if (obj instanceof NodeList) {
return '[object NodeList]';
}
} // Handle HTMLCollection (IE8 only).
// Handle HTMLCollection (IE8 only).
if (obj instanceof HTMLCollection) {
return '[object HTMLCollection]';
}
} // Handle HTMLCollection (IE8 only).
// Handle HTMLCollection (IE8 only).
if (has(obj, 'callee')) {

@@ -465,4 +477,5 @@ return '[object Arguments]';

*/
function is(obj, type) {
return tagName(obj) === '[object ' + type + ']';
return tagName(obj) === "[object " + type + "]";
}

@@ -476,2 +489,3 @@

*/
function isString(obj) {

@@ -491,2 +505,3 @@ return is(obj, 'String');

*/
function isNodeCollection(obj) {

@@ -525,2 +540,3 @@ return is(obj, 'NodeList') || is(obj, 'HTMLCollection');

*/
function isFunction(value) {

@@ -536,2 +552,3 @@ return is(value, 'Function');

*/
function isNumber(obj) {

@@ -541,6 +558,5 @@ return is(obj, 'Number');

// Main jQuery methods.
// An object with these methods will be considered a jQuery object.
var JQ_METHODS = ['addClass', 'prop', 'attr', 'html', 'text'];
/**

@@ -553,2 +569,3 @@ * Check if the parameter is an HTML collection (i.e a generic collection (array-like

*/
function isJqueryObject(obj) {

@@ -558,12 +575,12 @@ // Fail fast with `primitive types`.

return false;
}
} // If `obj` is an instance of global jQuery, we are sure it is a jQuery object.
// If `obj` is an instance of global jQuery, we are sure it is a jQuery object.
if (isJqueryGloballyAvailable() && obj instanceof jQuery) {
return true;
}
// Use duck-typing ; each jQuery instances should have:
} // Use duck-typing ; each jQuery instances should have:
// - A `length` property that is a `number` greater than or equal to zero.
// - Mandatory methods listed below.
return isNumber(obj.length) && obj.length >= 0 && every(JQ_METHODS, function(x) {

@@ -573,3 +590,2 @@ return isFunction(obj[x]);

}
/**

@@ -580,2 +596,3 @@ * Check if `jQuery` is globally available (i.e available on `window` object).

*/
function isJqueryGloballyAvailable() {

@@ -588,3 +605,2 @@ return typeof jQuery !== 'undefined';

};
/**

@@ -596,2 +612,4 @@ * Check that a given value is an array.

*/
function isArray(obj) {

@@ -609,2 +627,3 @@ return _isArray(obj);

*/
function toDomElement(value) {

@@ -616,2 +635,3 @@ if (isDomElement(value)) {

var nodes = isString(value) ? createNodes(value) : value;
if (isNodeCollection(nodes) || isJqueryObject(nodes) || isArray(nodes)) {

@@ -621,5 +641,4 @@ return extractSingleNode(nodes);

throw new Error('Expect DOM node but found: ' + pp(value));
throw new Error("Expect DOM node but found: " + pp(value));
}
/**

@@ -631,2 +650,3 @@ * Translate HTML content to a `NodeList` element.

*/
function createNodes(html) {

@@ -637,3 +657,2 @@ var div = document.createElement('div');

}
/**

@@ -647,4 +666,7 @@ * Extract DOM from singleton array-like object and:

*/
function extractSingleNode(value) {
var size = value.length;
if (size === 0) {

@@ -655,3 +677,3 @@ throw new Error('Expect valid node but found empty node list');

if (size > 1) {
throw new Error('Expect single node but found node list of ' + size + ' nodes: ' + pp(value));
throw new Error("Expect single node but found node list of " + size + " nodes: " + pp(value));
}

@@ -662,3 +684,3 @@

if (!isDomElement(node)) {
throw new Error('Expect single node but found value: ' + pp(value));
throw new Error("Expect single node but found value: " + pp(value));
}

@@ -684,11 +706,11 @@

*/
function toBeChecked(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var checked = node.checked;
ensureHasIn(node, 'checked', 'Cannot run `toBeChecked` matcher on a DOM node without `checked` property');
return {
pass: checked === true,
pass: node.checked === true,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be checked';
return "Expect " + pp(actual) + " [NOT] to be checked";
}

@@ -713,9 +735,9 @@ };

*/
function toBeDetachedElement(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var isDetached = true;
var parentNode = node;
while (parentNode) {

@@ -733,3 +755,3 @@ if (parentNode === document || parentNode === document.body) {

message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be detached element';
return "Expect " + pp(actual) + " [NOT] to be detached element";
}

@@ -753,11 +775,11 @@ };

*/
function toBeDisabled(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var disabled = node.disabled;
ensureHasIn(node, 'disabled', 'Cannot run `toBeDisabled` matcher on a DOM node without `disabled` property');
return {
pass: disabled === true,
pass: node.disabled === true,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be disabled';
return "Expect " + pp(actual) + " [NOT] to be disabled";
}

@@ -794,18 +816,16 @@ };

*/
function toBeDisplayed(_ref) {
var actual = _ref.actual,
equals = _ref.equals;
var node = toDomElement(actual);
var display = getCurrentDisplayStyleValue(node);
var ok = !equals(display, 'none');
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be displayed';
return "Expect " + pp(actual) + " [NOT] to be displayed";
}
};
}
/**

@@ -817,2 +837,3 @@ * Get the value of the `display` css property on given node.

*/
function getCurrentDisplayStyleValue(node) {

@@ -822,14 +843,13 @@ // Modern browsers.

return getComputedDisplayStyle(node);
}
} // IE8 does not support `getComputedStyle` method.
// IE8 does not support `getComputedStyle` method.
if (isIn(node, 'currentStyle')) {
return getCurrentDisplayStyle(node);
}
} // If we are here, then it's weird since `getComputedStyle` and `currentStyle` are not supported.
// Use the `style` property as a fallback.
// If we are here, then it's weird since `getComputedStyle` and `currentStyle` are not supported.
// Use the `style` property as a fallback.
return node.style.display;
}
/**

@@ -844,2 +864,4 @@ * Extract the computed value of the `display` style property.

*/
function getComputedDisplayStyle(node) {

@@ -854,3 +876,2 @@ try {

}
/**

@@ -866,2 +887,4 @@ * Extract the current style value of the `display` style property.

*/
function getCurrentDisplayStyle(node) {

@@ -891,5 +914,5 @@ try {

*/
function toBeFocused(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);

@@ -900,3 +923,3 @@ var activeElement = document.activeElement;

message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be focused';
return "Expect " + pp(actual) + " [NOT] to be focused";
}

@@ -921,11 +944,11 @@ };

*/
function toBeIndeterminate(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var indeterminate = node.indeterminate;
ensureHasIn(node, 'indeterminate', 'Cannot run `toBeIndeterminate` matcher on a DOM node without `indeterminate` property');
return {
pass: indeterminate === true,
pass: node.indeterminate === true,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be indeterminate';
return "Expect " + pp(actual) + " [NOT] to be indeterminate";
}

@@ -949,11 +972,11 @@ };

*/
function toBeRequired(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var required = node.required;
ensureHasIn(node, 'required', 'Cannot run `toBeRequired` matcher on a DOM node without `required` property');
return {
pass: required === true,
pass: node.required === true,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be required';
return "Expect " + pp(actual) + " [NOT] to be required";
}

@@ -977,11 +1000,11 @@ };

*/
function toBeSelected(_ref) {
var actual = _ref.actual;
var node = toDomElement(actual);
var selected = node.selected;
ensureHasIn(node, 'selected', 'Cannot run `toBeSelected` matcher on a DOM node without `selected` property');
return {
pass: selected === true,
pass: node.selected === true,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to be selected';
return "Expect " + pp(actual) + " [NOT] to be selected";
}

@@ -997,2 +1020,3 @@ };

*/
function isNil(obj) {

@@ -1008,2 +1032,3 @@ return isNull(obj) || isUndefined(obj);

*/
function isRegExp(value) {

@@ -1022,2 +1047,3 @@ return is(value, 'RegExp');

*/
function matchOrEquals(actual, expected, equalsFn) {

@@ -1046,28 +1072,20 @@ if (isRegExp(expected)) {

* @param {Object} ctx Test context.
* @param {String|RegExp|Object} id The expected id or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|RegExp|jasmine.Any|jasmine.Anything} id The expected id or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveId(_ref, id) {
var actual = _ref.actual,
equals = _ref.equals;
var node = toDomElement(actual);
var actualId = node.id;
var checkId = !isUndefined(id);
var pass = !isNil(actualId) && actualId !== '';
if (checkId) {
pass = pass && matchOrEquals(actualId, id, equals);
}
var isIdFilled = !isNil(actualId) && actualId !== '';
var isExpectedId = checkId ? matchOrEquals(actualId, id, equals) : true;
var pass = isIdFilled && isExpectedId;
return {
pass: pass,
message: function message() {
var msg = 'Expect ' + pp(actual) + ' [NOT] to have id';
if (checkId) {
msg += ' ' + pp(id) + ' but was ' + pp(actualId);
}
return msg;
return "Expect " + pp(actual) + " [NOT] to have id" + (checkId ? " " + pp(id) + " but was " + pp(actualId) : '');
}

@@ -1093,12 +1111,12 @@ };

* @param {String|Object} attrName Attribute name (or map of attributes).
* @param {String|RegExp|Object} attrValue Attribute value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|RegExp|jasmine.Any|jasmine.Anything} attrValue Attribute value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveAttrs(_ref, attrName, attrValue) {
var _ref2;
var actual = _ref.actual,
equals = _ref.equals;
var _ref2;
var node = toDomElement(actual);

@@ -1113,2 +1131,3 @@ var expected = isObject(attrName) ? attrName : (_ref2 = {}, _ref2[attrName] = attrValue, _ref2);

var expectedValue = expected[attr];
if (isUndefined(expectedValue)) {

@@ -1121,7 +1140,6 @@ return true;

});
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have attributes ' + pp(expected);
return "Expect " + pp(actual) + " [NOT] to have attributes " + pp(expected);
}

@@ -1132,14 +1150,14 @@ };

/**
* Apply a predicate function on all the values of an array (also supports array-like
* objects) and returns an array without elements that satisfied the predicate.
*
* The iteratee function will be called with three arguments:
* - `value` The value for the given iteration.
* - `index` The index of the value being iterated.
* - `array` The array being traversed.
*
* @param {Array<*>} array The array to iterate.
* @param {function} predicate The filter function.
* @return {Array<*>} Array without filtered elements.
*/
* Apply a predicate function on all the values of an array (also supports array-like
* objects) and returns an array without elements that satisfied the predicate.
*
* The iteratee function will be called with three arguments:
* - `value` The value for the given iteration.
* - `index` The index of the value being iterated.
* - `array` The array being traversed.
*
* @param {Array<*>} array The array to iterate.
* @param {function} predicate The filter function.
* @return {Array<*>} Array without filtered elements.
*/
function filter(array, predicate) {

@@ -1186,14 +1204,14 @@ var results = [];

/**
* Apply a predicate function on all the values of an array (also supports array-like
* objects) and returns an array of all intermediate results.
*
* The iteratee function will be called with three arguments:
* - `value` The value for the given iteration.
* - `index` The index of the value being iterated.
* - `array` The array being traversed.
*
* @param {Array<*>} array The array to iterate.
* @param {function} iteratee The iteratee function.
* @return {Array<*>} Array containing all intermediate results.
*/
* Apply a predicate function on all the values of an array (also supports array-like
* objects) and returns an array of all intermediate results.
*
* The iteratee function will be called with three arguments:
* - `value` The value for the given iteration.
* - `index` The index of the value being iterated.
* - `array` The array being traversed.
*
* @param {Array<*>} array The array to iterate.
* @param {function} iteratee The iteratee function.
* @return {Array<*>} Array containing all intermediate results.
*/
function map(array, iteratee) {

@@ -1233,3 +1251,2 @@ var results = [];

var _trim = String.prototype.trim;
/**

@@ -1241,2 +1258,3 @@ * Trim a string (use native String#trim function if available).

*/
function trim(str) {

@@ -1272,5 +1290,5 @@ if (_trim) {

*/
function toHaveCssClass(_ref, expected) {
var actual = _ref.actual;
var node = toDomElement(actual);

@@ -1285,11 +1303,9 @@ var actualClasses = extract(node.className);

});
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have css class ' + pp(expected);
return "Expect " + pp(actual) + " [NOT] to have css class " + pp(expected);
}
};
}
/**

@@ -1300,2 +1316,3 @@ * Extract array of all css classes, removing useless whitespaces.

*/
function extract(classes) {

@@ -1314,3 +1331,2 @@ if (isRegExp(classes)) {

}
/**

@@ -1324,2 +1340,4 @@ * Check if the given regexp match at least one element in the

*/
function matchOne(array, regexp) {

@@ -1339,2 +1357,3 @@ return some(array, function(x) {

*/
function isBoolean(obj) {

@@ -1353,2 +1372,3 @@ return obj === true || obj === false || is(obj, 'Boolean');

*/
function isPrimitive(obj) {

@@ -1373,26 +1393,23 @@ return isString(obj) || isNumber(obj) || isBoolean(obj);

* @param {Object} ctx Test context.
* @param {String|Number|Boolean|RegExp|Object} html The expected html or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|Number|Boolean|RegExp|jasmine.Any|jasmine.Anything} html The expected html or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveHtml(_ref, html) {
var actual = _ref.actual,
equals = _ref.equals;
var node = toDomElement(actual);
var actualHtml = node.innerHTML;
var actualHtml = node.innerHTML; // Html may be a string **or** a jasmine asymetric matcher object.
// In the last case, do not try to normalize HTML.
// Html may be a string **or** a jasmine asymetric matcher object.
// In the last case, do not try to normalize HTML.
var expectedHtml = isPrimitive(html) ? normalizeHtml(html.toString()) : html;
var ok = matchOrEquals(actualHtml, expectedHtml, equals);
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have HTML ' + pp(expectedHtml) + ' but was ' + pp(actualHtml);
return "Expect " + pp(actual) + " [NOT] to have HTML " + pp(expectedHtml) + " but was " + pp(actualHtml);
}
};
}
/**

@@ -1406,2 +1423,3 @@ * Normalize HTML to be able to compare HTML content

*/
function normalizeHtml(html) {

@@ -1435,8 +1453,8 @@ var fragment = document.createElement('div');

*/
function toHaveProps(_ref, propName, propValue) {
var _ref2;
var actual = _ref.actual,
equals = _ref.equals;
var _ref2;
var node = toDomElement(actual);

@@ -1448,7 +1466,6 @@ var expected = isObject(propName) ? propName : (_ref2 = {}, _ref2[propName] = propValue, _ref2);

});
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have properties ' + pp(expected);
return "Expect " + pp(actual) + " [NOT] to have properties " + pp(expected);
}

@@ -1472,4 +1489,6 @@ };

var turnToUpper = false;
for (var i = 0, size = value.length; i < size; ++i) {
var c = value.charAt(i);
if (c === '-') {

@@ -1504,12 +1523,12 @@ turnToUpper = true;

* @param {String|Object} styleName Style name or object of styles.
* @param {String|RegExp|Object} styleValue Style value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|RegExp|jasmine.Any|jasmine.Anything} styleValue Style value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveStyle(_ref, styleName, styleValue) {
var _ref2;
var actual = _ref.actual,
equals = _ref.equals;
var _ref2;
var node = toDomElement(actual);

@@ -1524,7 +1543,6 @@ var expected = isObject(styleName) ? styleName : (_ref2 = {}, _ref2[styleName] = styleValue, _ref2);

});
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have styles ' + pp(expected);
return "Expect " + pp(actual) + " [NOT] to have styles " + pp(expected);
}

@@ -1541,2 +1559,3 @@ };

*/
function toLower(value) {

@@ -1558,10 +1577,10 @@ return isString(value) ? value.toLowerCase() : value;

* @param {Object} ctx Test context.
* @param {String|Object|RegExp} tagName The expected tag name or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|RegExp|jasmine.Any|jasmine.Anything} tagName The expected tag name or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveTagName(_ref, tagName) {
var actual = _ref.actual,
equals = _ref.equals;
// IE8 does not know textContent but knows innerText.

@@ -1573,7 +1592,6 @@ var node = toDomElement(actual);

var ok = matchOrEquals(lowerActualTagName, lowerExpectedTagName, equals);
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have tag name ' + pp(tagName) + ' but was ' + pp(actualTagName);
return "Expect " + pp(actual) + " [NOT] to have tag name " + pp(tagName) + " but was " + pp(actualTagName);
}

@@ -1599,10 +1617,10 @@ };

* @param {Object} ctx Test context.
* @param {String|Number|Boolean|RegExp|Object} text The expected text or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|Number|Boolean|RegExp|jasmine.Any|jasmine.Anything} text The expected text or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveText(_ref, text) {
var actual = _ref.actual,
equals = _ref.equals;
// IE8 does not know textContent but knows innerText.

@@ -1613,7 +1631,6 @@ var node = toDomElement(actual);

var ok = matchOrEquals(actualText, expectedText, equals);
return {
pass: ok,
message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have text ' + pp(expectedText) + ' but was ' + pp(actualText);
return "Expect " + pp(actual) + " [NOT] to have text " + pp(expectedText) + " but was " + pp(actualText);
}

@@ -1637,11 +1654,12 @@ };

* @param {Object} ctx Test context.
* @param {String|RegExp|Object} expectedValue The expected value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @param {String|RegExp|jasmine.Any|jasmine.Anything} expectedValue The expected value or a jasmine matcher (i.e `jasmine.any(<Type>)`).
* @return {Object} Test result.
* @since 0.1.0
*/
function toHaveValue(_ref, expectedValue) {
var actual = _ref.actual,
equals = _ref.equals;
var node = toDomElement(actual);
ensureHasIn(node, 'value', 'Cannot run `toHaveValue` matcher on a DOM node without `value` property');
var actualValue = node.value;

@@ -1651,3 +1669,3 @@ return {

message: function message() {
return 'Expect ' + pp(actual) + ' [NOT] to have value ' + pp(expectedValue) + ' but was ' + pp(actualValue);
return "Expect " + pp(actual) + " [NOT] to have value " + pp(expectedValue) + " but was " + pp(actualValue);
}

@@ -1659,3 +1677,3 @@ };

var matchers = (Object.freeze || Object)({
var matchers = /*#__PURE__*/ Object.freeze({
toBeChecked: toBeChecked,

@@ -1680,9 +1698,6 @@ toBeDetachedElement: toBeDetachedElement,

// Create matchers and add it to the current jasmine environment.
var jasmineMatchers = {};
forEach(keys(matchers), function(id) {
jasmineMatchers[id] = createMatcher(matchers[id]);
});
beforeEach(function jasmineUtilBeforeEach() {

@@ -1689,0 +1704,0 @@ if (version === 1) {

{
"name": "jasmine-dom-spec",
"version": "0.5.0",
"version": "0.6.0",
"description": "DOM Matchers and assertions for Jasmine framework",
"main": "dist/jasmine-dom-spec.js",
"typings": "dist/jasmine-dom-spec.d.ts",
"types": "dist/jasmine-dom-spec.d.ts",
"repository": {

@@ -17,3 +19,3 @@ "type": "git",

"build": "gulp build",
"release": "gulp release",
"release": "gulp release:minor",
"release:patch": "gulp release:patch",

@@ -35,40 +37,45 @@ "release:minor": "gulp release:minor",

"devDependencies": {
"ansi-colors": "1.0.1",
"babel-core": "6.26.0",
"babel-preset-env": "1.6.1",
"del": "3.0.0",
"@babel/core": "7.4.4",
"@babel/preset-env": "7.4.4",
"@types/jasmine": "3.3.12",
"ansi-colors": "3.2.4",
"del": "4.1.1",
"dox": "0.9.0",
"eslint": "4.17.0",
"eslint-config-google": "0.9.1",
"fancy-log": "1.3.2",
"glob": "7.1.2",
"gulp": "3.9.1",
"gulp-bump": "3.0.0",
"gulp-eslint": "4.0.2",
"gulp-git": "2.5.1",
"eslint": "5.16.0",
"eslint-config-google": "0.12.0",
"fancy-log": "1.3.3",
"glob": "7.1.3",
"gulp": "4.0.1",
"gulp-bump": "3.1.3",
"gulp-eslint": "5.0.0",
"gulp-git": "2.9.0",
"gulp-rename": "1.4.0",
"gulp-tag-version": "1.3.1",
"handlebars": "4.0.11",
"jasmine-core": "2.9.1",
"gulp-tslint": "8.1.4",
"handlebars": "4.1.2",
"jasmine-core": "3.4.0",
"jquery": "1.12.4",
"karma": "2.0.0",
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "1.1.1",
"karma-jasmine-html-reporter": "0.2.2",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.2",
"karma-phantomjs-launcher": "1.0.4",
"karma-rollup-preprocessor": "5.1.1",
"karma-rollup-preprocessor": "7.0.0",
"karma-safari-launcher": "1.0.0",
"karma-sauce-launcher": "1.2.0",
"lodash": "4.17.5",
"lodash": "4.17.11",
"phantomjs-prebuilt": "2.1.16",
"q": "1.5.1",
"rollup": "0.55.3",
"rollup-plugin-babel": "3.0.3",
"rollup-plugin-commonjs": "8.3.0",
"rollup-plugin-esformatter": "0.5.0",
"rollup-plugin-license": "0.5.0",
"rollup-plugin-node-resolve": "3.0.2",
"rollup": "1.11.3",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-commonjs": "9.3.4",
"rollup-plugin-esformatter": "0.7.0",
"rollup-plugin-license": "0.8.1",
"rollup-plugin-node-resolve": "4.2.3",
"rollup-plugin-strip-banner": "0.2.0",
"touch": "3.1.0"
"touch": "3.1.0",
"tslint": "5.16.0",
"typescript": "3.4.5"
}
}

@@ -248,3 +248,3 @@ jasmine-dom-spec

| `attrName` | `String,Object` | Attribute name (or map of attributes). |
| `attrValue` | `String,RegExp,Object` | Attribute value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `attrValue` | `String,RegExp,jasmine.Any,jasmine.Anything` | Attribute value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -320,3 +320,3 @@ #### Message

|------|------|-------------|
| `html` | `String,Number,Boolean,RegExp,Object` | The expected html or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `html` | `String,Number,Boolean,RegExp,jasmine.Any,jasmine.Anything` | The expected html or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -352,3 +352,3 @@ #### Message

|------|------|-------------|
| `id` | `String,RegExp,Object` | The expected id or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `id` | `String,RegExp,jasmine.Any,jasmine.Anything` | The expected id or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -422,3 +422,3 @@ #### Message

| `styleName` | `String,Object` | Style name or object of styles. |
| `styleValue` | `String,RegExp,Object` | Style value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `styleValue` | `String,RegExp,jasmine.Any,jasmine.Anything` | Style value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -457,3 +457,3 @@ #### Message

|------|------|-------------|
| `tagName` | `String,Object,RegExp` | The expected tag name or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `tagName` | `String,RegExp,jasmine.Any,jasmine.Anything` | The expected tag name or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -490,3 +490,3 @@ #### Message

|------|------|-------------|
| `text` | `String,Number,Boolean,RegExp,Object` | The expected text or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `text` | `String,Number,Boolean,RegExp,jasmine.Any,jasmine.Anything` | The expected text or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -524,3 +524,3 @@ #### Message

|------|------|-------------|
| `expectedValue` | `String,RegExp,Object` | The expected value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |
| `expectedValue` | `String,RegExp,jasmine.Any,jasmine.Anything` | The expected value or a jasmine matcher (i.e `jasmine.any(<Type>)`). |

@@ -527,0 +527,0 @@ #### Message

Sorry, the diff of this file is not supported yet

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