diff --git a/packages/dapp-kit-ui/test/listeners.test.ts b/packages/dapp-kit-ui/test/listeners.test.ts new file mode 100644 index 00000000..e0d55d37 --- /dev/null +++ b/packages/dapp-kit-ui/test/listeners.test.ts @@ -0,0 +1,24 @@ +import { vi } from 'vitest'; +import { addResizeListeners } from '../src/utils/listeners'; // Replace 'yourModule' with the actual module path + +describe('addResizeListeners', () => { + it('should call the callback when the window loads', () => { + const callback = vi.fn(); + addResizeListeners(callback); + + // Simulate a 'load' event on the window + window.dispatchEvent(new Event('load')); + + expect(callback).toHaveBeenCalled(); + }); + + it('should call the callback when the window resizes', () => { + const callback = vi.fn(); + addResizeListeners(callback); + + // Simulate a 'resize' event on the window + window.dispatchEvent(new Event('resize')); + + expect(callback).toHaveBeenCalled(); + }); +}); diff --git a/packages/dapp-kit-ui/tsconfig.json b/packages/dapp-kit-ui/tsconfig.json index 49edcff3..17cd689c 100644 --- a/packages/dapp-kit-ui/tsconfig.json +++ b/packages/dapp-kit-ui/tsconfig.json @@ -4,6 +4,6 @@ "target": "es2021", "experimentalDecorators": true }, - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "test/listeners.test.ts"], "exclude": [] }