Skip to content

Commit 83c8f52

Browse files
chore: add unit tests
1 parent a0d4efc commit 83c8f52

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/v1/sources/shopify/webhookTransformations/serverSideUtils.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const {
22
getProductsFromLineItems,
33
createPropertiesForEcomEventFromWebhook,
4+
getAnonymousIdFromAttributes,
45
} = require('./serverSideUtlis');
56

67
const { constructPayload } = require('../../../../v0/util');
@@ -109,4 +110,21 @@ describe('serverSideUtils.js', () => {
109110
});
110111
});
111112
});
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+
});
112130
});

0 commit comments

Comments
 (0)