Skip to content

Commit b56697f

Browse files
committed
fix: tests fixed
1 parent 00b296f commit b56697f

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/test/tooltip-interaction-behavior.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,20 @@ describe('tooltip interaction behavior', () => {
8686
await waitForTooltip('global-events-test')
8787

8888
fireEvent.scroll(window)
89+
advanceTimers(100)
8990
await flushMicrotasks()
9091
await waitForTooltipToStopShowing('global-events-test')
9192

93+
// Allow the tooltip to fully unmount before re-hovering
94+
advanceTimers(100)
95+
await flushMicrotasks()
96+
9297
hoverAnchor(anchor, 1000)
98+
await flushMicrotasks()
9399
await waitForTooltip('global-events-test')
94100

95101
fireEvent.resize(window)
102+
advanceTimers(100)
96103
await flushMicrotasks()
97104
await waitForTooltipToStopShowing('global-events-test')
98105
})

src/test/tooltip-styling.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ describe('tooltip styling and appearance', () => {
100100

101101
const tooltip = await hoverAndFindTooltip()
102102

103-
expect(tooltip).toHaveStyle({
104-
backgroundColor: 'purple',
105-
color: 'white',
106-
borderRadius: '10px',
107-
})
103+
expect(tooltip.style.backgroundColor).toBe('purple')
104+
expect(tooltip.style.color).toBe('white')
105+
expect(tooltip.style.borderRadius).toBe('10px')
108106
})
109107

110108
test('tooltip with custom opacity', async () => {

src/test/utils.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ describe('debounce', () => {
120120

121121
const func = jest.fn()
122122

123+
afterEach(() => {
124+
func.mockClear()
125+
jest.clearAllTimers()
126+
})
127+
123128
test('execute just once', () => {
124129
const debouncedFunc = debounce(func, 1000)
125130
for (let i = 0; i < 100; i += 1) {
@@ -130,14 +135,14 @@ describe('debounce', () => {
130135

131136
jest.runAllTimers()
132137

133-
expect(func).toBeCalledTimes(1)
138+
expect(func).toHaveBeenCalledTimes(1)
134139
})
135140

136141
test('execute immediately just once', () => {
137142
const debouncedFunc = debounce(func, 1000, true)
138143

139144
debouncedFunc()
140-
expect(func).toBeCalledTimes(1)
145+
expect(func).toHaveBeenCalledTimes(1)
141146

142147
for (let i = 0; i < 100; i += 1) {
143148
debouncedFunc()

0 commit comments

Comments
 (0)