Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit d27d8e7

Browse files
author
Bassem Dghaidi
committed
Add depth 3 level test
1 parent 67f59ca commit d27d8e7

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

test/test_objectron.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff 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': /invite \((?<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
});

0 commit comments

Comments
 (0)