Skip to content

Commit

Permalink
test: add vi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecarpini committed Nov 21, 2023
1 parent 0393476 commit d470537
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions packages/dapp-kit-ui/test/listeners.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"target": "es2021",
"experimentalDecorators": true
},
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "test/listeners.test.ts"],
"exclude": []
}

0 comments on commit d470537

Please sign in to comment.