diff --git a/.gitignore b/.gitignore index b20ce55e..81327a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ coverage site-build .nyc_output lib +unexpected-dom.js +unexpected-dom.min.js diff --git a/package.json b/package.json index fffdbb6f..13f7a5ff 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "test-node": "mocha ./test/*.js", "test-headless": "npm run test-browser", "coverage": "nyc --reporter=lcov --reporter=text npm test", - "preversion": "npm run build && npm run bundle && npm run lint && npm run test && git add unexpected-dom.*", + "preversion": "npm run lint && npm run test", + "prepublishOnly": "npm run build && npm run bundle", "postversion": "npm run changelog && git add CHANGELOG.md && git commit --allow-empty -m 'Update changelog' && npm run generate-site && gh-pages -d site-build", "generate-site": "generate-site --require ./bootstrap-unexpected-markdown.js", "update-examples": "generate-site --require ./bootstrap-unexpected-markdown.js --update-examples" diff --git a/unexpected-dom.js b/unexpected-dom.js deleted file mode 100644 index aef344f8..00000000 --- a/unexpected-dom.js +++ /dev/null @@ -1,2640 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.unexpected || (g.unexpected = {})).dom = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i { anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); }); ' + str + ''; - } - var htmlDocument = getHtmlDocument(str); - - if (isFragment) { - var body = htmlDocument.body; - var documentFragment = htmlDocument.createDocumentFragment(); - if (body) { - for (var i = 0; i < body.childNodes.length; i += 1) { - documentFragment.appendChild(body.childNodes[i].cloneNode(true)); - } - } - return documentFragment; - } else { - return htmlDocument; - } -} - -function parseXml(str) { - if (typeof DOMParser !== 'undefined') { - return new DOMParser().parseFromString(str, 'text/xml'); - } else { - var jsdom = getJSDOM(); - - if (jsdom.JSDOM) { - return new jsdom.JSDOM(str, { contentType: 'text/xml' }).window.document; - } else { - return jsdom.jsdom(str, { parsingMode: 'xml' }); - } - } -} - -// From html-minifier -var enumeratedAttributeValues = { - draggable: ['true', 'false'] // defaults to 'auto' -}; - -var matchSimpleAttribute = /^(?:allowfullscreen|async|autofocus|autoplay|checked|compact|controls|declare|default|defaultchecked|defaultmuted|defaultselected|defer|disabled|enabled|formnovalidate|hidden|indeterminate|inert|ismap|itemscope|loop|multiple|muted|nohref|noresize|noshade|novalidate|nowrap|open|pauseonexit|readonly|required|reversed|scoped|seamless|selected|sortable|spellcheck|truespeed|typemustmatch|visible)$/i; - -function isBooleanAttribute(attrName) { - return matchSimpleAttribute.test(attrName); -} - -function isEnumeratedAttribute(attrName) { - return attrName in enumeratedAttributeValues; -} - -function validateStyles(expect, str) { - var invalidStyles = str.split(';').filter(function (part) { - return !/^\s*(\w|-)+\s*:\s*(#(?:[0-9a-fA-F]{3}){1,2}|[^#]+)\s*$|^$/.test(part); - }); - - if (invalidStyles.length > 0) { - expect.errorMode = 'nested'; - expect.fail('Expectation contains invalid styles: {0}', invalidStyles.join(';')); - } -} - -function styleStringToObject(str) { - var styles = {}; - - str.split(';').forEach(function (rule) { - var tuple = rule.split(':').map(function (part) { - return part.trim(); - }); - // Guard against empty touples - if (tuple[0] && tuple[1]) { - styles[tuple[0]] = tuple[1]; - } - }); - - return styles; -} - -function getClassNamesFromAttributeValue(attributeValue) { - if (attributeValue === null) { - return []; - } - - if (attributeValue === '') { - return []; - } - - var classNames = attributeValue.split(/\s+/); - if (classNames.length === 1 && classNames[0] === '') { - classNames.pop(); - } - return classNames; -} - -function isInsideHtmlDocument(node) { - var ownerDocument = node.nodeType === 9 && node.documentElement && node.implementation ? node : node.ownerDocument; - - if (ownerDocument.contentType) { - return ownerDocument.contentType === 'text/html'; - } else { - return ownerDocument.toString() === '[object HTMLDocument]'; - } -} - -function getAttributes(element) { - var isHtml = isInsideHtmlDocument(element); - var attrs = element.attributes; - var result = {}; - - for (var i = 0; i < attrs.length; i += 1) { - if (attrs[i].name === 'class') { - result[attrs[i].name] = attrs[i].value && attrs[i].value.split(' ') || []; - } else if (attrs[i].name === 'style') { - result[attrs[i].name] = styleStringToObject(attrs[i].value); - } else { - result[attrs[i].name] = isHtml && isBooleanAttribute(attrs[i].name) ? true : attrs[i].value || ''; - } - } - - return result; -} - -function entitify(value) { - return String(value).replace(/&/g, '&').replace(/"/g, '"').replace(/'; - } -} - -function ensureSupportedSpecOptions(options) { - var unsupportedOptions = Object.keys(options).filter(function (key) { - return key !== 'attributes' && key !== 'name' && key !== 'children' && key !== 'onlyAttributes' && key !== 'textContent'; - }); - - if (unsupportedOptions.length > 0) { - throw new Error('Unsupported option' + (unsupportedOptions.length === 1 ? '' : 's') + ': ' + unsupportedOptions.join(', ')); - } -} - -module.exports = { - name: 'unexpected-dom', - installInto: function installInto(expect) { - expect = expect.child(); - expect.use(require('magicpen-prism')); - - function bubbleError(body) { - return expect.withError(body, function (err) { - err.errorMode = 'bubble'; - throw err; - }); - } - - expect.exportType({ - name: 'DOMNode', - base: 'object', - identify: function identify(obj) { - return obj && obj.nodeName && [2, 3, 4, 5, 6, 7, 10, 11, 12].indexOf(obj.nodeType) > -1; - }, - equal: function equal(a, b) { - return a.nodeValue === b.nodeValue; - }, - inspect: function inspect(element, depth, output) { - return output.code(element.nodeName + ' "' + element.nodeValue + '"', 'prism-string'); - } - }); - - expect.exportType({ - name: 'DOMComment', - base: 'DOMNode', - identify: function identify(obj) { - return obj && typeof obj.nodeType === 'number' && obj.nodeType === 8; - }, - equal: function equal(a, b) { - return a.nodeValue === b.nodeValue; - }, - inspect: function inspect(element, depth, output) { - return output.code('', 'html'); - }, - diff: function diff(actual, expected, output, _diff, inspect, equal) { - var d = _diff('', ''); - d.inline = true; - return d; - } - }); - - // Recognize as a special subtype of DOMComment so it can be targeted by assertions: - expect.exportType({ - name: 'DOMIgnoreComment', - base: 'DOMComment', - identify: function identify(obj) { - return this.baseType.identify(obj) && /^\s*ignore\s*$/.test(obj.nodeValue); - } - }); - - expect.exportType({ - name: 'DOMTextNode', - base: 'DOMNode', - identify: function identify(obj) { - return obj && typeof obj.nodeType === 'number' && obj.nodeType === 3; - }, - equal: function equal(a, b) { - return a.nodeValue === b.nodeValue; - }, - inspect: function inspect(element, depth, output) { - return output.code(entitify(element.nodeValue.trim()), 'html'); - }, - diff: function diff(actual, expected, output, _diff2, inspect, equal) { - var d = _diff2(actual.nodeValue, expected.nodeValue); - d.inline = true; - return d; - } - }); - - expect.exportType({ - name: 'DOMNodeList', - base: 'array-like', - prefix: function prefix(output) { - return output.text('NodeList['); - }, - suffix: function suffix(output) { - return output.text(']'); - }, - similar: function similar(a, b) { - // Figure out whether a and b are "struturally similar" so they can be diffed inline. - return a.nodeType === 1 && b.nodeType === 1 && a.nodeName === b.nodeName; - }, - identify: function identify(obj) { - return obj && typeof obj.length === 'number' && typeof obj.toString === 'function' && typeof obj.item === 'function' && ( - // With jsdom 6+, nodeList.toString() comes out as '[object Object]', so fall back to the constructor name: - obj.toString().indexOf('NodeList') !== -1 || obj.constructor && obj.constructor.name === 'NodeList'); - } - }); - - // Fake type to make it possible to build 'to satisfy' diffs to be rendered inline: - expect.exportType({ - name: 'attachedDOMNodeList', - base: 'DOMNodeList', - indent: false, - prefix: function prefix(output) { - return output; - }, - suffix: function suffix(output) { - return output; - }, - delimiter: function delimiter(output) { - return output; - }, - identify: function identify(obj) { - return obj && obj._isAttachedDOMNodeList; - } - }); - - function makeAttachedDOMNodeList(domNodeList, contentType) { - var attachedDOMNodeList = []; - for (var i = 0; i < domNodeList.length; i += 1) { - attachedDOMNodeList.push(domNodeList[i]); - } - attachedDOMNodeList._isAttachedDOMNodeList = true; - attachedDOMNodeList.ownerDocument = { contentType: contentType }; - return attachedDOMNodeList; - } - - expect.exportType({ - name: 'HTMLDocType', - base: 'DOMNode', - identify: function identify(obj) { - return obj && typeof obj.nodeType === 'number' && obj.nodeType === 10 && 'publicId' in obj; - }, - inspect: function inspect(doctype, depth, output, _inspect) { - return output.code('', 'html'); - }, - equal: function equal(a, b) { - return a.toString() === b.toString(); - }, - diff: function diff(actual, expected, output, _diff3) { - var d = _diff3('', ''); - d.inline = true; - return d; - } - }); - - expect.exportType({ - name: 'DOMDocument', - base: 'DOMNode', - identify: function identify(obj) { - return obj && typeof obj.nodeType === 'number' && obj.nodeType === 9 && obj.documentElement && obj.implementation; - }, - inspect: function inspect(document, depth, output, _inspect2) { - for (var i = 0; i < document.childNodes.length; i += 1) { - output.append(_inspect2(document.childNodes[i])); - } - return output; - }, - diff: function diff(actual, expected, output, _diff4, inspect, equal) { - output.inline = true; - output.append(_diff4(makeAttachedDOMNodeList(actual.childNodes), makeAttachedDOMNodeList(expected.childNodes))); - return output; - } - }); - - expect.exportType({ - name: 'HTMLDocument', - base: 'DOMDocument', - identify: function identify(obj) { - return this.baseType.identify(obj) && isInsideHtmlDocument(obj); - } - }); - - expect.exportType({ - name: 'XMLDocument', - base: 'DOMDocument', - identify: function identify(obj) { - return this.baseType.identify(obj) && !isInsideHtmlDocument(obj); - }, - inspect: function inspect(document, depth, output, _inspect3) { - output.code('', 'xml'); - for (var i = 0; i < document.childNodes.length; i += 1) { - output.append(_inspect3(document.childNodes[i], depth - 1)); - } - return output; - } - }); - - expect.exportType({ - name: 'DOMDocumentFragment', - base: 'DOMNode', - identify: function identify(obj) { - return obj && obj.nodeType === 11; // In jsdom, documentFragment.toString() does not return [object DocumentFragment] - }, - inspect: function inspect(documentFragment, depth, output, _inspect4) { - return output.text('DocumentFragment[').append(_inspect4(documentFragment.childNodes, depth)).text(']'); - }, - diff: function diff(actual, expected, output, _diff5, inspect, equal) { - output.inline = true; - output.block(_diff5(makeAttachedDOMNodeList(actual.childNodes), makeAttachedDOMNodeList(expected.childNodes))); - return output; - } - }); - - expect.exportType({ - name: 'DOMElement', - base: 'DOMNode', - identify: function identify(obj) { - return obj && typeof obj.nodeType === 'number' && obj.nodeType === 1 && obj.nodeName && obj.attributes; - }, - equal: function equal(a, b, _equal) { - var aIsHtml = isInsideHtmlDocument(a); - var bIsHtml = isInsideHtmlDocument(b); - return aIsHtml === bIsHtml && (aIsHtml ? a.nodeName.toLowerCase() === b.nodeName.toLowerCase() : a.nodeName === b.nodeName) && _equal(getAttributes(a), getAttributes(b)) && _equal(a.childNodes, b.childNodes); - }, - inspect: function inspect(element, depth, output, _inspect5) { - var elementName = element.nodeName.toLowerCase(); - var startTag = stringifyStartTag(element); - - output.code(startTag, 'html'); - if (element.childNodes.length > 0) { - if (depth === 1) { - output.text('...'); - } else { - var inspectedChildren = []; - if (elementName === 'script') { - var type = element.getAttribute('type'); - if (!type || /javascript/.test(type)) { - type = 'javascript'; - } - inspectedChildren.push(output.clone().code(element.textContent, type)); - } else if (elementName === 'style') { - inspectedChildren.push(output.clone().code(element.textContent, element.getAttribute('type') || 'text/css')); - } else { - for (var i = 0; i < element.childNodes.length; i += 1) { - inspectedChildren.push(_inspect5(element.childNodes[i])); - } - } - - var width = startTag.length; - var multipleLines = inspectedChildren.some(function (o) { - var size = o.size(); - width += size.width; - return width > 60 || o.height > 1; - }); - - if (multipleLines) { - output.nl().indentLines(); - - inspectedChildren.forEach(function (inspectedChild, index) { - output.i().block(inspectedChild).nl(); - }); - - output.outdentLines(); - } else { - inspectedChildren.forEach(function (inspectedChild, index) { - return output.append(inspectedChild); - }); - } - } - } - output.code(stringifyEndTag(element), 'html'); - return output; - }, - - diffLimit: 512, - diff: function diff(actual, expected, output, _diff6, inspect, equal) { - var isHtml = isInsideHtmlDocument(actual); - output.inline = true; - - if (Math.max(actual.length, expected.length) > this.diffLimit) { - output.jsComment('Diff suppressed due to size > ' + this.diffLimit); - return output; - } - - var emptyElements = actual.childNodes.length === 0 && expected.childNodes.length === 0; - var conflictingElement = actual.nodeName.toLowerCase() !== expected.nodeName.toLowerCase() || !equal(getAttributes(actual), getAttributes(expected)); - - if (conflictingElement) { - var canContinueLine = true; - output.prismPunctuation('<').prismTag(actual.nodeName.toLowerCase()); - if (actual.nodeName.toLowerCase() !== expected.nodeName.toLowerCase()) { - output.sp().annotationBlock(function (output) { - return output.error('should be').sp().prismTag(expected.nodeName.toLowerCase()); - }).nl(); - canContinueLine = false; - } - var actualAttributes = getAttributes(actual); - var expectedAttributes = getAttributes(expected); - Object.keys(actualAttributes).forEach(function (attributeName) { - output.sp(canContinueLine ? 1 : 2 + actual.nodeName.length); - writeAttributeToMagicPen(output, attributeName, actualAttributes[attributeName], isHtml); - if (attributeName in expectedAttributes) { - if (actualAttributes[attributeName] === expectedAttributes[attributeName]) { - canContinueLine = true; - } else { - output.sp().annotationBlock(function (output) { - return output.error('should equal').sp().append(inspect(entitify(expectedAttributes[attributeName]))); - }).nl(); - canContinueLine = false; - } - delete expectedAttributes[attributeName]; - } else { - output.sp().annotationBlock(function (output) { - return output.error('should be removed'); - }).nl(); - canContinueLine = false; - } - }); - Object.keys(expectedAttributes).forEach(function (attributeName) { - output.sp(canContinueLine ? 1 : 2 + actual.nodeName.length); - output.annotationBlock(function (output) { - output.error('missing').sp(); - writeAttributeToMagicPen(output, attributeName, expectedAttributes[attributeName], isHtml); - }).nl(); - canContinueLine = false; - }); - output.prismPunctuation('>'); - } else { - output.code(stringifyStartTag(actual), 'html'); - } - - if (!emptyElements) { - output.nl().indentLines().i().block(_diff6(makeAttachedDOMNodeList(actual.childNodes), makeAttachedDOMNodeList(expected.childNodes))).nl().outdentLines(); - } - - output.code(stringifyEndTag(actual), 'html'); - return output; - } - }); - - expect.exportAssertion(' to have (class|classes) ', function (expect, subject, value) { - return expect(subject, 'to have attributes', { class: value }); - }); - - expect.exportAssertion(' to only have (class|classes) ', function (expect, subject, value) { - return expect(subject, 'to have attributes', { - class: expect.it(function (className) { - var actualClasses = getClassNamesFromAttributeValue(className); - if (typeof value === 'string') { - value = getClassNamesFromAttributeValue(value); - } - return bubbleError(function () { - return expect(actualClasses.sort(), 'to equal', value.sort()); - }); - }) - }); - }); - - expect.exportAssertion(' not to have (class|classes) ', function (expect, subject, value) { - return expect(subject, 'to have attributes', { - class: expect.it(function (className) { - var actualClasses = getClassNamesFromAttributeValue(className); - var expectedClasses = void 0; - if (typeof value === 'string') { - expectedClasses = getClassNamesFromAttributeValue(value); - } else { - expectedClasses = value; - } - return bubbleError(function () { - return expect.apply(undefined, [actualClasses, 'not to contain'].concat(_toConsumableArray(expectedClasses))); - }); - }) - }); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - return expect(subject.nodeValue, 'to equal', value.nodeValue); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - return expect(subject.nodeValue, 'to equal', value.nodeValue); - }); - - // Avoid rendering a huge object diff when a text node is matched against a different node type: - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - return expect.fail(); - }); - - // Always passes: - expect.exportAssertion( - // Name each subject type to increase the specificity of the assertion - ' to [exhaustively] satisfy ', function (expect, subject, value) {}); - - // Necessary because this case would otherwise be handled by the above catch-all for : - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, _ref, value) { - var nodeValue = _ref.nodeValue; - return expect(nodeValue, 'to satisfy', value); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, _ref2, value) { - var nodeValue = _ref2.nodeValue; - return expect(nodeValue, 'to satisfy', value); - }); - - function convertDOMNodeToSatisfySpec(node, isHtml) { - if (node.nodeType === 10) { - // HTMLDocType - return { name: node.nodeName }; - } else if (node.nodeType === 1) { - // DOMElement - var name = isHtml ? node.nodeName.toLowerCase() : node.nodeName; - - var result = { name: name }; - - if (node.attributes) { - result.attributes = {}; - for (var i = 0; i < node.attributes.length; i += 1) { - result.attributes[node.attributes[i].name] = isHtml && isBooleanAttribute(node.attributes[i].name) ? true : node.attributes[i].value || ''; - } - } - result.children = Array.prototype.map.call(node.childNodes, function (childNode) { - return convertDOMNodeToSatisfySpec(childNode, isHtml); - }); - return result; - } else if (node.nodeType === 3) { - // DOMTextNode - return node.nodeValue; - } else if (node.nodeType === 8) { - // DOMComment - return node; - } else { - throw new Error('to satisfy: Node type ' + node.nodeType + ' is not yet supported in the value'); - } - } - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - - expect.argsOutput = function (output) { - return output.code(value, isHtml ? 'html' : 'xml'); - }; - - return expect(subject, 'to [exhaustively] satisfy', (isHtml ? parseHtml(value, true) : parseXml(value)).childNodes); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - var satisfySpecs = []; - for (var i = 0; i < value.length; i += 1) { - satisfySpecs.push(convertDOMNodeToSatisfySpec(value[i], isHtml)); - } - return expect(subject, 'to [exhaustively] satisfy', satisfySpecs); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - - expect.argsOutput = function (output) { - return output.code(value, isHtml ? 'html' : 'xml'); - }; - - return expect(subject, 'to [exhaustively] satisfy', isHtml ? parseHtml(value, true) : parseXml(value)); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, _ref3) { - var childNodes = _ref3.childNodes; - - var isHtml = isInsideHtmlDocument(subject); - return expect(subject, 'to [exhaustively] satisfy', Array.prototype.map.call(childNodes, function (childNode) { - return convertDOMNodeToSatisfySpec(childNode, isHtml); - })); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, _ref4, value) { - var childNodes = _ref4.childNodes; - return expect(childNodes, 'to [exhaustively] satisfy', value); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - var documentFragment = isHtml ? parseHtml(value, true) : parseXml(value); - if (documentFragment.childNodes.length !== 1) { - throw new Error('HTMLElement to satisfy string: Only a single node is supported'); - } - - expect.argsOutput = function (output) { - return output.code(value, isHtml ? 'html' : 'xml'); - }; - - return expect(subject, 'to [exhaustively] satisfy', documentFragment.childNodes[0]); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - var valueDocument = isHtml ? parseHtml(value, false) : parseXml(value); - return expect(makeAttachedDOMNodeList(subject.childNodes), 'to [exhaustively] satisfy', Array.prototype.map.call(valueDocument.childNodes, function (childNode) { - return convertDOMNodeToSatisfySpec(childNode, isHtml); - })); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, _ref5) { - var childNodes = _ref5.childNodes; - - var isHtml = isInsideHtmlDocument(subject); - return expect(makeAttachedDOMNodeList(subject.childNodes), 'to [exhaustively] satisfy', Array.prototype.map.call(childNodes, function (childNode) { - return convertDOMNodeToSatisfySpec(childNode, isHtml); - })); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - return expect(subject, 'to [exhaustively] satisfy', convertDOMNodeToSatisfySpec(value, isInsideHtmlDocument(subject))); - }); - - expect.exportAssertion([' to [exhaustively] satisfy ', ' to [exhaustively] satisfy ', ' to [exhaustively] satisfy '], function (expect, subject, value) { - return expect.fail(); - }); - - expect.exportAssertion(' to [exhaustively] satisfy ', function (expect, subject, value) { - var isHtml = isInsideHtmlDocument(subject); - ensureSupportedSpecOptions(value); - - var promiseByKey = { - name: expect.promise(function () { - if (value && typeof value.name !== 'undefined') { - return bubbleError(function () { - return expect(isHtml ? subject.nodeName.toLowerCase() : subject.nodeName, 'to satisfy', value.name); - }); - } - }), - children: expect.promise(function () { - if (typeof value.children !== 'undefined') { - if (typeof value.textContent !== 'undefined') { - throw new Error('The children and textContent properties are not supported together'); - } - - var contentType = subject.ownerDocument.contentType; - if (!contentType) { - // provide a value in the absence of a contentType (IE11) - contentType = isInsideHtmlDocument(subject) ? 'text/html' : 'application/xml'; - } - - return bubbleError(function () { - return expect(makeAttachedDOMNodeList(subject.childNodes, contentType), 'to satisfy', value.children); - }); - } else if (typeof value.textContent !== 'undefined') { - return bubbleError(function () { - return expect(subject.textContent, 'to satisfy', value.textContent); - }); - } - }), - attributes: {} - }; - - var onlyAttributes = value && value.onlyAttributes || expect.flags.exhaustively; - var attrs = getAttributes(subject); - var expectedAttributes = value && value.attributes; - var expectedAttributeNames = []; - var expectedValueByAttributeName = {}; - - if (typeof expectedAttributes !== 'undefined') { - if (typeof expectedAttributes === 'string') { - expectedAttributes = [expectedAttributes]; - } - if (Array.isArray(expectedAttributes)) { - expectedAttributes.forEach(function (attributeName) { - expectedValueByAttributeName[attributeName] = true; - }); - } else if (expectedAttributes && (typeof expectedAttributes === 'undefined' ? 'undefined' : _typeof(expectedAttributes)) === 'object') { - expectedValueByAttributeName = expectedAttributes; - } - Object.keys(expectedValueByAttributeName).forEach(function (attributeName) { - expectedAttributeNames.push(attributeName); - }); - - expectedAttributeNames.forEach(function (attributeName) { - var attributeValue = subject.getAttribute(attributeName); - var expectedAttributeValue = expectedValueByAttributeName[attributeName]; - promiseByKey.attributes[attributeName] = expect.promise(function () { - if (typeof expectedAttributeValue === 'undefined') { - return bubbleError(function () { - return expect(subject.hasAttribute(attributeName), 'to be false'); - }); - } else if (isEnumeratedAttribute(attributeName)) { - var indexOfEnumeratedAttributeValue = enumeratedAttributeValues[attributeName].indexOf(expectedAttributeValue); - - return bubbleError(function () { - if (indexOfEnumeratedAttributeValue === -1) { - expect.fail(function (output) { - return output.text('Invalid expected value ').appendInspected(expectedAttributeValue).text('. Supported values include: ').appendItems(enumeratedAttributeValues[attributeName], ', '); - }); - } - - expect(attributeValue, 'to satisfy', expectedAttributeValue); - }); - } else if (expectedAttributeValue === true) { - return bubbleError(function () { - return expect(subject.hasAttribute(attributeName), 'to be true'); - }); - } else if (attributeName === 'class' && (typeof expectedAttributeValue === 'string' || Array.isArray(expectedAttributeValue))) { - var actualClasses = getClassNamesFromAttributeValue(attributeValue); - var expectedClasses = expectedAttributeValue; - if (typeof expectedClasses === 'string') { - expectedClasses = getClassNamesFromAttributeValue(expectedAttributeValue); - } - if (onlyAttributes) { - return bubbleError(function () { - return expect(actualClasses.sort(), 'to equal', expectedClasses.sort()); - }); - } else { - if (expectedClasses.length === 0) { - return bubbleError(function () { - return expect(expectedClasses, 'to be empty'); - }); - } - return bubbleError(function () { - return expect.apply(undefined, [actualClasses, 'to contain'].concat(_toConsumableArray(expectedClasses))); - }); - } - } else if (attributeName === 'style') { - var expectedStyleObj = void 0; - if (typeof expectedValueByAttributeName.style === 'string') { - validateStyles(expect, expectedValueByAttributeName.style); - expectedStyleObj = styleStringToObject(expectedValueByAttributeName.style); - } else { - expectedStyleObj = expectedValueByAttributeName.style; - } - - if (onlyAttributes) { - return bubbleError(function () { - return expect(attrs.style, 'to exhaustively satisfy', expectedStyleObj); - }); - } else { - return bubbleError(function () { - return expect(attrs.style, 'to satisfy', expectedStyleObj); - }); - } - } else if (expect.findTypeOf(expectedAttributeValue).is('expect.it')) { - expect.context.thisObject = subject; - return bubbleError(function () { - return expectedAttributeValue(attributeValue, expect.context); - }); - } else { - return bubbleError(function () { - return expect(attributeValue, 'to satisfy', expectedAttributeValue); - }); - } - }); - }); - - promiseByKey.attributePresence = expect.promise(function () { - var attributeNamesExpectedToBeDefined = []; - expectedAttributeNames.forEach(function (attributeName) { - if (typeof expectedValueByAttributeName[attributeName] === 'undefined') { - expect(attrs, 'not to have key', attributeName); - } else { - attributeNamesExpectedToBeDefined.push(attributeName); - expect(attrs, 'to have key', attributeName); - } - }); - if (onlyAttributes) { - expect(Object.keys(attrs).sort(), 'to equal', attributeNamesExpectedToBeDefined.sort()); - } - }); - } - - return expect.promise.all(promiseByKey).caught(function () { - return expect.promise.settle(promiseByKey).then(function () { - expect.fail({ - diff: function diff(output, _diff7, inspect, equal) { - output.block(function (output) { - var seenError = false; - output.prismPunctuation('<').prismTag(isHtml ? subject.nodeName.toLowerCase() : subject.nodeName); - if (promiseByKey.name.isRejected()) { - seenError = true; - var nameError = promiseByKey.name.reason(); - output.sp().annotationBlock(function (output) { - return output.error(nameError && nameError.getLabel() || 'should satisfy').sp().append(inspect(value.name)); - }); - } - var inspectedAttributes = []; - Object.keys(attrs).forEach(function (attributeName) { - var attributeOutput = output.clone(); - var promise = promiseByKey.attributes[attributeName]; - writeAttributeToMagicPen(attributeOutput, attributeName, attrs[attributeName], isHtml); - if (promise && promise.isFulfilled() || !promise && (!onlyAttributes || expectedAttributeNames.indexOf(attributeName) !== -1)) {} else { - seenError = true; - attributeOutput.sp().annotationBlock(function (output) { - if (promise && typeof expectedValueByAttributeName[attributeName] !== 'undefined') { - output.appendErrorMessage(promise.reason()); - } else { - // onlyAttributes === true - output.error('should be removed'); - } - }); - } - inspectedAttributes.push(attributeOutput); - }); - expectedAttributeNames.forEach(function (attributeName) { - if (!subject.hasAttribute(attributeName)) { - var promise = promiseByKey.attributes[attributeName]; - if (!promise || promise.isRejected()) { - seenError = true; - var err = promise && promise.reason(); - var attributeOutput = output.clone().annotationBlock(function (output) { - output.error('missing').sp().prismAttrName(attributeName, 'html'); - if (expectedValueByAttributeName[attributeName] !== true) { - output.sp().error(err && err.getLabel() || 'should satisfy').sp().append(inspect(expectedValueByAttributeName[attributeName])); - } - }); - inspectedAttributes.push(attributeOutput); - } - } - }); - if (inspectedAttributes.length > 0) { - if (seenError) { - output.nl().indentLines().indent().block(function (output) { - inspectedAttributes.forEach(function (item, i) { - if (i > 0) { - output.nl(); - } - output.append(item); - }); - }).outdentLines().nl(); - } else { - output.sp(); - inspectedAttributes.forEach(function (item, i) { - if (i > 0) { - output.sp(); - } - output.append(item); - }); - } - } else if (seenError) { - // The tag name mismatched - output.nl(); - } - - output.prismPunctuation('>'); - var childrenError = promiseByKey.children.isRejected() && promiseByKey.children.reason(); - if (childrenError) { - var childrenDiff = childrenError.getDiff(output); - if (childrenDiff && childrenDiff.inline) { - output.nl().indentLines().i().block(childrenDiff).nl().outdentLines(); - } else { - output.nl().indentLines().i().block(function (output) { - for (var i = 0; i < subject.childNodes.length; i += 1) { - output.append(inspect(subject.childNodes[i])).nl(); - } - }); - output.sp().annotationBlock(function (output) { - return output.appendErrorMessage(childrenError); - }); - output.nl(); - } - } else { - for (var i = 0; i < subject.childNodes.length; i += 1) { - output.append(inspect(subject.childNodes[i])); - } - } - output.code(stringifyEndTag(subject), 'html'); - }); - output.inline = true; - return output; - } - }); - }); - }); - }); - - expect.exportAssertion(' to [only] have (attribute|attributes) ', function (expect, subject) { - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - return expect(subject, 'to [only] have attributes', args); - }); - - expect.exportAssertion(' not to have (attribute|attributes) ', function (expect, subject, value) { - var attributes = getAttributes(subject); - - value.forEach(function (name) { - delete attributes[name]; - }); - - return expect(subject, 'to only have attributes', attributes); - }); - - expect.exportAssertion(' not to have (attribute|attributes) ', function (expect, subject) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { - args[_key2 - 2] = arguments[_key2]; - } - - return expect(subject, 'not to have attributes', args); - }); - - expect.exportAssertion(' to [only] have (attribute|attributes) ', function (expect, subject, value) { - return expect(subject, 'to satisfy', { - attributes: value, - onlyAttributes: expect.flags.only - }); - }); - - expect.exportAssertion(' to have [no] (child|children)', function (expect, _ref6) { - var childNodes = _ref6.childNodes; - return expect.flags.no ? expect(childNodes, 'to be empty') : expect(childNodes, 'not to be empty'); - }); - - expect.exportAssertion(' to have text ', function (expect, _ref7, value) { - var textContent = _ref7.textContent; - return expect(textContent, 'to satisfy', value); - }); - - expect.exportAssertion(' [when] queried for [first] ', function (expect, subject, query) { - var queryResult = void 0; - - expect.argsOutput[0] = function (output) { - return output.green(query); - }; - expect.errorMode = 'nested'; - - if (expect.flags.first) { - queryResult = subject.querySelector(query); - if (!queryResult) { - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - - expect.fail(function (output) { - return output.error('The selector').sp().jsString(query).sp().error('yielded no results'); - }); - } - } else { - queryResult = subject.querySelectorAll(query); - if (queryResult.length === 0) { - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - - expect.fail(function (output) { - return output.error('The selector').sp().jsString(query).sp().error('yielded no results'); - }); - } - } - return expect.shift(queryResult); - }); - - expect.exportAssertion(' to contain [no] elements matching ', function (expect, subject, query) { - if (expect.flags.no) { - return expect(subject.querySelectorAll(query), 'to satisfy', []); - } - - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - - return expect(subject.querySelectorAll(query), 'not to satisfy', []); - }); - - expect.exportAssertion(' [not] to match ', function (expect, subject, query) { - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - - return expect(matchesSelector(subject, query), '[not] to be true'); - }); - - expect.exportAssertion(' [when] parsed as (html|HTML) [fragment] ', function (expect, subject) { - expect.errorMode = 'nested'; - return expect.shift(parseHtml(subject, expect.flags.fragment)); - }); - - expect.exportAssertion(' [when] parsed as (xml|XML) ', function (expect, subject) { - expect.errorMode = 'nested'; - return expect.shift(parseXml(subject)); - }); - - function scoreElementAgainstSpec(element, spec) { - var isTextSimilar = function isTextSimilar(value, valueSpec) { - var actual = (value || '').trim().toLowerCase(); - if (typeof valueSpec === 'string') { - if (actual === valueSpec.trim().toLowerCase()) { - return true; - } - } else if (valueSpec instanceof RegExp) { - if (valueSpec.test(actual)) { - return true; - } - } else if (typeof valueSpec === 'function') { - return true; - } - - return false; - }; - - var isHtml = isInsideHtmlDocument(element); - - var score = 0; - - var nodeName = isHtml ? element.nodeName.toLowerCase() : element.nodeName; - - if (isTextSimilar(nodeName, spec.name)) { - score++; - } - - if (isTextSimilar(element.textContent, spec.textContent)) { - score++; - } - - if (typeof element.hasAttribute === 'function') { - var attributes = spec.attributes || {}; - var className = attributes['class']; - var style = attributes.style; - - if (className && element.hasAttribute('class')) { - if (typeof className === 'string') { - var expectedClasses = getClassNamesFromAttributeValue(className); - var actualClasses = getClassNamesFromAttributeValue(element.getAttribute('class')); - - expectedClasses.forEach(function (expectedClass) { - if (actualClasses.indexOf(expectedClass) !== -1) { - score++; - } - }); - } else if (isTextSimilar(element.getAttribute('class'), className)) { - score++; - } - } - - if (style && element.hasAttribute('style')) { - var expectedStyles = typeof style === 'string' ? styleStringToObject(style) : style; - var actualStyles = styleStringToObject(element.getAttribute('style')); - - Object.keys(expectedStyles).forEach(function (styleName) { - var expectedStyle = expectedStyles[styleName]; - var actualStyle = actualStyles[styleName]; - - if (actualStyle) { - score++; - } - - if (isTextSimilar(actualStyle, expectedStyle)) { - score++; - } - }); - } - - var specialAttributes = ['style', 'class']; - var ids = ['id', 'data-test-id', 'data-testid']; - - Object.keys(attributes).forEach(function (attributeName) { - if (specialAttributes.indexOf(attributeName) !== -1) { - return; // skip - } - - if (element.hasAttribute(attributeName)) { - if (typeof attributes[attributeName] === 'boolean') { - score++; - } - - if (element.getAttribute(attributeName) === attributes[attributeName]) { - score += ids.indexOf(attributeName) === -1 ? 1 : 100; - } - } else if (typeof attributes[attributeName] === 'undefined') { - score++; - } - }); - } - - var expectedChildren = spec.children || []; - - expectedChildren.forEach(function (childSpec, i) { - var child = element.childNodes[i]; - var childType = expect.findTypeOf(child); - - if (!child) { - return; - } - - if (typeof childSpec.nodeType === 'number') { - if (child.nodeType === childSpec.nodeType) { - if (childType.is('DOMElement')) { - // Element - score += scoreElementAgainstSpec(element.childNodes[i], convertDOMNodeToSatisfySpec(childSpec)); - } - - score++; - } else if (expect.findTypeOf(childSpec).is('DOMIgnoreComment')) { - score++; - } - } else if (childType.is('DOMElement') && (typeof childSpec === 'undefined' ? 'undefined' : _typeof(childSpec)) === 'object') { - score += scoreElementAgainstSpec(element.childNodes[i], childSpec); - } else if (childType.is('DOMTextNode') && isTextSimilar(child.nodeValue, childSpec)) { - score++; - } - }); - - return score; - } - - function findMatchesWithGoodScore(data, spec) { - var elements = typeof data.length === 'number' ? Array.prototype.slice.call(data) : [data]; - - var result = []; - var bestScore = 0; - - elements.forEach(function (element) { - var score = scoreElementAgainstSpec(element, spec); - bestScore = Math.max(score, bestScore); - - if (score > 0 && score >= bestScore) { - result.push({ score: score, element: element }); - } - - for (var i = 0; i < element.childNodes.length; i += 1) { - var child = element.childNodes[i]; - if (child.nodeType === 1) { - result.push.apply(result, _toConsumableArray(findMatchesWithGoodScore(child, spec))); - } - } - }); - - result.sort(function (a, b) { - return b.score - a.score; - }); - - if (result.length > 0) { - var _bestScore = result[0].score; - - return result.filter(function (_ref8) { - var score = _ref8.score; - return score === _bestScore; - }); - } - - return result; - } - - expect.exportAssertion(' [not] to contain ', function (expect, subject, value) { - var nodes = subject.childNodes || makeAttachedDOMNodeList(subject); - var isHtml = isInsideHtmlDocument(subject.childNodes ? subject : nodes); - var valueType = expect.findTypeOf(value); - var spec = value; - - if (valueType.is('DOMElement')) { - spec = convertDOMNodeToSatisfySpec(value, isHtml); - } else if (valueType.is('string')) { - var documentFragment = isHtml ? parseHtml(value, true) : parseXml(value); - - if (documentFragment.childNodes.length !== 1) { - throw new Error('HTMLElement to contain string: Only a single node is supported'); - } - - spec = convertDOMNodeToSatisfySpec(documentFragment.childNodes[0], isHtml); - - if (typeof spec === 'string') { - throw new Error('HTMLElement to contain string: please provide a HTML structure as a string'); - } - - expect.argsOutput = function (output) { - return output.appendInspected(documentFragment.childNodes[0]); - }; - - ensureSupportedSpecOptions(spec); - } - - var scoredElements = findMatchesWithGoodScore(nodes, spec); - - if (expect.flags.not) { - if (scoredElements.length > 0) { - return expect.withError(function () { - return expect(scoredElements.map(function (_ref9) { - var element = _ref9.element; - return element; - }), 'not to have an item satisfying', spec); - }, function () { - var bestMatch = scoredElements[0].element; - - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - - expect.fail({ - diff: function diff(output, _diff8, inspect, equal) { - return output.error('Found:').nl(2).appendInspected(bestMatch); - } - }); - }); - } - } else { - if (scoredElements.length === 0) { - expect.subjectOutput = function (output) { - return expect.inspect(subject, Infinity, output); - }; - expect.fail(); - } - - return expect.withError(function () { - return expect(scoredElements.map(function (_ref10) { - var element = _ref10.element; - return element; - }), 'to have an item satisfying', spec); - }, function () { - var bestMatch = scoredElements[0].element; - - return expect(bestMatch, 'to satisfy', spec); - }); - } - }); - } -}; -},{"./matchesSelector":2,"magicpen-prism":3}],2:[function(require,module,exports){ -module.exports = function (elm, selector) { - var matchFuntion = elm.matchesSelector || elm.mozMatchesSelector || elm.msMatchesSelector || elm.oMatchesSelector || elm.webkitMatchesSelector || function (selector) { - var node = this; - var nodes = (node.parentNode || node.document).querySelectorAll(selector); - var i = 0; - - while (nodes[i] && nodes[i] !== node) { - i += 1; - } - - return !!nodes[i]; - }; - - return matchFuntion.call(elm, selector); -}; -},{}],3:[function(require,module,exports){ -(function (global){ -var oldPrismGlobal = global.Prism; -var prism = (global.Prism = require('prismjs')); -require('prismjs/components/prism-graphql.js'); -require('prismjs/components/prism-csp.js'); -global.Prism = oldPrismGlobal; - -var defaultTheme = { - // Adapted from the default Prism theme: - prismComment: '#708090', // slategray - prismProlog: 'prismComment', - prismDoctype: 'prismComment', - prismCdata: 'prismComment', - - prismPunctuation: '#999', - - prismSymbol: '#905', - prismProperty: 'prismSymbol', - prismTag: 'prismSymbol', - prismBoolean: 'prismSymbol', - prismNumber: 'prismSymbol', - prismConstant: 'prismSymbol', - prismDeleted: 'prismSymbol', - - prismString: '#690', - prismSelector: 'prismString', - prismAttrName: 'prismString', - prismChar: 'prismString', - prismBuiltin: 'prismString', - prismInserted: 'prismString', - - prismOperator: '#a67f59', - prismVariable: 'prismOperator', - prismEntity: 'prismOperator', - prismUrl: 'prismOperator', - prismCssString: 'prismOperator', - - prismKeyword: '#07a', - prismAtrule: 'prismKeyword', - prismAttrValue: 'prismKeyword', - - prismFunction: '#DD4A68', - - prismRegex: '#e90', - prismImportant: ['#e90', 'bold'] -}; - -var languageMapping = { - 'text/html': 'markup', - 'application/xml': 'markup', - 'text/xml': 'markup', - 'application/json': 'javascript', - 'text/javascript': 'javascript', - 'application/javascript': 'javascript', - 'text/css': 'css', - html: 'markup', - xml: 'markup', - c: 'clike', - 'c++': 'clike', - cpp: 'clike', - 'c#': 'clike', - java: 'clike', - 'application/graphql': 'graphql' -}; - -function upperCamelCase(str) { - return str.replace(/(?:^|-)([a-z])/g, function($0, ch) { - return ch.toUpperCase(); - }); -} - -module.exports = { - name: 'magicpen-prism', - version: require('../package.json').version, - installInto: function(magicPen) { - Object.keys(defaultTheme).forEach(function(styleName) { - var style = defaultTheme[styleName]; - while (typeof style === 'string' && style in defaultTheme) { - style = defaultTheme[style]; - } - magicPen.addStyle(styleName, function(text) { - this.text(text, style); - }); - }); - - magicPen.addStyle( - 'code', - function(sourceText, language) { - if (language in languageMapping) { - language = languageMapping[language]; - } else if (/\+xml\b/.test(language)) { - language = 'markup'; - } - if (!(language in prism.languages)) { - return this.text(sourceText); - } - var that = this; - var capitalizedLanguage = upperCamelCase(language); - var languageDefinition = prism.languages[language]; - - function printTokens(token, parentStyle) { - if (Array.isArray(token)) { - token.forEach(function(subToken) { - printTokens(subToken, parentStyle); - }); - } else if (typeof token === 'string') { - var upperCamelCasedParentStyle = upperCamelCase(parentStyle); - token = token.replace(/</g, '<'); - if ( - that['prism' + capitalizedLanguage + upperCamelCasedParentStyle] - ) { - that['prism' + capitalizedLanguage + upperCamelCasedParentStyle]( - token - ); - } else if (that['prism' + upperCamelCasedParentStyle]) { - that['prism' + upperCamelCasedParentStyle](token); - } else if ( - languageDefinition[parentStyle] && - languageDefinition[parentStyle].alias - ) { - printTokens(token, languageDefinition[parentStyle].alias); - } else { - that.text(token); - } - } else { - printTokens(token.content, token.type); - } - } - printTokens( - prism.tokenize(sourceText, prism.languages[language]), - 'text' - ); - }, - true - ); - } -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - -},{"../package.json":4,"prismjs":7,"prismjs/components/prism-csp.js":5,"prismjs/components/prism-graphql.js":6}],4:[function(require,module,exports){ -module.exports={ - "_args": [ - [ - { - "raw": "magicpen-prism@^3.0.1", - "scope": null, - "escapedName": "magicpen-prism", - "name": "magicpen-prism", - "rawSpec": "^3.0.1", - "spec": ">=3.0.1 <4.0.0", - "type": "range" - }, - "/Users/alex/Documents/projects/unexpected-dom" - ] - ], - "_from": "magicpen-prism@>=3.0.1 <4.0.0", - "_hasShrinkwrap": false, - "_id": "magicpen-prism@3.0.1", - "_inCache": true, - "_location": "/magicpen-prism", - "_nodeVersion": "10.15.1", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/magicpen-prism_3.0.1_1552750340750_0.6047691017808081" - }, - "_npmUser": { - "name": "papandreou", - "email": "andreaslindpetersen@gmail.com" - }, - "_npmVersion": "6.4.1", - "_phantomChildren": {}, - "_requested": { - "raw": "magicpen-prism@^3.0.1", - "scope": null, - "escapedName": "magicpen-prism", - "name": "magicpen-prism", - "rawSpec": "^3.0.1", - "spec": ">=3.0.1 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/" - ], - "_resolved": "https://registry.npmjs.org/magicpen-prism/-/magicpen-prism-3.0.1.tgz", - "_shasum": "5bf516bb9f8b0fd889548ca452c863cb30e843a1", - "_shrinkwrap": null, - "_spec": "magicpen-prism@^3.0.1", - "_where": "/Users/alex/Documents/projects/unexpected-dom", - "author": { - "name": "Andreas Lind", - "email": "andreaslindpetersen@gmail.com" - }, - "bugs": { - "url": "https://github.com/unexpectedjs/magicpen-prism/issues" - }, - "dependencies": { - "prismjs": "^1.15.0" - }, - "description": "Add syntax highlighting support to magicpen via prism.js", - "devDependencies": { - "browserify": "^16.2.3", - "bundle-collapser": "^1.3.0", - "coveralls": "^3.0.3", - "eslint": "^5.7.0", - "eslint-config-prettier": "^4.1.0", - "eslint-config-standard": "^12.0.0", - "eslint-plugin-import": "^2.16.0", - "eslint-plugin-mocha": "^5.3.0", - "eslint-plugin-node": "^8.0.1", - "eslint-plugin-promise": "^4.0.1", - "eslint-plugin-standard": "^4.0.0", - "magicpen": "^6.0.2", - "mocha": "^6.0.2", - "nyc": "^13.3.0", - "prettier": "^1.16.4", - "unexpected": "^11.2.0" - }, - "directories": {}, - "dist": { - "integrity": "sha512-BNV59p+oTWFF6Pw19QnBEGYV3W6pqRToGIGklXm0RQlE6M9SdLUPhd0QKlPln7LPrEnHvo9E1fPnW0OXJomRXw==", - "shasum": "5bf516bb9f8b0fd889548ca452c863cb30e843a1", - "tarball": "https://registry.npmjs.org/magicpen-prism/-/magicpen-prism-3.0.1.tgz", - "fileCount": 4, - "unpackedSize": 35339, - "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcjRcFCRA9TVsSAnZWagAA8rYP/3IN5mSBhOVXBTrb8sk9\nZ1BGaIzg0KdrYyEUm4S1njN8lfqenakc14MDRAD4huFMDH+TWpSdbKX5qj5x\nzoBqQK6H0XlQdQ5vag3pONBz9OGU6mxqjM4pnhogYDWV0SlXjyXuc3PSvQ6H\nRKyJrH7HwSV5gu7DDY9a0gsajXU4Ah6pER/HNGQXZCWESVduwa4EYzk1sqBx\njNvAQxUFfRYcSiVVwfo2ftBE6Muq7/DAyFUFJz8eblFSX4kB5+uopmVHyFEX\ntbhfl1Qyxszrmr/rDuzNi5gecG4tauF6/D3NCtMxR1NOxcsSv2MJiz3FoqT2\nUmKTn+P/Pb7GLNcj73mPF2s6wDXBBrytJR8pIOMD22yV3ZZH0PqD4DsQvjHK\nYnSp+kLVSeB7NdALB+xNVFxRg2fg6rE8CiQJzFt/v+MUsDdMX0sqRGe9n9Eo\nzIASOAJTrbXfC9Ulf01C1mGSbrN779fkKF9tC9k7W+NXziI0EKjn/r8AXe75\nSOXAEVmvafI+35WUlHn1/ho97O3wr+pngEFOERpEX1+NSIbOanSww3LnrLW+\njMEIGGj7N3q7m4zAZdn4giYjekVewLoGMTF9oCzIOcWsYqcbKeVRSFB9YyPt\nOqSkAK8yg2ygtKAgq5+ubXJFxmA6zcT07Zd9GVrUqM94xveCzsUxAtR2NUqG\nVcH0\r\n=evAJ\r\n-----END PGP SIGNATURE-----\r\n" - }, - "gitHead": "2c72f21e3d1750bcee977867de28a79be3f1e21b", - "homepage": "https://github.com/unexpectedjs/magicpen-prism#readme", - "main": "lib/magicPenPrism.js", - "maintainers": [ - { - "name": "alexjeffburke", - "email": "alex@alexjeffburke.com" - }, - { - "name": "gustavnikolaj", - "email": "gustavnikolaj@gmail.com" - }, - { - "name": "joelmukuthu", - "email": "joelmukuthu@gmail.com" - }, - { - "name": "papandreou", - "email": "andreaslindpetersen@gmail.com" - }, - { - "name": "sunesimonsen", - "email": "sune@we-knowhow.dk" - } - ], - "name": "magicpen-prism", - "nyc": { - "include": [ - "lib/**" - ] - }, - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/unexpectedjs/magicpen-prism.git" - }, - "scripts": { - "ci": "npm run lint && npm run coverage", - "coverage": "NODE_ENV=development nyc --reporter=lcov --reporter=text --all -- npm test && echo google-chrome coverage/lcov-report/index.html", - "lint": "eslint . && prettier --check '**/*.js'", - "prepublish": "browserify -p bundle-collapser/plugin -e lib/magicPenPrism -s magicPenPrism > magicPenPrism.min.js", - "test": "mocha" - }, - "version": "3.0.1" -} - -},{}],5:[function(require,module,exports){ -/** - * Original by Scott Helme. - * - * Reference: https://scotthelme.co.uk/csp-cheat-sheet/ - * - * Supports the following: - * - CSP Level 1 - * - CSP Level 2 - * - CSP Level 3 - */ - -Prism.languages.csp = { - 'directive': { - pattern: /\b(?:(?:base-uri|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox) |(?:block-all-mixed-content|disown-opener|upgrade-insecure-requests)(?: |;)|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src )/i, - alias: 'keyword' - }, - 'safe': { - pattern: /'(?:self|none|strict-dynamic|(?:nonce-|sha(?:256|384|512)-)[a-zA-Z\d+=/]+)'/, - alias: 'selector' - }, - 'unsafe': { - pattern: /(?:'unsafe-inline'|'unsafe-eval'|'unsafe-hashed-attributes'|\*)/, - alias: 'function' - } -}; -},{}],6:[function(require,module,exports){ -Prism.languages.graphql = { - 'comment': /#.*/, - 'string': { - pattern: /"(?:\\.|[^\\"\r\n])*"/, - greedy: true - }, - 'number': /(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, - 'boolean': /\b(?:true|false)\b/, - 'variable': /\$[a-z_]\w*/i, - 'directive': { - pattern: /@[a-z_]\w*/i, - alias: 'function' - }, - 'attr-name': { - pattern: /[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i, - greedy: true - }, - 'class-name': { - pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/, - lookbehind: true - }, - 'fragment': { - pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/, - lookbehind: true, - alias: 'function' - }, - 'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/, - 'operator': /[!=|]|\.{3}/, - 'punctuation': /[!(){}\[\]:=,]/, - 'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/ -}; - -},{}],7:[function(require,module,exports){ -(function (global){ - -/* ********************************************** - Begin prism-core.js -********************************************** */ - -var _self = (typeof window !== 'undefined') - ? window // if in browser - : ( - (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) - ? self // if in worker - : {} // if in node js - ); - -/** - * Prism: Lightweight, robust, elegant syntax highlighting - * MIT license http://www.opensource.org/licenses/mit-license.php/ - * @author Lea Verou http://lea.verou.me - */ - -var Prism = (function (_self){ - -// Private helper vars -var lang = /\blang(?:uage)?-([\w-]+)\b/i; -var uniqueId = 0; - -var _ = { - manual: _self.Prism && _self.Prism.manual, - disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, - util: { - encode: function (tokens) { - if (tokens instanceof Token) { - return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); - } else if (Array.isArray(tokens)) { - return tokens.map(_.util.encode); - } else { - return tokens.replace(/&/g, '&').replace(/ text.length) { - // Something went terribly wrong, ABORT, ABORT! - return; - } - - if (str instanceof Token) { - continue; - } - - if (greedy && i != strarr.length - 1) { - pattern.lastIndex = pos; - var match = pattern.exec(text); - if (!match) { - break; - } - - var from = match.index + (lookbehind ? match[1].length : 0), - to = match.index + match[0].length, - k = i, - p = pos; - - for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) { - p += strarr[k].length; - // Move the index i to the element in strarr that is closest to from - if (from >= p) { - ++i; - pos = p; - } - } - - // If strarr[i] is a Token, then the match starts inside another Token, which is invalid - if (strarr[i] instanceof Token) { - continue; - } - - // Number of tokens to delete and replace with the new match - delNum = k - i; - str = text.slice(pos, p); - match.index -= pos; - } else { - pattern.lastIndex = 0; - - var match = pattern.exec(str), - delNum = 1; - } - - if (!match) { - if (oneshot) { - break; - } - - continue; - } - - if(lookbehind) { - lookbehindLength = match[1] ? match[1].length : 0; - } - - var from = match.index + lookbehindLength, - match = match[0].slice(lookbehindLength), - to = from + match.length, - before = str.slice(0, from), - after = str.slice(to); - - var args = [i, delNum]; - - if (before) { - ++i; - pos += before.length; - args.push(before); - } - - var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy); - - args.push(wrapped); - - if (after) { - args.push(after); - } - - Array.prototype.splice.apply(strarr, args); - - if (delNum != 1) - _.matchGrammar(text, strarr, grammar, i, pos, true, token); - - if (oneshot) - break; - } - } - } - }, - - tokenize: function(text, grammar) { - var strarr = [text]; - - var rest = grammar.rest; - - if (rest) { - for (var token in rest) { - grammar[token] = rest[token]; - } - - delete grammar.rest; - } - - _.matchGrammar(text, strarr, grammar, 0, 0, false); - - return strarr; - }, - - hooks: { - all: {}, - - add: function (name, callback) { - var hooks = _.hooks.all; - - hooks[name] = hooks[name] || []; - - hooks[name].push(callback); - }, - - run: function (name, env) { - var callbacks = _.hooks.all[name]; - - if (!callbacks || !callbacks.length) { - return; - } - - for (var i=0, callback; callback = callbacks[i++];) { - callback(env); - } - } - }, - - Token: Token -}; - -_self.Prism = _; - -function Token(type, content, alias, matchedStr, greedy) { - this.type = type; - this.content = content; - this.alias = alias; - // Copy of the full string this token was created from - this.length = (matchedStr || "").length|0; - this.greedy = !!greedy; -} - -Token.stringify = function(o, language, parent) { - if (typeof o == 'string') { - return o; - } - - if (Array.isArray(o)) { - return o.map(function(element) { - return Token.stringify(element, language, o); - }).join(''); - } - - var env = { - type: o.type, - content: Token.stringify(o.content, language, parent), - tag: 'span', - classes: ['token', o.type], - attributes: {}, - language: language, - parent: parent - }; - - if (o.alias) { - var aliases = Array.isArray(o.alias) ? o.alias : [o.alias]; - Array.prototype.push.apply(env.classes, aliases); - } - - _.hooks.run('wrap', env); - - var attributes = Object.keys(env.attributes).map(function(name) { - return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; - }).join(' '); - - return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + ''; - -}; - -if (!_self.document) { - if (!_self.addEventListener) { - // in Node.js - return _; - } - - if (!_.disableWorkerMessageHandler) { - // In worker - _self.addEventListener('message', function (evt) { - var message = JSON.parse(evt.data), - lang = message.language, - code = message.code, - immediateClose = message.immediateClose; - - _self.postMessage(_.highlight(code, _.languages[lang], lang)); - if (immediateClose) { - _self.close(); - } - }, false); - } - - return _; -} - -//Get current script and highlight -var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); - -if (script) { - _.filename = script.src; - - if (!_.manual && !script.hasAttribute('data-manual')) { - if(document.readyState !== "loading") { - if (window.requestAnimationFrame) { - window.requestAnimationFrame(_.highlightAll); - } else { - window.setTimeout(_.highlightAll, 16); - } - } - else { - document.addEventListener('DOMContentLoaded', _.highlightAll); - } - } -} - -return _; - -})(_self); - -if (typeof module !== 'undefined' && module.exports) { - module.exports = Prism; -} - -// hack for components to work correctly in node.js -if (typeof global !== 'undefined') { - global.Prism = Prism; -} - - -/* ********************************************** - Begin prism-markup.js -********************************************** */ - -Prism.languages.markup = { - 'comment': //, - 'prolog': /<\?[\s\S]+?\?>/, - 'doctype': //i, - 'cdata': //i, - 'tag': { - pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i, - greedy: true, - inside: { - 'tag': { - pattern: /^<\/?[^\s>\/]+/i, - inside: { - 'punctuation': /^<\/?/, - 'namespace': /^[^\s>\/:]+:/ - } - }, - 'attr-value': { - pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, - inside: { - 'punctuation': [ - /^=/, - { - pattern: /^(\s*)["']|["']$/, - lookbehind: true - } - ] - } - }, - 'punctuation': /\/?>/, - 'attr-name': { - pattern: /[^\s>\/]+/, - inside: { - 'namespace': /^[^\s>\/:]+:/ - } - } - - } - }, - 'entity': /&#?[\da-z]{1,8};/i -}; - -Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = - Prism.languages.markup['entity']; - -// Plugin to make entity title show the real entity, idea by Roman Komarov -Prism.hooks.add('wrap', function(env) { - - if (env.type === 'entity') { - env.attributes['title'] = env.content.replace(/&/, '&'); - } -}); - -Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { - /** - * Adds an inlined language to markup. - * - * An example of an inlined language is CSS with ` "+str+""}var htmlDocument=getHtmlDocument(str);if(isFragment){var body=htmlDocument.body;var documentFragment=htmlDocument.createDocumentFragment();if(body){for(var i=0;i0){expect.errorMode="nested";expect.fail("Expectation contains invalid styles: {0}",invalidStyles.join(";"))}}function styleStringToObject(str){var styles={};str.split(";").forEach(function(rule){var tuple=rule.split(":").map(function(part){return part.trim()});if(tuple[0]&&tuple[1]){styles[tuple[0]]=tuple[1]}});return styles}function getClassNamesFromAttributeValue(attributeValue){if(attributeValue===null){return[]}if(attributeValue===""){return[]}var classNames=attributeValue.split(/\s+/);if(classNames.length===1&&classNames[0]===""){classNames.pop()}return classNames}function isInsideHtmlDocument(node){var ownerDocument=node.nodeType===9&&node.documentElement&&node.implementation?node:node.ownerDocument;if(ownerDocument.contentType){return ownerDocument.contentType==="text/html"}else{return ownerDocument.toString()==="[object HTMLDocument]"}}function getAttributes(element){var isHtml=isInsideHtmlDocument(element);var attrs=element.attributes;var result={};for(var i=0;i"}}function ensureSupportedSpecOptions(options){var unsupportedOptions=Object.keys(options).filter(function(key){return key!=="attributes"&&key!=="name"&&key!=="children"&&key!=="onlyAttributes"&&key!=="textContent"});if(unsupportedOptions.length>0){throw new Error("Unsupported option"+(unsupportedOptions.length===1?"":"s")+": "+unsupportedOptions.join(", "))}}module.exports={name:"unexpected-dom",installInto:function installInto(expect){expect=expect.child();expect.use(require("magicpen-prism"));function bubbleError(body){return expect.withError(body,function(err){err.errorMode="bubble";throw err})}expect.exportType({name:"DOMNode",base:"object",identify:function identify(obj){return obj&&obj.nodeName&&[2,3,4,5,6,7,10,11,12].indexOf(obj.nodeType)>-1},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(element.nodeName+' "'+element.nodeValue+'"',"prism-string")}});expect.exportType({name:"DOMComment",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===8},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code("\x3c!--"+element.nodeValue+"--\x3e","html")},diff:function diff(actual,expected,output,_diff,inspect,equal){var d=_diff("\x3c!--"+actual.nodeValue+"--\x3e","\x3c!--"+expected.nodeValue+"--\x3e");d.inline=true;return d}});expect.exportType({name:"DOMIgnoreComment",base:"DOMComment",identify:function identify(obj){return this.baseType.identify(obj)&&/^\s*ignore\s*$/.test(obj.nodeValue)}});expect.exportType({name:"DOMTextNode",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===3},equal:function equal(a,b){return a.nodeValue===b.nodeValue},inspect:function inspect(element,depth,output){return output.code(entitify(element.nodeValue.trim()),"html")},diff:function diff(actual,expected,output,_diff2,inspect,equal){var d=_diff2(actual.nodeValue,expected.nodeValue);d.inline=true;return d}});expect.exportType({name:"DOMNodeList",base:"array-like",prefix:function prefix(output){return output.text("NodeList[")},suffix:function suffix(output){return output.text("]")},similar:function similar(a,b){return a.nodeType===1&&b.nodeType===1&&a.nodeName===b.nodeName},identify:function identify(obj){return obj&&typeof obj.length==="number"&&typeof obj.toString==="function"&&typeof obj.item==="function"&&(obj.toString().indexOf("NodeList")!==-1||obj.constructor&&obj.constructor.name==="NodeList")}});expect.exportType({name:"attachedDOMNodeList",base:"DOMNodeList",indent:false,prefix:function prefix(output){return output},suffix:function suffix(output){return output},delimiter:function delimiter(output){return output},identify:function identify(obj){return obj&&obj._isAttachedDOMNodeList}});function makeAttachedDOMNodeList(domNodeList,contentType){var attachedDOMNodeList=[];for(var i=0;i","html")},equal:function equal(a,b){return a.toString()===b.toString()},diff:function diff(actual,expected,output,_diff3){var d=_diff3("","");d.inline=true;return d}});expect.exportType({name:"DOMDocument",base:"DOMNode",identify:function identify(obj){return obj&&typeof obj.nodeType==="number"&&obj.nodeType===9&&obj.documentElement&&obj.implementation},inspect:function inspect(document,depth,output,_inspect2){for(var i=0;i',"xml");for(var i=0;i0){if(depth===1){output.text("...")}else{var inspectedChildren=[];if(elementName==="script"){var type=element.getAttribute("type");if(!type||/javascript/.test(type)){type="javascript"}inspectedChildren.push(output.clone().code(element.textContent,type))}else if(elementName==="style"){inspectedChildren.push(output.clone().code(element.textContent,element.getAttribute("type")||"text/css"))}else{for(var i=0;i60||o.height>1});if(multipleLines){output.nl().indentLines();inspectedChildren.forEach(function(inspectedChild,index){output.i().block(inspectedChild).nl()});output.outdentLines()}else{inspectedChildren.forEach(function(inspectedChild,index){return output.append(inspectedChild)})}}}output.code(stringifyEndTag(element),"html");return output},diffLimit:512,diff:function diff(actual,expected,output,_diff6,inspect,equal){var isHtml=isInsideHtmlDocument(actual);output.inline=true;if(Math.max(actual.length,expected.length)>this.diffLimit){output.jsComment("Diff suppressed due to size > "+this.diffLimit);return output}var emptyElements=actual.childNodes.length===0&&expected.childNodes.length===0;var conflictingElement=actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()||!equal(getAttributes(actual),getAttributes(expected));if(conflictingElement){var canContinueLine=true;output.prismPunctuation("<").prismTag(actual.nodeName.toLowerCase());if(actual.nodeName.toLowerCase()!==expected.nodeName.toLowerCase()){output.sp().annotationBlock(function(output){return output.error("should be").sp().prismTag(expected.nodeName.toLowerCase())}).nl();canContinueLine=false}var actualAttributes=getAttributes(actual);var expectedAttributes=getAttributes(expected);Object.keys(actualAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);writeAttributeToMagicPen(output,attributeName,actualAttributes[attributeName],isHtml);if(attributeName in expectedAttributes){if(actualAttributes[attributeName]===expectedAttributes[attributeName]){canContinueLine=true}else{output.sp().annotationBlock(function(output){return output.error("should equal").sp().append(inspect(entitify(expectedAttributes[attributeName])))}).nl();canContinueLine=false}delete expectedAttributes[attributeName]}else{output.sp().annotationBlock(function(output){return output.error("should be removed")}).nl();canContinueLine=false}});Object.keys(expectedAttributes).forEach(function(attributeName){output.sp(canContinueLine?1:2+actual.nodeName.length);output.annotationBlock(function(output){output.error("missing").sp();writeAttributeToMagicPen(output,attributeName,expectedAttributes[attributeName],isHtml)}).nl();canContinueLine=false});output.prismPunctuation(">")}else{output.code(stringifyStartTag(actual),"html")}if(!emptyElements){output.nl().indentLines().i().block(_diff6(makeAttachedDOMNodeList(actual.childNodes),makeAttachedDOMNodeList(expected.childNodes))).nl().outdentLines()}output.code(stringifyEndTag(actual),"html");return output}});expect.exportAssertion(" to have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:value})});expect.exportAssertion(" to only have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:expect.it(function(className){var actualClasses=getClassNamesFromAttributeValue(className);if(typeof value==="string"){value=getClassNamesFromAttributeValue(value)}return bubbleError(function(){return expect(actualClasses.sort(),"to equal",value.sort())})})})});expect.exportAssertion(" not to have (class|classes) ",function(expect,subject,value){return expect(subject,"to have attributes",{class:expect.it(function(className){var actualClasses=getClassNamesFromAttributeValue(className);var expectedClasses=void 0;if(typeof value==="string"){expectedClasses=getClassNamesFromAttributeValue(value)}else{expectedClasses=value}return bubbleError(function(){return expect.apply(undefined,[actualClasses,"not to contain"].concat(_toConsumableArray(expectedClasses)))})})})});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject.nodeValue,"to equal",value.nodeValue)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref,value){var nodeValue=_ref.nodeValue;return expect(nodeValue,"to satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref2,value){var nodeValue=_ref2.nodeValue;return expect(nodeValue,"to satisfy",value)});function convertDOMNodeToSatisfySpec(node,isHtml){if(node.nodeType===10){return{name:node.nodeName}}else if(node.nodeType===1){var name=isHtml?node.nodeName.toLowerCase():node.nodeName;var result={name:name};if(node.attributes){result.attributes={};for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",(isHtml?parseHtml(value,true):parseXml(value)).childNodes)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var satisfySpecs=[];for(var i=0;i to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",isHtml?parseHtml(value,true):parseXml(value))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref3){var childNodes=_ref3.childNodes;var isHtml=isInsideHtmlDocument(subject);return expect(subject,"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,_ref4,value){var childNodes=_ref4.childNodes;return expect(childNodes,"to [exhaustively] satisfy",value)});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var documentFragment=isHtml?parseHtml(value,true):parseXml(value);if(documentFragment.childNodes.length!==1){throw new Error("HTMLElement to satisfy string: Only a single node is supported")}expect.argsOutput=function(output){return output.code(value,isHtml?"html":"xml")};return expect(subject,"to [exhaustively] satisfy",documentFragment.childNodes[0])});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);var valueDocument=isHtml?parseHtml(value,false):parseXml(value);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(valueDocument.childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,_ref5){var childNodes=_ref5.childNodes;var isHtml=isInsideHtmlDocument(subject);return expect(makeAttachedDOMNodeList(subject.childNodes),"to [exhaustively] satisfy",Array.prototype.map.call(childNodes,function(childNode){return convertDOMNodeToSatisfySpec(childNode,isHtml)}))});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){return expect(subject,"to [exhaustively] satisfy",convertDOMNodeToSatisfySpec(value,isInsideHtmlDocument(subject)))});expect.exportAssertion([" to [exhaustively] satisfy "," to [exhaustively] satisfy "," to [exhaustively] satisfy "],function(expect,subject,value){return expect.fail()});expect.exportAssertion(" to [exhaustively] satisfy ",function(expect,subject,value){var isHtml=isInsideHtmlDocument(subject);ensureSupportedSpecOptions(value);var promiseByKey={name:expect.promise(function(){if(value&&typeof value.name!=="undefined"){return bubbleError(function(){return expect(isHtml?subject.nodeName.toLowerCase():subject.nodeName,"to satisfy",value.name)})}}),children:expect.promise(function(){if(typeof value.children!=="undefined"){if(typeof value.textContent!=="undefined"){throw new Error("The children and textContent properties are not supported together")}var contentType=subject.ownerDocument.contentType;if(!contentType){contentType=isInsideHtmlDocument(subject)?"text/html":"application/xml"}return bubbleError(function(){return expect(makeAttachedDOMNodeList(subject.childNodes,contentType),"to satisfy",value.children)})}else if(typeof value.textContent!=="undefined"){return bubbleError(function(){return expect(subject.textContent,"to satisfy",value.textContent)})}}),attributes:{}};var onlyAttributes=value&&value.onlyAttributes||expect.flags.exhaustively;var attrs=getAttributes(subject);var expectedAttributes=value&&value.attributes;var expectedAttributeNames=[];var expectedValueByAttributeName={};if(typeof expectedAttributes!=="undefined"){if(typeof expectedAttributes==="string"){expectedAttributes=[expectedAttributes]}if(Array.isArray(expectedAttributes)){expectedAttributes.forEach(function(attributeName){expectedValueByAttributeName[attributeName]=true})}else if(expectedAttributes&&(typeof expectedAttributes==="undefined"?"undefined":_typeof(expectedAttributes))==="object"){expectedValueByAttributeName=expectedAttributes}Object.keys(expectedValueByAttributeName).forEach(function(attributeName){expectedAttributeNames.push(attributeName)});expectedAttributeNames.forEach(function(attributeName){var attributeValue=subject.getAttribute(attributeName);var expectedAttributeValue=expectedValueByAttributeName[attributeName];promiseByKey.attributes[attributeName]=expect.promise(function(){if(typeof expectedAttributeValue==="undefined"){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be false")})}else if(isEnumeratedAttribute(attributeName)){var indexOfEnumeratedAttributeValue=enumeratedAttributeValues[attributeName].indexOf(expectedAttributeValue);return bubbleError(function(){if(indexOfEnumeratedAttributeValue===-1){expect.fail(function(output){return output.text("Invalid expected value ").appendInspected(expectedAttributeValue).text(". Supported values include: ").appendItems(enumeratedAttributeValues[attributeName],", ")})}expect(attributeValue,"to satisfy",expectedAttributeValue)})}else if(expectedAttributeValue===true){return bubbleError(function(){return expect(subject.hasAttribute(attributeName),"to be true")})}else if(attributeName==="class"&&(typeof expectedAttributeValue==="string"||Array.isArray(expectedAttributeValue))){var actualClasses=getClassNamesFromAttributeValue(attributeValue);var expectedClasses=expectedAttributeValue;if(typeof expectedClasses==="string"){expectedClasses=getClassNamesFromAttributeValue(expectedAttributeValue)}if(onlyAttributes){return bubbleError(function(){return expect(actualClasses.sort(),"to equal",expectedClasses.sort())})}else{if(expectedClasses.length===0){return bubbleError(function(){return expect(expectedClasses,"to be empty")})}return bubbleError(function(){return expect.apply(undefined,[actualClasses,"to contain"].concat(_toConsumableArray(expectedClasses)))})}}else if(attributeName==="style"){var expectedStyleObj=void 0;if(typeof expectedValueByAttributeName.style==="string"){validateStyles(expect,expectedValueByAttributeName.style);expectedStyleObj=styleStringToObject(expectedValueByAttributeName.style)}else{expectedStyleObj=expectedValueByAttributeName.style}if(onlyAttributes){return bubbleError(function(){return expect(attrs.style,"to exhaustively satisfy",expectedStyleObj)})}else{return bubbleError(function(){return expect(attrs.style,"to satisfy",expectedStyleObj)})}}else if(expect.findTypeOf(expectedAttributeValue).is("expect.it")){expect.context.thisObject=subject;return bubbleError(function(){return expectedAttributeValue(attributeValue,expect.context)})}else{return bubbleError(function(){return expect(attributeValue,"to satisfy",expectedAttributeValue)})}})});promiseByKey.attributePresence=expect.promise(function(){var attributeNamesExpectedToBeDefined=[];expectedAttributeNames.forEach(function(attributeName){if(typeof expectedValueByAttributeName[attributeName]==="undefined"){expect(attrs,"not to have key",attributeName)}else{attributeNamesExpectedToBeDefined.push(attributeName);expect(attrs,"to have key",attributeName)}});if(onlyAttributes){expect(Object.keys(attrs).sort(),"to equal",attributeNamesExpectedToBeDefined.sort())}})}return expect.promise.all(promiseByKey).caught(function(){return expect.promise.settle(promiseByKey).then(function(){expect.fail({diff:function diff(output,_diff7,inspect,equal){output.block(function(output){var seenError=false;output.prismPunctuation("<").prismTag(isHtml?subject.nodeName.toLowerCase():subject.nodeName);if(promiseByKey.name.isRejected()){seenError=true;var nameError=promiseByKey.name.reason();output.sp().annotationBlock(function(output){return output.error(nameError&&nameError.getLabel()||"should satisfy").sp().append(inspect(value.name))})}var inspectedAttributes=[];Object.keys(attrs).forEach(function(attributeName){var attributeOutput=output.clone();var promise=promiseByKey.attributes[attributeName];writeAttributeToMagicPen(attributeOutput,attributeName,attrs[attributeName],isHtml);if(promise&&promise.isFulfilled()||!promise&&(!onlyAttributes||expectedAttributeNames.indexOf(attributeName)!==-1)){}else{seenError=true;attributeOutput.sp().annotationBlock(function(output){if(promise&&typeof expectedValueByAttributeName[attributeName]!=="undefined"){output.appendErrorMessage(promise.reason())}else{output.error("should be removed")}})}inspectedAttributes.push(attributeOutput)});expectedAttributeNames.forEach(function(attributeName){if(!subject.hasAttribute(attributeName)){var promise=promiseByKey.attributes[attributeName];if(!promise||promise.isRejected()){seenError=true;var err=promise&&promise.reason();var attributeOutput=output.clone().annotationBlock(function(output){output.error("missing").sp().prismAttrName(attributeName,"html");if(expectedValueByAttributeName[attributeName]!==true){output.sp().error(err&&err.getLabel()||"should satisfy").sp().append(inspect(expectedValueByAttributeName[attributeName]))}});inspectedAttributes.push(attributeOutput)}}});if(inspectedAttributes.length>0){if(seenError){output.nl().indentLines().indent().block(function(output){inspectedAttributes.forEach(function(item,i){if(i>0){output.nl()}output.append(item)})}).outdentLines().nl()}else{output.sp();inspectedAttributes.forEach(function(item,i){if(i>0){output.sp()}output.append(item)})}}else if(seenError){output.nl()}output.prismPunctuation(">");var childrenError=promiseByKey.children.isRejected()&&promiseByKey.children.reason();if(childrenError){var childrenDiff=childrenError.getDiff(output);if(childrenDiff&&childrenDiff.inline){output.nl().indentLines().i().block(childrenDiff).nl().outdentLines()}else{output.nl().indentLines().i().block(function(output){for(var i=0;i to [only] have (attribute|attributes) ",function(expect,subject){for(var _len=arguments.length,args=Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}return expect(subject,"to [only] have attributes",args)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject,value){var attributes=getAttributes(subject);value.forEach(function(name){delete attributes[name]});return expect(subject,"to only have attributes",attributes)});expect.exportAssertion(" not to have (attribute|attributes) ",function(expect,subject){for(var _len2=arguments.length,args=Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){args[_key2-2]=arguments[_key2]}return expect(subject,"not to have attributes",args)});expect.exportAssertion(" to [only] have (attribute|attributes) ",function(expect,subject,value){return expect(subject,"to satisfy",{attributes:value,onlyAttributes:expect.flags.only})});expect.exportAssertion(" to have [no] (child|children)",function(expect,_ref6){var childNodes=_ref6.childNodes;return expect.flags.no?expect(childNodes,"to be empty"):expect(childNodes,"not to be empty")});expect.exportAssertion(" to have text ",function(expect,_ref7,value){var textContent=_ref7.textContent;return expect(textContent,"to satisfy",value)});expect.exportAssertion(" [when] queried for [first] ",function(expect,subject,query){var queryResult=void 0;expect.argsOutput[0]=function(output){return output.green(query)};expect.errorMode="nested";if(expect.flags.first){queryResult=subject.querySelector(query);if(!queryResult){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}else{queryResult=subject.querySelectorAll(query);if(queryResult.length===0){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail(function(output){return output.error("The selector").sp().jsString(query).sp().error("yielded no results")})}}return expect.shift(queryResult)});expect.exportAssertion(" to contain [no] elements matching ",function(expect,subject,query){if(expect.flags.no){return expect(subject.querySelectorAll(query),"to satisfy",[])}expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(subject.querySelectorAll(query),"not to satisfy",[])});expect.exportAssertion(" [not] to match ",function(expect,subject,query){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};return expect(matchesSelector(subject,query),"[not] to be true")});expect.exportAssertion(" [when] parsed as (html|HTML) [fragment] ",function(expect,subject){expect.errorMode="nested";return expect.shift(parseHtml(subject,expect.flags.fragment))});expect.exportAssertion(" [when] parsed as (xml|XML) ",function(expect,subject){expect.errorMode="nested";return expect.shift(parseXml(subject))});function scoreElementAgainstSpec(element,spec){var isTextSimilar=function isTextSimilar(value,valueSpec){var actual=(value||"").trim().toLowerCase();if(typeof valueSpec==="string"){if(actual===valueSpec.trim().toLowerCase()){return true}}else if(valueSpec instanceof RegExp){if(valueSpec.test(actual)){return true}}else if(typeof valueSpec==="function"){return true}return false};var isHtml=isInsideHtmlDocument(element);var score=0;var nodeName=isHtml?element.nodeName.toLowerCase():element.nodeName;if(isTextSimilar(nodeName,spec.name)){score++}if(isTextSimilar(element.textContent,spec.textContent)){score++}if(typeof element.hasAttribute==="function"){var attributes=spec.attributes||{};var className=attributes["class"];var style=attributes.style;if(className&&element.hasAttribute("class")){if(typeof className==="string"){var expectedClasses=getClassNamesFromAttributeValue(className);var actualClasses=getClassNamesFromAttributeValue(element.getAttribute("class"));expectedClasses.forEach(function(expectedClass){if(actualClasses.indexOf(expectedClass)!==-1){score++}})}else if(isTextSimilar(element.getAttribute("class"),className)){score++}}if(style&&element.hasAttribute("style")){var expectedStyles=typeof style==="string"?styleStringToObject(style):style;var actualStyles=styleStringToObject(element.getAttribute("style"));Object.keys(expectedStyles).forEach(function(styleName){var expectedStyle=expectedStyles[styleName];var actualStyle=actualStyles[styleName];if(actualStyle){score++}if(isTextSimilar(actualStyle,expectedStyle)){score++}})}var specialAttributes=["style","class"];var ids=["id","data-test-id","data-testid"];Object.keys(attributes).forEach(function(attributeName){if(specialAttributes.indexOf(attributeName)!==-1){return}if(element.hasAttribute(attributeName)){if(typeof attributes[attributeName]==="boolean"){score++}if(element.getAttribute(attributeName)===attributes[attributeName]){score+=ids.indexOf(attributeName)===-1?1:100}}else if(typeof attributes[attributeName]==="undefined"){score++}})}var expectedChildren=spec.children||[];expectedChildren.forEach(function(childSpec,i){var child=element.childNodes[i];var childType=expect.findTypeOf(child);if(!child){return}if(typeof childSpec.nodeType==="number"){if(child.nodeType===childSpec.nodeType){if(childType.is("DOMElement")){score+=scoreElementAgainstSpec(element.childNodes[i],convertDOMNodeToSatisfySpec(childSpec))}score++}else if(expect.findTypeOf(childSpec).is("DOMIgnoreComment")){score++}}else if(childType.is("DOMElement")&&(typeof childSpec==="undefined"?"undefined":_typeof(childSpec))==="object"){score+=scoreElementAgainstSpec(element.childNodes[i],childSpec)}else if(childType.is("DOMTextNode")&&isTextSimilar(child.nodeValue,childSpec)){score++}});return score}function findMatchesWithGoodScore(data,spec){var elements=typeof data.length==="number"?Array.prototype.slice.call(data):[data];var result=[];var bestScore=0;elements.forEach(function(element){var score=scoreElementAgainstSpec(element,spec);bestScore=Math.max(score,bestScore);if(score>0&&score>=bestScore){result.push({score:score,element:element})}for(var i=0;i0){var _bestScore=result[0].score;return result.filter(function(_ref8){var score=_ref8.score;return score===_bestScore})}return result}expect.exportAssertion(" [not] to contain ",function(expect,subject,value){var nodes=subject.childNodes||makeAttachedDOMNodeList(subject);var isHtml=isInsideHtmlDocument(subject.childNodes?subject:nodes);var valueType=expect.findTypeOf(value);var spec=value;if(valueType.is("DOMElement")){spec=convertDOMNodeToSatisfySpec(value,isHtml)}else if(valueType.is("string")){var documentFragment=isHtml?parseHtml(value,true):parseXml(value);if(documentFragment.childNodes.length!==1){throw new Error("HTMLElement to contain string: Only a single node is supported")}spec=convertDOMNodeToSatisfySpec(documentFragment.childNodes[0],isHtml);if(typeof spec==="string"){throw new Error("HTMLElement to contain string: please provide a HTML structure as a string")}expect.argsOutput=function(output){return output.appendInspected(documentFragment.childNodes[0])};ensureSupportedSpecOptions(spec)}var scoredElements=findMatchesWithGoodScore(nodes,spec);if(expect.flags.not){if(scoredElements.length>0){return expect.withError(function(){return expect(scoredElements.map(function(_ref9){var element=_ref9.element;return element}),"not to have an item satisfying",spec)},function(){var bestMatch=scoredElements[0].element;expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail({diff:function diff(output,_diff8,inspect,equal){return output.error("Found:").nl(2).appendInspected(bestMatch)}})})}}else{if(scoredElements.length===0){expect.subjectOutput=function(output){return expect.inspect(subject,Infinity,output)};expect.fail()}return expect.withError(function(){return expect(scoredElements.map(function(_ref10){var element=_ref10.element;return element}),"to have an item satisfying",spec)},function(){var bestMatch=scoredElements[0].element;return expect(bestMatch,"to satisfy",spec)})}})}}},{"./matchesSelector":2,"magicpen-prism":3}],2:[function(require,module,exports){module.exports=function(elm,selector){var matchFuntion=elm.matchesSelector||elm.mozMatchesSelector||elm.msMatchesSelector||elm.oMatchesSelector||elm.webkitMatchesSelector||function(selector){var node=this;var nodes=(node.parentNode||node.document).querySelectorAll(selector);var i=0;while(nodes[i]&&nodes[i]!==node){i+=1}return!!nodes[i]};return matchFuntion.call(elm,selector)}},{}],3:[function(require,module,exports){(function(global){var oldPrismGlobal=global.Prism;var prism=global.Prism=require("prismjs");require("prismjs/components/prism-graphql.js");require("prismjs/components/prism-csp.js");global.Prism=oldPrismGlobal;var defaultTheme={prismComment:"#708090",prismProlog:"prismComment",prismDoctype:"prismComment",prismCdata:"prismComment",prismPunctuation:"#999",prismSymbol:"#905",prismProperty:"prismSymbol",prismTag:"prismSymbol",prismBoolean:"prismSymbol",prismNumber:"prismSymbol",prismConstant:"prismSymbol",prismDeleted:"prismSymbol",prismString:"#690",prismSelector:"prismString",prismAttrName:"prismString",prismChar:"prismString",prismBuiltin:"prismString",prismInserted:"prismString",prismOperator:"#a67f59",prismVariable:"prismOperator",prismEntity:"prismOperator",prismUrl:"prismOperator",prismCssString:"prismOperator",prismKeyword:"#07a",prismAtrule:"prismKeyword",prismAttrValue:"prismKeyword",prismFunction:"#DD4A68",prismRegex:"#e90",prismImportant:["#e90","bold"]};var languageMapping={"text/html":"markup","application/xml":"markup","text/xml":"markup","application/json":"javascript","text/javascript":"javascript","application/javascript":"javascript","text/css":"css",html:"markup",xml:"markup",c:"clike","c++":"clike",cpp:"clike","c#":"clike",java:"clike","application/graphql":"graphql"};function upperCamelCase(str){return str.replace(/(?:^|-)([a-z])/g,function($0,ch){return ch.toUpperCase()})}module.exports={name:"magicpen-prism",version:require("../package.json").version,installInto:function(magicPen){Object.keys(defaultTheme).forEach(function(styleName){var style=defaultTheme[styleName];while(typeof style==="string"&&style in defaultTheme){style=defaultTheme[style]}magicPen.addStyle(styleName,function(text){this.text(text,style)})});magicPen.addStyle("code",function(sourceText,language){if(language in languageMapping){language=languageMapping[language]}else if(/\+xml\b/.test(language)){language="markup"}if(!(language in prism.languages)){return this.text(sourceText)}var that=this;var capitalizedLanguage=upperCamelCase(language);var languageDefinition=prism.languages[language];function printTokens(token,parentStyle){if(Array.isArray(token)){token.forEach(function(subToken){printTokens(subToken,parentStyle)})}else if(typeof token==="string"){var upperCamelCasedParentStyle=upperCamelCase(parentStyle);token=token.replace(/</g,"<");if(that["prism"+capitalizedLanguage+upperCamelCasedParentStyle]){that["prism"+capitalizedLanguage+upperCamelCasedParentStyle](token)}else if(that["prism"+upperCamelCasedParentStyle]){that["prism"+upperCamelCasedParentStyle](token)}else if(languageDefinition[parentStyle]&&languageDefinition[parentStyle].alias){printTokens(token,languageDefinition[parentStyle].alias)}else{that.text(token)}}else{printTokens(token.content,token.type)}}printTokens(prism.tokenize(sourceText,prism.languages[language]),"text")},true)}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../package.json":4,prismjs:7,"prismjs/components/prism-csp.js":5,"prismjs/components/prism-graphql.js":6}],4:[function(require,module,exports){module.exports={_args:[[{raw:"magicpen-prism@^3.0.1",scope:null,escapedName:"magicpen-prism",name:"magicpen-prism",rawSpec:"^3.0.1",spec:">=3.0.1 <4.0.0",type:"range"},"/Users/alex/Documents/projects/unexpected-dom"]],_from:"magicpen-prism@>=3.0.1 <4.0.0",_hasShrinkwrap:false,_id:"magicpen-prism@3.0.1",_inCache:true,_location:"/magicpen-prism",_nodeVersion:"10.15.1",_npmOperationalInternal:{host:"s3://npm-registry-packages",tmp:"tmp/magicpen-prism_3.0.1_1552750340750_0.6047691017808081"},_npmUser:{name:"papandreou",email:"andreaslindpetersen@gmail.com"},_npmVersion:"6.4.1",_phantomChildren:{},_requested:{raw:"magicpen-prism@^3.0.1",scope:null,escapedName:"magicpen-prism",name:"magicpen-prism",rawSpec:"^3.0.1",spec:">=3.0.1 <4.0.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/magicpen-prism/-/magicpen-prism-3.0.1.tgz",_shasum:"5bf516bb9f8b0fd889548ca452c863cb30e843a1",_shrinkwrap:null,_spec:"magicpen-prism@^3.0.1",_where:"/Users/alex/Documents/projects/unexpected-dom",author:{name:"Andreas Lind",email:"andreaslindpetersen@gmail.com"},bugs:{url:"https://github.com/unexpectedjs/magicpen-prism/issues"},dependencies:{prismjs:"^1.15.0"},description:"Add syntax highlighting support to magicpen via prism.js",devDependencies:{browserify:"^16.2.3","bundle-collapser":"^1.3.0",coveralls:"^3.0.3",eslint:"^5.7.0","eslint-config-prettier":"^4.1.0","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.16.0","eslint-plugin-mocha":"^5.3.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0",magicpen:"^6.0.2",mocha:"^6.0.2",nyc:"^13.3.0",prettier:"^1.16.4",unexpected:"^11.2.0"},directories:{},dist:{integrity:"sha512-BNV59p+oTWFF6Pw19QnBEGYV3W6pqRToGIGklXm0RQlE6M9SdLUPhd0QKlPln7LPrEnHvo9E1fPnW0OXJomRXw==",shasum:"5bf516bb9f8b0fd889548ca452c863cb30e843a1",tarball:"https://registry.npmjs.org/magicpen-prism/-/magicpen-prism-3.0.1.tgz",fileCount:4,unpackedSize:35339,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcjRcFCRA9TVsSAnZWagAA8rYP/3IN5mSBhOVXBTrb8sk9\nZ1BGaIzg0KdrYyEUm4S1njN8lfqenakc14MDRAD4huFMDH+TWpSdbKX5qj5x\nzoBqQK6H0XlQdQ5vag3pONBz9OGU6mxqjM4pnhogYDWV0SlXjyXuc3PSvQ6H\nRKyJrH7HwSV5gu7DDY9a0gsajXU4Ah6pER/HNGQXZCWESVduwa4EYzk1sqBx\njNvAQxUFfRYcSiVVwfo2ftBE6Muq7/DAyFUFJz8eblFSX4kB5+uopmVHyFEX\ntbhfl1Qyxszrmr/rDuzNi5gecG4tauF6/D3NCtMxR1NOxcsSv2MJiz3FoqT2\nUmKTn+P/Pb7GLNcj73mPF2s6wDXBBrytJR8pIOMD22yV3ZZH0PqD4DsQvjHK\nYnSp+kLVSeB7NdALB+xNVFxRg2fg6rE8CiQJzFt/v+MUsDdMX0sqRGe9n9Eo\nzIASOAJTrbXfC9Ulf01C1mGSbrN779fkKF9tC9k7W+NXziI0EKjn/r8AXe75\nSOXAEVmvafI+35WUlHn1/ho97O3wr+pngEFOERpEX1+NSIbOanSww3LnrLW+\njMEIGGj7N3q7m4zAZdn4giYjekVewLoGMTF9oCzIOcWsYqcbKeVRSFB9YyPt\nOqSkAK8yg2ygtKAgq5+ubXJFxmA6zcT07Zd9GVrUqM94xveCzsUxAtR2NUqG\nVcH0\r\n=evAJ\r\n-----END PGP SIGNATURE-----\r\n"},gitHead:"2c72f21e3d1750bcee977867de28a79be3f1e21b",homepage:"https://github.com/unexpectedjs/magicpen-prism#readme",main:"lib/magicPenPrism.js",maintainers:[{name:"alexjeffburke",email:"alex@alexjeffburke.com"},{name:"gustavnikolaj",email:"gustavnikolaj@gmail.com"},{name:"joelmukuthu",email:"joelmukuthu@gmail.com"},{name:"papandreou",email:"andreaslindpetersen@gmail.com"},{name:"sunesimonsen",email:"sune@we-knowhow.dk"}],name:"magicpen-prism",nyc:{include:["lib/**"]},optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/unexpectedjs/magicpen-prism.git"},scripts:{ci:"npm run lint && npm run coverage",coverage:"NODE_ENV=development nyc --reporter=lcov --reporter=text --all -- npm test && echo google-chrome coverage/lcov-report/index.html",lint:"eslint . && prettier --check '**/*.js'",prepublish:"browserify -p bundle-collapser/plugin -e lib/magicPenPrism -s magicPenPrism > magicPenPrism.min.js",test:"mocha"},version:"3.0.1"}},{}],5:[function(require,module,exports){Prism.languages.csp={directive:{pattern:/\b(?:(?:base-uri|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox) |(?:block-all-mixed-content|disown-opener|upgrade-insecure-requests)(?: |;)|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src )/i,alias:"keyword"},safe:{pattern:/'(?:self|none|strict-dynamic|(?:nonce-|sha(?:256|384|512)-)[a-zA-Z\d+=/]+)'/,alias:"selector"},unsafe:{pattern:/(?:'unsafe-inline'|'unsafe-eval'|'unsafe-hashed-attributes'|\*)/,alias:"function"}}},{}],6:[function(require,module,exports){Prism.languages.graphql={comment:/#.*/,string:{pattern:/"(?:\\.|[^\\"\r\n])*"/,greedy:true},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:/\b(?:true|false)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:"function"},"attr-name":{pattern:/[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,greedy:true},"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/,lookbehind:true},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,lookbehind:true,alias:"function"},keyword:/\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/,operator:/[!=|]|\.{3}/,punctuation:/[!(){}\[\]:=,]/,constant:/\b(?!ID\b)[A-Z][A-Z_\d]*\b/}},{}],7:[function(require,module,exports){(function(global){var _self=typeof window!=="undefined"?window:typeof WorkerGlobalScope!=="undefined"&&self instanceof WorkerGlobalScope?self:{};var Prism=function(_self){var lang=/\blang(?:uage)?-([\w-]+)\b/i;var uniqueId=0;var _={manual:_self.Prism&&_self.Prism.manual,disableWorkerMessageHandler:_self.Prism&&_self.Prism.disableWorkerMessageHandler,util:{encode:function(tokens){if(tokens instanceof Token){return new Token(tokens.type,_.util.encode(tokens.content),tokens.alias)}else if(Array.isArray(tokens)){return tokens.map(_.util.encode)}else{return tokens.replace(/&/g,"&").replace(/text.length){return}if(str instanceof Token){continue}if(greedy&&i!=strarr.length-1){pattern.lastIndex=pos;var match=pattern.exec(text);if(!match){break}var from=match.index+(lookbehind?match[1].length:0),to=match.index+match[0].length,k=i,p=pos;for(var len=strarr.length;k=p){++i;pos=p}}if(strarr[i]instanceof Token){continue}delNum=k-i;str=text.slice(pos,p);match.index-=pos}else{pattern.lastIndex=0;var match=pattern.exec(str),delNum=1}if(!match){if(oneshot){break}continue}if(lookbehind){lookbehindLength=match[1]?match[1].length:0}var from=match.index+lookbehindLength,match=match[0].slice(lookbehindLength),to=from+match.length,before=str.slice(0,from),after=str.slice(to);var args=[i,delNum];if(before){++i;pos+=before.length;args.push(before)}var wrapped=new Token(token,inside?_.tokenize(match,inside):match,alias,match,greedy);args.push(wrapped);if(after){args.push(after)}Array.prototype.splice.apply(strarr,args);if(delNum!=1)_.matchGrammar(text,strarr,grammar,i,pos,true,token);if(oneshot)break}}}},tokenize:function(text,grammar){var strarr=[text];var rest=grammar.rest;if(rest){for(var token in rest){grammar[token]=rest[token]}delete grammar.rest}_.matchGrammar(text,strarr,grammar,0,0,false);return strarr},hooks:{all:{},add:function(name,callback){var hooks=_.hooks.all;hooks[name]=hooks[name]||[];hooks[name].push(callback)},run:function(name,env){var callbacks=_.hooks.all[name];if(!callbacks||!callbacks.length){return}for(var i=0,callback;callback=callbacks[i++];){callback(env)}}},Token:Token};_self.Prism=_;function Token(type,content,alias,matchedStr,greedy){this.type=type;this.content=content;this.alias=alias;this.length=(matchedStr||"").length|0;this.greedy=!!greedy}Token.stringify=function(o,language,parent){if(typeof o=="string"){return o}if(Array.isArray(o)){return o.map(function(element){return Token.stringify(element,language,o)}).join("")}var env={type:o.type,content:Token.stringify(o.content,language,parent),tag:"span",classes:["token",o.type],attributes:{},language:language,parent:parent};if(o.alias){var aliases=Array.isArray(o.alias)?o.alias:[o.alias];Array.prototype.push.apply(env.classes,aliases)}_.hooks.run("wrap",env);var attributes=Object.keys(env.attributes).map(function(name){return name+'="'+(env.attributes[name]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+env.tag+' class="'+env.classes.join(" ")+'"'+(attributes?" "+attributes:"")+">"+env.content+""};if(!_self.document){if(!_self.addEventListener){return _}if(!_.disableWorkerMessageHandler){_self.addEventListener("message",function(evt){var message=JSON.parse(evt.data),lang=message.language,code=message.code,immediateClose=message.immediateClose;_self.postMessage(_.highlight(code,_.languages[lang],lang));if(immediateClose){_self.close()}},false)}return _}var script=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(script){_.filename=script.src;if(!_.manual&&!script.hasAttribute("data-manual")){if(document.readyState!=="loading"){if(window.requestAnimationFrame){window.requestAnimationFrame(_.highlightAll)}else{window.setTimeout(_.highlightAll,16)}}else{document.addEventListener("DOMContentLoaded",_.highlightAll)}}}return _}(_self);if(typeof module!=="undefined"&&module.exports){module.exports=Prism}if(typeof global!=="undefined"){global.Prism=Prism}Prism.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,greedy:true,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:true}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i};Prism.languages.markup["tag"].inside["attr-value"].inside["entity"]=Prism.languages.markup["entity"];Prism.hooks.add("wrap",function(env){if(env.type==="entity"){env.attributes["title"]=env.content.replace(/&/,"&")}});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function addInlined(tagName,lang){var includedCdataInside={};includedCdataInside["language-"+lang]={pattern:/(^$)/i,lookbehind:true,inside:Prism.languages[lang]};includedCdataInside["cdata"]=/^$/i;var inside={"included-cdata":{pattern://i,inside:includedCdataInside}};inside["language-"+lang]={pattern:/[\s\S]+/,inside:Prism.languages[lang]};var def={};def[tagName]={pattern:RegExp(/(<__[\s\S]*?>)(?:\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g,tagName),"i"),lookbehind:true,greedy:true,inside:inside};Prism.languages.insertBefore("markup","cdata",def)}});Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;(function(Prism){var string=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:RegExp("url\\((?:"+string.source+"|.*?)\\)","i"),selector:RegExp("[^{}\\s](?:[^{};\"']|"+string.source+")*?(?=\\s*\\{)"),string:{pattern:string,greedy:true},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/};Prism.languages.css["atrule"].inside.rest=Prism.languages.css;var markup=Prism.languages.markup;if(markup){markup.tag.addInlined("style","css");Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},markup.tag)}})(Prism);Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:true},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:true,greedy:true}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:true},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,lookbehind:true,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(?:true|false)\b/,function:/\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/};Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:true}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:true},{pattern:/(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:true}],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,function:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:true,greedy:true},"function-variable":{pattern:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:true,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:true,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:true,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:true,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}});if(Prism.languages.markup){Prism.languages.markup.tag.addInlined("script","javascript")}Prism.languages.js=Prism.languages.javascript;(function(){if(typeof self==="undefined"||!self.Prism||!self.document||!document.querySelector){return}self.Prism.fileHighlight=function(container){container=container||document;var Extensions={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.slice.call(container.querySelectorAll("pre[data-src]")).forEach(function(pre){if(pre.hasAttribute("data-src-loaded")){return}var src=pre.getAttribute("data-src");var language,parent=pre;var lang=/\blang(?:uage)?-([\w-]+)\b/i;while(parent&&!lang.test(parent.className)){parent=parent.parentNode}if(parent){language=(pre.className.match(lang)||[,""])[1]}if(!language){var extension=(src.match(/\.(\w+)$/)||[,""])[1];language=Extensions[extension]||extension}var code=document.createElement("code");code.className="language-"+language;pre.textContent="";code.textContent="Loading…";pre.appendChild(code);var xhr=new XMLHttpRequest;xhr.open("GET",src,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status<400&&xhr.responseText){code.textContent=xhr.responseText;Prism.highlightElement(code);pre.setAttribute("data-src-loaded","")}else if(xhr.status>=400){code.textContent="✖ Error "+xhr.status+" while fetching file: "+xhr.statusText}else{code.textContent="✖ Error: File does not exist or is empty"}}};xhr.send(null)});if(Prism.plugins.toolbar){Prism.plugins.toolbar.registerButton("download-file",function(env){var pre=env.element.parentNode;if(!pre||!/pre/i.test(pre.nodeName)||!pre.hasAttribute("data-src")||!pre.hasAttribute("data-download-link")){return}var src=pre.getAttribute("data-src");var a=document.createElement("a");a.textContent=pre.getAttribute("data-download-link-label")||"Download";a.setAttribute("download","");a.href=src;return a})}};document.addEventListener("DOMContentLoaded",function(){self.Prism.fileHighlight()})})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)});