-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cole
committed
Jun 21, 2024
1 parent
19bc13b
commit 8fadc87
Showing
5 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 11 additions & 12 deletions
23
src/packages/resize-observer/__tests__/ResizeObserver.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
import ResizeObserver from '../index' | ||
import mountTest from '../../../../tests/shared/mountTest' | ||
import MockResizeObserver from '../../../../tests/__mocks__/resize-observer' | ||
|
||
describe('ResizeObserver', () => { | ||
it(`render`, async () => { | ||
const wrapper = mount(ResizeObserver, { | ||
slots: { | ||
default: () => { | ||
return ( | ||
<div style={{ height: '200px' }}/> | ||
) | ||
} | ||
} | ||
}) | ||
expect(wrapper.exists()).toBeTruthy() | ||
beforeEach(() => { | ||
window.ResizeObserver = MockResizeObserver | ||
}) | ||
|
||
mountTest(ResizeObserver) | ||
it(`emits resize`, async () => { | ||
const wrapper = mount(ResizeObserver) | ||
expect(wrapper.emitted()).toHaveProperty('resize') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class ResizeObserver { | ||
constructor (callback) { | ||
const entry = { | ||
contentRect: { width: 1024, height: 768 } | ||
} | ||
callback([entry]) | ||
} | ||
|
||
observe () { | ||
} | ||
|
||
unobserve () { | ||
} | ||
|
||
disconnect () { | ||
} | ||
} | ||
|
||
export default ResizeObserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters