UNPKG

@age/quantum

Version:
30 lines (22 loc) 884 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeCSS = exports.expectCSSMatches = exports.getCSS = void 0; var normalizeCSS = function normalizeCSS(rule) { return rule.join('\n').replace(/(?:\r\n|\r|\n)/g, '').replace(/ {\s+/g, '{').replace(/\s+ }/g, '}').replace(/,\s+/g, ',').replace(/;\s+/g, ';').replace(/:\s+/g, ':').replace(/:\s+;/g, ':;'); }; exports.normalizeCSS = normalizeCSS; var getCSS = function getCSS(scope) { return normalizeCSS(Array.from(scope.querySelectorAll('style')).map(function (tag) { return tag.innerHTML; })); }; exports.getCSS = getCSS; var expectCSSMatches = function expectCSSMatches(expectation) { var _expectation = normalizeCSS(expectation.split('\n')); var css = getCSS(document); expect(css).toContain(_expectation); return css; }; exports.expectCSSMatches = expectCSSMatches;