diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f4aa9..3ff24f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -## 1.0.0 (2024-08-23) +## 1.0.0 (2024-08-24) * test(hooks): 添加对useBoolean和useToggle和useTitle的单元测试 ([8951ad9](https://github.com/zjydipingxian/hooks-encode/commit/8951ad9)) +* test(hooks): 添加useDebounce和useThrottle的测试 ([2d5539a](https://github.com/zjydipingxian/hooks-encode/commit/2d5539a)) * test(hooks): 新增useThrottle的测试用例 ([8288fd3](https://github.com/zjydipingxian/hooks-encode/commit/8288fd3)) * refactor(cli): 将CLI入口文件和实用程序模块转换为TypeScript ([e2243be](https://github.com/zjydipingxian/hooks-encode/commit/e2243be)) * refactor(cli): 使用 prettier 格式化代码并更新导入逻辑 ([b626f83](https://github.com/zjydipingxian/hooks-encode/commit/b626f83)) diff --git a/packages/hooks/src/useOnline/index.ts b/packages/hooks/src/useOnline/index.ts index 9063393..1ed38fc 100644 --- a/packages/hooks/src/useOnline/index.ts +++ b/packages/hooks/src/useOnline/index.ts @@ -1,5 +1,4 @@ import { ref, onMounted, onUnmounted } from 'vue'; -import useEventListener from '../useEventListener'; /** * @description 用户网络是否可用 diff --git a/packages/hooks/src/useRect/__tests__/index.test.ts b/packages/hooks/src/useRect/__tests__/index.test.ts new file mode 100644 index 0000000..29e82da --- /dev/null +++ b/packages/hooks/src/useRect/__tests__/index.test.ts @@ -0,0 +1,25 @@ +import { describe, expect, it } from '@jest/globals'; +import { ref } from 'vue'; + +import useRect from '../index'; + +describe('useRect', () => { + it('should return the correct DOMRect for a window', () => { + const rect = useRect(window); + expect(rect.width).toEqual(window.innerWidth); + expect(rect.height).toEqual(window.innerHeight); + }); + + it('should return the correct DOMRect for an element with getBoundingClientRect', () => { + const element = document.createElement('div'); + const rect = useRect(element); + expect(rect.width).toEqual(element.getBoundingClientRect().width); + expect(rect.height).toEqual(element.getBoundingClientRect().height); + }); + + it('should return a default DOMRect for an undefined element', () => { + const rect = useRect(ref(undefined)); + expect(rect.width).toEqual(0); + expect(rect.height).toEqual(0); + }); +});