This repository was archived by the owner on Jan 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,4 +270,61 @@ suite('Objectron Core Tests', () => {
270270 assert . isTrue ( result . match ) ;
271271 assert . deepEqual ( result , expected ) ;
272272 } ) ;
273+
274+ test ( 'Match depth 3 regular expressions' , ( ) => {
275+ const payload = {
276+ 'type' : 'message' ,
277+ 'level1' : [
278+ {
279+ 'level2' : [
280+ {
281+ 'text' : 'invite (Smith) (john@example.com) (CompanyX) (Engineer)'
282+ }
283+ ]
284+ } ,
285+ {
286+ 'text' : 'secondary object'
287+ }
288+ ]
289+ }
290+
291+ const result = match ( payload , {
292+ 'type' : 'message' ,
293+ 'level1' : [
294+ {
295+ 'level2' : [
296+ {
297+ 'text' : / i n v i t e \( (?< name > \S + ) \) \( (?< email > \S + ) \) \( (?< company > \S + ) \) \( (?< role > \S + ) \) / ,
298+ }
299+ ]
300+ }
301+ ]
302+ } ) ;
303+
304+ const expected = {
305+ match : true ,
306+ total : 2 ,
307+ matches : {
308+ 'type' : 'message' ,
309+ 'level1' : [
310+ {
311+ 'level2' : [
312+ {
313+ 'text' : 'invite (Smith) (john@example.com) (CompanyX) (Engineer)'
314+ }
315+ ]
316+ }
317+ ]
318+ } ,
319+ groups : {
320+ name : 'Smith' ,
321+ email : 'john@example.com' ,
322+ company : 'CompanyX' ,
323+ role : 'Engineer'
324+ }
325+ } ;
326+
327+ assert . isTrue ( result . match ) ;
328+ assert . deepEqual ( result , expected ) ;
329+ } ) ;
273330} ) ;
You can’t perform that action at this time.
0 commit comments