@@ -238,6 +238,39 @@ describe('element', () => {
238
238
} ) ;
239
239
} ) ;
240
240
241
+ describe ( 'contains' , ( ) => {
242
+ it ( 'returns true when a node is an direct child of a given node' , ( ) => {
243
+ const root = document . createElement ( 'div' ) ;
244
+ const span = document . createElement ( 'span' ) ;
245
+
246
+ root . appendChild ( span ) ;
247
+
248
+ expect ( root . contains ( span ) ) . toEqual ( true ) ;
249
+ } ) ;
250
+
251
+ it ( 'returns true when a node is an indirect child of a given node' , ( ) => {
252
+ const root = document . createElement ( 'div' ) ;
253
+ const span = document . createElement ( 'span' ) ;
254
+ const h1 = document . createElement ( 'h1' ) ;
255
+
256
+ root . appendChild ( span ) ;
257
+ span . appendChild ( h1 ) ;
258
+
259
+ expect ( root . contains ( h1 ) ) . toEqual ( true ) ;
260
+ } ) ;
261
+
262
+ it ( 'returns true when a node is the given node itself' , ( ) => {
263
+ const root = document . createElement ( 'div' ) ;
264
+ expect ( root . contains ( root ) ) . toEqual ( true ) ;
265
+ } ) ;
266
+
267
+ it ( 'returns false when a node is not the given node itself or not a descendant of the given node ' , ( ) => {
268
+ const root = document . createElement ( 'div' ) ;
269
+ const span = document . createElement ( 'span' ) ;
270
+ expect ( root . contains ( span ) ) . toEqual ( false ) ;
271
+ } ) ;
272
+ } ) ;
273
+
241
274
describe ( 'isConnected' , ( ) => {
242
275
it ( 'nested true' , ( ) => {
243
276
const elmParent = document . createElement ( 'div' ) ;
0 commit comments