@@ -4,6 +4,7 @@ import { getTrigger } from '@/triggers'
44import {
55 isQuickBooksEventMatch ,
66 QUICKBOOKS_TRIGGER_DEFINITIONS ,
7+ quickBooksEventTypesSubBlockId ,
78 quickBooksTriggerOptions ,
89} from '@/triggers/quickbooks/utils'
910
@@ -32,11 +33,14 @@ describe('QuickBooks triggers', () => {
3233 ) . toHaveLength ( 1 )
3334 for ( const definition of QUICKBOOKS_TRIGGER_DEFINITIONS ) {
3435 const trigger = getTrigger ( definition . id )
35- const eventTypes = trigger . subBlocks . find ( ( subBlock ) => subBlock . id === 'eventTypes' )
36+ const eventTypes = trigger . subBlocks . find (
37+ ( subBlock ) => subBlock . id === quickBooksEventTypesSubBlockId ( definition . id )
38+ )
3639 if ( definition . id === 'quickbooks_preferences_updated' ) {
3740 expect ( eventTypes ) . toBeUndefined ( )
3841 } else {
3942 expect ( eventTypes ?. options ?. map ( ( option ) => option . id ) ) . toEqual ( definition . actions )
43+ expect ( eventTypes ?. multiSelect ) . toBe ( true )
4044 }
4145 const instructions = trigger . subBlocks . find ( ( subBlock ) =>
4246 subBlock . id . startsWith ( 'triggerInstructions' )
@@ -47,15 +51,22 @@ describe('QuickBooks triggers', () => {
4751 }
4852 expect ( trigger . outputs ) . toEqual ( getTrigger ( 'quickbooks_invoice_events' ) . outputs )
4953 }
54+
55+ const eventTypeIds = QuickBooksBlock . subBlocks
56+ . map ( ( subBlock ) => subBlock . id )
57+ . filter ( ( id ) => id . startsWith ( 'eventTypes_quickbooks_' ) )
58+ expect ( eventTypeIds ) . toHaveLength ( 28 )
59+ expect ( new Set ( eventTypeIds ) . size ) . toBe ( eventTypeIds . length )
5060 } )
5161
5262 it ( 'matches all 101 supported combinations and rejects unsupported actions' , ( ) => {
5363 for ( const definition of QUICKBOOKS_TRIGGER_DEFINITIONS ) {
5464 for ( const action of definition . actions ) {
65+ const providerAction = action === 'voided' ? 'void' : action
5566 expect (
5667 isQuickBooksEventMatch (
5768 definition . id ,
58- `qbo.${ definition . entity } .${ action } .v1` ,
69+ `qbo.${ definition . entity } .${ providerAction } .v1` ,
5970 definition . actions
6071 )
6172 ) . toBe ( true )
0 commit comments