File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/v1/sources/shopify/webhookTransformations Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
const {
2
2
getProductsFromLineItems,
3
3
createPropertiesForEcomEventFromWebhook,
4
+ getAnonymousIdFromAttributes,
4
5
} = require ( './serverSideUtlis' ) ;
5
6
6
7
const { constructPayload } = require ( '../../../../v0/util' ) ;
@@ -109,4 +110,21 @@ describe('serverSideUtils.js', () => {
109
110
} ) ;
110
111
} ) ;
111
112
} ) ;
113
+
114
+ describe ( 'getAnonymousIdFromAttributes' , ( ) => {
115
+ // Handles empty note_attributes array gracefully
116
+ it ( 'should return null when note_attributes is an empty array' , async ( ) => {
117
+ const event = { note_attributes : [ ] } ;
118
+ const result = await getAnonymousIdFromAttributes ( event ) ;
119
+ expect ( result ) . toBeNull ( ) ;
120
+ } ) ;
121
+
122
+ it ( 'get anonymousId from noteAttributes' , async ( ) => {
123
+ const event = {
124
+ note_attributes : [ { name : 'rudderAnonymousId' , value : '123456' } ] ,
125
+ } ;
126
+ const result = await getAnonymousIdFromAttributes ( event ) ;
127
+ expect ( result ) . toEqual ( '123456' ) ;
128
+ } ) ;
129
+ } ) ;
112
130
} ) ;
You can’t perform that action at this time.
0 commit comments