@@ -12,9 +12,11 @@ class MyWidget extends WidgetBase<{
12
12
prependChild ?: boolean ;
13
13
appendChild ?: boolean ;
14
14
replaceChild ?: boolean ;
15
+ before ?: boolean ;
16
+ after ?: boolean ;
15
17
} > {
16
18
render ( ) {
17
- const { toggleProperty, prependChild, appendChild, replaceChild } = this . properties ;
19
+ const { toggleProperty, prependChild, appendChild, replaceChild, before , after } = this . properties ;
18
20
let children = [ 'hello' ] ;
19
21
if ( prependChild ) {
20
22
children = [ 'prepend' , ...children ] ;
@@ -27,7 +29,9 @@ class MyWidget extends WidgetBase<{
27
29
}
28
30
return v ( 'div' , { classes : [ 'root' ] } , [
29
31
v ( 'h2' , children ) ,
30
- v ( 'ul' , [ v ( 'li' , { foo : toggleProperty ? 'b' : 'a' } , [ 'one' ] ) , v ( 'li' , [ 'two' ] ) , v ( 'li' , [ 'three' ] ) ] )
32
+ before ? v ( 'span' , [ 'before' ] ) : undefined ,
33
+ v ( 'ul' , [ v ( 'li' , { foo : toggleProperty ? 'b' : 'a' } , [ 'one' ] ) , v ( 'li' , [ 'two' ] ) , v ( 'li' , [ 'three' ] ) ] ) ,
34
+ after ? v ( 'span' , [ 'after' ] ) : undefined
31
35
] ) ;
32
36
}
33
37
}
@@ -98,6 +102,18 @@ describe('assertionTemplate', () => {
98
102
h . expect ( childAssertion ) ;
99
103
} ) ;
100
104
105
+ it ( 'can set children after with insert' , ( ) => {
106
+ const h = harness ( ( ) => w ( MyWidget , { after : true } ) ) ;
107
+ const childAssertion = baseAssertion . insertChildren ( 'ul' , [ v ( 'span' , [ 'after' ] ) ] ) ;
108
+ h . expect ( childAssertion ) ;
109
+ } ) ;
110
+
111
+ it ( 'can set children before with insert' , ( ) => {
112
+ const h = harness ( ( ) => w ( MyWidget , { before : true } ) ) ;
113
+ const childAssertion = baseAssertion . insertChildren ( 'ul' , [ v ( 'span' , [ 'before' ] ) ] , 'before' ) ;
114
+ h . expect ( childAssertion ) ;
115
+ } ) ;
116
+
101
117
it ( 'can be used with tsx' , ( ) => {
102
118
const h = harness ( ( ) => < MyWidget toggleProperty = { true } /> ) ;
103
119
const propertyAssertion = tsxAssertion . setProperty ( '~li-one' , 'foo' , 'b' ) ;
0 commit comments