@@ -111,6 +111,39 @@ test('should find by name beginning with', (_context, document) => {
111111 ] )
112112} )
113113
114+ test ( 'should find by full name match ignoring case' , ( _context , document ) => {
115+ // eslint-disable-next-line no-param-reassign
116+ document . pages = [
117+ {
118+ layers : [
119+ { type : 'Artboard' } ,
120+ { type : 'Shape' , name : 'test' } ,
121+ { type : 'Shape' , name : 'test2' } ,
122+ ] ,
123+ } ,
124+ ]
125+ expect ( find ( '[name~="tEsT"]' , document ) . map ( ( x ) => x . id ) ) . toEqual ( [
126+ document . pages [ 0 ] . layers [ 1 ] . id ,
127+ ] )
128+ } )
129+
130+ test ( 'should find by partial name ignoring case' , ( _context , document ) => {
131+ // eslint-disable-next-line no-param-reassign
132+ document . pages = [
133+ {
134+ layers : [
135+ { type : 'Artboard' } ,
136+ { type : 'Shape' , name : 'test' } ,
137+ { type : 'Shape' , name : 'test2' } ,
138+ ] ,
139+ } ,
140+ ]
141+ expect ( find ( '[name~*="tEsT"]' , document ) . map ( ( x ) => x . id ) ) . toEqual ( [
142+ document . pages [ 0 ] . layers [ 1 ] . id ,
143+ document . pages [ 0 ] . layers [ 2 ] . id ,
144+ ] )
145+ } )
146+
114147test ( 'should find by frame.x greater than' , ( _context , document ) => {
115148 // eslint-disable-next-line no-param-reassign
116149 document . pages = [
@@ -158,3 +191,62 @@ test('should find with id', (_context, document) => {
158191 find ( `#${ document . pages [ 0 ] . layers [ 1 ] . id } ` , document ) . map ( ( x ) => x . id )
159192 ) . toEqual ( [ document . pages [ 0 ] . layers [ 1 ] . id ] )
160193} )
194+
195+ test ( 'should find within root progeny' , ( _context , document ) => {
196+ // eslint-disable-next-line no-param-reassign
197+ document . pages = [
198+ {
199+ layers : [
200+ {
201+ type : 'Artboard' ,
202+ frame : new Rectangle ( 400 , 0 , 100 , 100 ) ,
203+ layers : [
204+ {
205+ type : 'Shape' ,
206+ name : 'test' ,
207+ frame : new Rectangle ( 400 , 0 , 50 , 50 ) ,
208+ } ,
209+ ] ,
210+ } ,
211+ { type : 'Shape' , name : 'test' } ,
212+ ] ,
213+ } ,
214+ ]
215+
216+ const root = document . pages [ 0 ] . layers [ 0 ]
217+ expect ( find ( "[name='test']" , root ) . map ( ( x ) => x . id ) ) . toEqual ( [
218+ root . layers [ 0 ] . id ,
219+ ] )
220+
221+ expect (
222+ find ( "[name='test']" , root , { inclusive : false } ) . map ( ( x ) => x . id )
223+ ) . toEqual ( [ root . layers [ 0 ] . id ] )
224+ } )
225+
226+ test ( 'should find within root progeny + root itself' , ( _context , document ) => {
227+ // eslint-disable-next-line no-param-reassign
228+ document . pages = [
229+ {
230+ layers : [
231+ {
232+ type : 'Artboard' ,
233+ name : 'test' ,
234+ frame : new Rectangle ( 400 , 0 , 100 , 100 ) ,
235+ layers : [
236+ {
237+ type : 'Shape' ,
238+ name : 'test' ,
239+ frame : new Rectangle ( 400 , 0 , 50 , 50 ) ,
240+ } ,
241+ ] ,
242+ } ,
243+ { type : 'Shape' , name : 'test' } ,
244+ ] ,
245+ } ,
246+ ]
247+
248+ const root = document . pages [ 0 ] . layers [ 0 ]
249+ expect (
250+ find ( "[name='test']" , root , { inclusive : true } ) . map ( ( x ) => x . id )
251+ ) . toEqual ( [ root . id , root . layers [ 0 ] . id ] )
252+ } )
0 commit comments