From 94f580113daaeef391301f635ea43a8c9dcf5932 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 20 Feb 2019 21:17:27 +0100 Subject: [PATCH 1/2] Relax the inline style validation in expectations I don't think our current regex is anywhere near smart enough to recognize all valid style values. So I'm going to relax the validation. --- src/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index f4bda178..56217998 100644 --- a/src/index.js +++ b/src/index.js @@ -87,9 +87,7 @@ function validateStyles(expect, str) { .split(';') .filter( part => - !/^\s*(\w|-)+\s*:\s*(#(?:[0-9a-fA-F]{3}){1,2}|(\w|-)+)\s*$|^$/.test( - part - ) + !/^\s*(\w|-)+\s*:\s*(#(?:[0-9a-fA-F]{3}){1,2}|[^#]+)\s*$|^$/.test(part) ); if (invalidStyles.length > 0) { From a524844e5fed86e65c9b28c4a4a32280ba838489 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 20 Feb 2019 21:48:18 +0100 Subject: [PATCH 2/2] Fixing linting problem It seems like some default eslint configuration has changed when run with the latest dependencies that matches our ranges. I changed the tactic to make assigning to the global document in the test a bit more explicit. --- test/index.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/index.spec.js b/test/index.spec.js index a5c8de3f..ce3b6ff3 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1,4 +1,4 @@ -/*global expect, jsdom, sinon, describe, it, beforeEach, afterEach, document:true, DOMParser:true*/ +/*global expect, jsdom, sinon, describe, it, beforeEach, afterEach, DOMParser:true*/ expect.addAssertion( ' to inspect as ', (expect, subject, value) => { @@ -2577,6 +2577,7 @@ describe('unexpected-dom', () => { DOMParser = undefined; // force the "implementation" path originalDocument = root.document; + // eslint-disable-next-line no-global-assign document = { implementation: { createHTMLDocument: (createHTMLDocumentSpy = sinon @@ -2587,8 +2588,10 @@ describe('unexpected-dom', () => { } }; }); + afterEach(() => { DOMParser = OriginalDOMParser; + // eslint-disable-next-line no-global-assign document = originalDocument; });