Fix a few Transition-related tests
This commit is contained in:
16
src/lib/components/listbox/listbox.test.ts
vendored
16
src/lib/components/listbox/listbox.test.ts
vendored
@@ -63,6 +63,16 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
afterAll(() => jest.restoreAllMocks())
|
afterAll(() => jest.restoreAllMocks())
|
||||||
|
|
||||||
|
function nextFrame() {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('safeguards', () => {
|
describe('safeguards', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['ListboxButton', ListboxButton],
|
['ListboxButton', ListboxButton],
|
||||||
@@ -610,8 +620,7 @@ describe('Rendering composition', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe('Composition', () => {
|
describe('Composition', () => {
|
||||||
// TODO: fix this test
|
it(
|
||||||
it.skip(
|
|
||||||
'should be possible to wrap the ListboxOptions with a Transition component',
|
'should be possible to wrap the ListboxOptions with a Transition component',
|
||||||
suppressConsoleLogs(async () => {
|
suppressConsoleLogs(async () => {
|
||||||
let orderFn = jest.fn()
|
let orderFn = jest.fn()
|
||||||
@@ -653,6 +662,9 @@ describe('Composition', () => {
|
|||||||
|
|
||||||
await click(getListboxButton())
|
await click(getListboxButton())
|
||||||
|
|
||||||
|
// Wait for all transitions to finish
|
||||||
|
await nextFrame()
|
||||||
|
|
||||||
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
||||||
expect(orderFn.mock.calls).toEqual([
|
expect(orderFn.mock.calls).toEqual([
|
||||||
['Mounting - Listbox'],
|
['Mounting - Listbox'],
|
||||||
|
|||||||
22
src/lib/components/menu/menu.test.ts
vendored
22
src/lib/components/menu/menu.test.ts
vendored
@@ -26,6 +26,16 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
afterAll(() => jest.restoreAllMocks())
|
afterAll(() => jest.restoreAllMocks())
|
||||||
|
|
||||||
|
function nextFrame() {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('Safe guards', () => {
|
describe('Safe guards', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['MenuButton', MenuButton],
|
['MenuButton', MenuButton],
|
||||||
@@ -464,7 +474,7 @@ describe('Rendering composition', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Composition', () => {
|
describe('Composition', () => {
|
||||||
it.skip(
|
it(
|
||||||
'should be possible to wrap the MenuItems with a Transition component',
|
'should be possible to wrap the MenuItems with a Transition component',
|
||||||
suppressConsoleLogs(async () => {
|
suppressConsoleLogs(async () => {
|
||||||
let orderFn = jest.fn()
|
let orderFn = jest.fn()
|
||||||
@@ -506,6 +516,9 @@ describe('Composition', () => {
|
|||||||
|
|
||||||
await click(getMenuButton())
|
await click(getMenuButton())
|
||||||
|
|
||||||
|
// Wait for all transitions to finish
|
||||||
|
await nextFrame()
|
||||||
|
|
||||||
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
||||||
expect(orderFn.mock.calls).toEqual([
|
expect(orderFn.mock.calls).toEqual([
|
||||||
['Mounting - Menu'],
|
['Mounting - Menu'],
|
||||||
@@ -517,8 +530,8 @@ describe('Composition', () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
it.skip(
|
it(
|
||||||
'should be possible to wrap the MenuItems with a Transition.Child component',
|
'should be possible to wrap the MenuItems with a TransitionChild component',
|
||||||
suppressConsoleLogs(async () => {
|
suppressConsoleLogs(async () => {
|
||||||
let orderFn = jest.fn()
|
let orderFn = jest.fn()
|
||||||
render(
|
render(
|
||||||
@@ -559,6 +572,9 @@ describe('Composition', () => {
|
|||||||
|
|
||||||
await click(getMenuButton())
|
await click(getMenuButton())
|
||||||
|
|
||||||
|
// Wait for all transitions to finish
|
||||||
|
await nextFrame()
|
||||||
|
|
||||||
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
// Verify that we tracked the `mounts` and `unmounts` in the correct order
|
||||||
expect(orderFn.mock.calls).toEqual([
|
expect(orderFn.mock.calls).toEqual([
|
||||||
['Mounting - Menu'],
|
['Mounting - Menu'],
|
||||||
|
|||||||
Reference in New Issue
Block a user