1- import { expect , it , vi } from "vitest" ;
1+ import { expect , it } from "vitest" ;
22import { render } from "vitest-browser-svelte" ;
33import type { Component } from "svelte" ;
44import { getTestKbd } from "../utils.js" ;
@@ -56,7 +56,7 @@ it("should close on escape keydown", async () => {
5656 await expectNotExists ( page . getByTestId ( "content" ) ) ;
5757} ) ;
5858
59- it . skip ( "should close when pointer moves outside the trigger and content" , async ( ) => {
59+ it ( "should close when pointer moves outside the trigger and content" , async ( ) => {
6060 await open ( ) ;
6161
6262 const outside = page . getByTestId ( "outside" ) ;
@@ -66,6 +66,23 @@ it.skip("should close when pointer moves outside the trigger and content", async
6666 await expectNotExists ( page . getByTestId ( "content" ) ) ;
6767} ) ;
6868
69+ it ( "should stay open when hovering content" , async ( ) => {
70+ const t = await open ( ) ;
71+ await t . content . hover ( ) ;
72+ await expectExists ( page . getByTestId ( "content" ) ) ;
73+ } ) ;
74+
75+ it ( "should open on focus and close on blur" , async ( ) => {
76+ const t = setup ( ) ;
77+ await expectNotExists ( page . getByTestId ( "content" ) ) ;
78+
79+ ( t . trigger . element ( ) as HTMLElement ) . focus ( ) ;
80+ await expectExists ( page . getByTestId ( "content" ) ) ;
81+
82+ ( t . trigger . element ( ) as HTMLElement ) . blur ( ) ;
83+ await expectNotExists ( page . getByTestId ( "content" ) ) ;
84+ } ) ;
85+
6986it ( "should portal to the body by default" , async ( ) => {
7087 const t = await open ( ) ;
7188 const contentWrapper = t . content . element ( ) . parentElement ;
@@ -98,17 +115,12 @@ it("should allow ignoring escapeKeydownBehavior ", async () => {
98115} ) ;
99116
100117it ( "should respect binding the open prop" , async ( ) => {
101- await open ( {
102- contentProps : {
103- interactOutsideBehavior : "ignore" ,
104- } ,
105- } ) ;
118+ await open ( ) ;
106119 const binding = page . getByTestId ( "binding" ) ;
107- await vi . waitFor ( ( ) => expect ( binding ) . toHaveTextContent ( "true" ) ) ;
108120 await expect . element ( binding ) . toHaveTextContent ( "true" ) ;
109- await binding . click ( ) ;
110- await expect . element ( binding ) . toHaveTextContent ( "false" ) ;
121+ await userEvent . keyboard ( kbd . ESCAPE ) ;
111122 await expectNotExists ( page . getByTestId ( "content" ) ) ;
123+ await expect . element ( binding ) . toHaveTextContent ( "false" ) ;
112124 await binding . click ( ) ;
113125 await expect . element ( binding ) . toHaveTextContent ( "true" ) ;
114126 await expectExists ( page . getByTestId ( "content" ) ) ;
0 commit comments