@ui5/cra-template-webcomponents-react
Advanced tools
Comparing version 0.17.1 to 0.17.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.17.3](https://github.com/SAP/ui5-webcomponents-react/compare/v0.17.2...v0.17.3) (2021-08-02) | ||
### Bug Fixes | ||
* improve setupMatchMedia for cra-templates and docs ([#1909](https://github.com/SAP/ui5-webcomponents-react/issues/1909)) ([d8ef7a1](https://github.com/SAP/ui5-webcomponents-react/commit/d8ef7a130d09229f2c5f9b4d3fa3ee67f0e6e256)) | ||
## [0.17.1](https://github.com/SAP/ui5-webcomponents-react/compare/v0.17.0...v0.17.1) (2021-07-16) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@ui5/cra-template-webcomponents-react", | ||
"version": "0.17.1", | ||
"version": "0.17.3", | ||
"keywords": [ | ||
@@ -33,3 +33,3 @@ "react", | ||
}, | ||
"gitHead": "b4a4d8de8b858894fa77bee88a3a8533d754bd2b" | ||
"gitHead": "90517f3c31cfab7ad87a866ae9e8fada272da220" | ||
} |
@@ -6,3 +6,3 @@ // jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import ResiveObserverPolyfill from 'resize-observer-polyfill'; | ||
import ResizeObserverPolyfill from 'resize-observer-polyfill'; | ||
@@ -12,12 +12,24 @@ const setupMatchMedia = () => { | ||
writable: true, | ||
value: jest.fn().mockImplementation((query) => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), // deprecated | ||
removeListener: jest.fn(), // deprecated | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
dispatchEvent: jest.fn() | ||
})) | ||
value: jest.fn().mockImplementation((query) => { | ||
const maxWidth = parseInt(/max-width:(?<maxWidth>\d+)px/.exec(query)?.groups?.maxWidth); | ||
const minWidth = parseInt(/min-width:(?<minWidth>\d+)px/.exec(query)?.groups?.minWidth); | ||
let matches = | ||
(minWidth ? minWidth <= window.innerWidth : true) && (maxWidth ? window.innerWidth <= maxWidth : true); | ||
if (query === '(orientation: landscape)') { | ||
matches = window.innerWidth > window.innerHeight; | ||
} | ||
return { | ||
matches, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), // deprecated | ||
removeListener: jest.fn(), // deprecated | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
dispatchEvent: jest.fn() | ||
}; | ||
}) | ||
}); | ||
@@ -28,3 +40,3 @@ }; | ||
setupMatchMedia(); | ||
window.ResizeObserver = ResiveObserverPolyfill; | ||
window.ResizeObserver = ResizeObserverPolyfill; | ||
}); |
60019
291