Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dom-resize-observer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dom-resize-observer - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

71

dist/hooks/__tests__/useResizeObserver.test.jsx

@@ -13,7 +13,2 @@ "use strict";

class ResizeObserver {
constructor(callback) {
this.callback = function (entries) {
console.log(entries);
};
}
observe() {

@@ -64,1 +59,67 @@ mockObserve();

});
it("returns the entry from the observer callback", () => {
let observerCallback = () => { };
class ResizeObserver {
constructor(callback) {
observerCallback = callback;
}
observe() { }
disconnect() { }
unobserve() { }
}
window.ResizeObserver = ResizeObserver;
const { result } = (0, react_1.renderHook)(() => (0, useResizeObserver_1.useResizeObserver)());
(0, react_1.act)(() => {
const el = document.createElement("div");
result.current.observer(el);
});
(0, react_1.act)(() => {
observerCallback([{ test: "test" }], new ResizeObserver(observerCallback));
});
expect(result.current.entry).toEqual({ test: "test" });
});
it("calls onResize callback if there are entries", () => {
let observerCallback = () => { };
class ResizeObserver {
constructor(callback) {
observerCallback = callback;
}
observe() { }
disconnect() { }
unobserve() { }
}
window.ResizeObserver = ResizeObserver;
const mockOnResize = jest.fn();
const { result } = (0, react_1.renderHook)(() => (0, useResizeObserver_1.useResizeObserver)(mockOnResize));
(0, react_1.act)(() => {
const el = document.createElement("div");
result.current.observer(el);
});
(0, react_1.act)(() => {
observerCallback([{ test: "test" }], new ResizeObserver(observerCallback));
});
expect(mockOnResize).toHaveBeenCalledTimes(1);
});
it("returns a null entry and does not call onResize if no rentries were called back", () => {
let observerCallback = () => { };
class ResizeObserver {
constructor(callback) {
observerCallback = callback;
}
observe() { }
disconnect() { }
unobserve() { }
}
window.ResizeObserver = ResizeObserver;
const mockOnResize = jest.fn();
const { result } = (0, react_1.renderHook)(() => (0, useResizeObserver_1.useResizeObserver)(mockOnResize));
(0, react_1.act)(() => {
const el = document.createElement("div");
result.current.observer(el);
});
(0, react_1.act)(() => {
observerCallback([], new ResizeObserver(observerCallback));
});
expect(result.current.entry).toBeNull();
expect(mockOnResize).not.toHaveBeenCalled();
});

2

package.json
{
"name": "react-dom-resize-observer",
"version": "0.1.3",
"version": "0.1.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc