@@ -119,10 +119,21 @@ describe('Overlay directives', () => {
119
119
fixture . componentInstance . isOpen = true ;
120
120
fixture . detectChanges ( ) ;
121
121
122
- // expected x value is the starting x + offset x
123
- const expectedX = startX + 5 ;
124
122
const pane = overlayContainerElement . children [ 0 ] as HTMLElement ;
125
- expect ( pane . style . transform ) . toContain ( `translateX(${ expectedX } px)` ) ;
123
+ expect ( pane . style . transform )
124
+ . toContain ( `translateX(${ startX + 5 } px)` ,
125
+ `Expected overlay translateX to equal the original X + the offsetX.` ) ;
126
+
127
+ fixture . componentInstance . isOpen = false ;
128
+ fixture . detectChanges ( ) ;
129
+
130
+ fixture . componentInstance . offsetX = 15 ;
131
+ fixture . componentInstance . isOpen = true ;
132
+ fixture . detectChanges ( ) ;
133
+
134
+ expect ( pane . style . transform )
135
+ . toContain ( `translateX(${ startX + 15 } px)` ,
136
+ `Expected overlay directive to reflect new offsetX if it changes.` ) ;
126
137
} ) ;
127
138
128
139
it ( 'should set the offsetY' , ( ) => {
@@ -138,7 +149,19 @@ describe('Overlay directives', () => {
138
149
// expected y value is the starting y + trigger height + offset y
139
150
// 30 + 20 + 45 = 95px
140
151
const pane = overlayContainerElement . children [ 0 ] as HTMLElement ;
141
- expect ( pane . style . transform ) . toContain ( `translateY(95px)` ) ;
152
+ expect ( pane . style . transform )
153
+ . toContain ( `translateY(95px)` ,
154
+ `Expected overlay translateY to equal the start Y + height + offsetY.` ) ;
155
+
156
+ fixture . componentInstance . isOpen = false ;
157
+ fixture . detectChanges ( ) ;
158
+
159
+ fixture . componentInstance . offsetY = 55 ;
160
+ fixture . componentInstance . isOpen = true ;
161
+ fixture . detectChanges ( ) ;
162
+ expect ( pane . style . transform )
163
+ . toContain ( `translateY(105px)` ,
164
+ `Expected overlay directive to reflect new offsetY if it changes.` ) ;
142
165
} ) ;
143
166
144
167
} ) ;
0 commit comments