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

Commit e296acc

Browse files
author
Bassem Dghaidi
committed
Add test case for issue #14
1 parent 44e2b40 commit e296acc

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

test/test_objectron.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ suite('Objectron Core Tests', () => {
441441
assert.isTrue(called)
442442
})
443443

444-
test('Callback used as wildcard', () => {
444+
test('Wildcard matching with a closure', () => {
445445
const payload = {
446446
request: {
447447
status: 200,
@@ -548,4 +548,60 @@ suite('Objectron Core Tests', () => {
548548
assert.isTrue(result.match)
549549
assert.deepEqual(result, expected)
550550
})
551+
552+
test('Unordered index matching case', () => {
553+
const payload = {
554+
api: 13,
555+
ids: [1, 5, 130, 23, 45, 12],
556+
components: {
557+
type: 'section',
558+
fields: [
559+
{
560+
type: 'plain_text',
561+
text: 'going home?',
562+
rating: 5.5
563+
},
564+
{
565+
type: 'markdown',
566+
text: '*This must be it*'
567+
}
568+
]
569+
}
570+
}
571+
572+
const result = match(payload, {
573+
api: 13,
574+
ids: [12, 130, 45],
575+
components: {
576+
type: 'section',
577+
fields: [
578+
{
579+
type: 'markdown',
580+
text: /.*/
581+
}
582+
]
583+
}
584+
})
585+
586+
const expected = {
587+
match: true,
588+
total: 8,
589+
matches: {
590+
api: 13,
591+
ids: [12, 130, 45],
592+
components: {
593+
type: 'section',
594+
fields: [
595+
{
596+
type: 'markdown',
597+
text: '*This must be it*'
598+
}
599+
]
600+
}
601+
},
602+
groups: {}
603+
}
604+
605+
assert.isFalse(result.match)
606+
})
551607
})

0 commit comments

Comments
 (0)