@@ -57,10 +57,59 @@ describe("getActiveWindow", () => {
5757 expect ( activeWindowRect . width ) . toBe ( WIDTH ) ;
5858 expect ( activeWindowRect . height ) . toBe ( HEIGTH ) ;
5959 } ) ;
60+
61+ it ( "should determine correct coordinates for our application after moving the window" , async ( ) => {
62+ // GIVEN
63+ const xPosition = 42 ;
64+ const yPosition = 23 ;
65+ await app . browserWindow . setPosition ( xPosition , yPosition ) ;
66+
67+ // WHEN
68+ const activeWindowHandle = libnut . getActiveWindow ( ) ;
69+ const activeWindowRect = libnut . getWindowRect ( activeWindowHandle ) ;
70+
71+ // THEN
72+ expect ( activeWindowRect . x ) . toBe ( xPosition ) ;
73+ expect ( activeWindowRect . y ) . toBe ( yPosition ) ;
74+ } ) ;
75+
76+ it ( "should determine correct window size for our application after resizing the window" , async ( ) => {
77+ // GIVEN
78+ const newWidth = 400 ;
79+ const newHeight = 250 ;
80+ await app . browserWindow . setSize ( newWidth , newHeight ) ;
81+
82+ // WHEN
83+ const activeWindowHandle = libnut . getActiveWindow ( ) ;
84+ const activeWindowRect = libnut . getWindowRect ( activeWindowHandle ) ;
85+
86+ // THEN
87+ expect ( activeWindowRect . width ) . toBe ( newWidth ) ;
88+ expect ( activeWindowRect . height ) . toBe ( newHeight ) ;
89+ } ) ;
90+
91+ it ( "should return (0,0,0,0) by default for a minimized window" , async ( ) => {
92+ // GIVEN
93+ const xPosition = 0 ;
94+ const yPosition = 0 ;
95+ const width = 0 ;
96+ const height = 0 ;
97+ await app . browserWindow . minimize ( ) ;
98+
99+ // WHEN
100+ const activeWindowHandle = libnut . getActiveWindow ( ) ;
101+ const activeWindowRect = libnut . getWindowRect ( activeWindowHandle ) ;
102+
103+ // THEN
104+ expect ( activeWindowRect . x ) . toBe ( xPosition ) ;
105+ expect ( activeWindowRect . y ) . toBe ( yPosition ) ;
106+ expect ( activeWindowRect . width ) . toBe ( width ) ;
107+ expect ( activeWindowRect . height ) . toBe ( height ) ;
108+ } ) ;
60109} ) ;
61110
62111afterAll ( async ( ) => {
63112 if ( app && app . isRunning ( ) ) {
64113 await app . stop ( ) ;
65114 }
66- } ) ;
115+ } ) ;
0 commit comments