Skip to content

Commit

Permalink
chore: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Nov 25, 2024
1 parent a0d4efc commit 83c8f52
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
getProductsFromLineItems,
createPropertiesForEcomEventFromWebhook,
getAnonymousIdFromAttributes,
} = require('./serverSideUtlis');

const { constructPayload } = require('../../../../v0/util');
Expand Down Expand Up @@ -109,4 +110,21 @@ describe('serverSideUtils.js', () => {
});
});
});

describe('getAnonymousIdFromAttributes', () => {
// Handles empty note_attributes array gracefully
it('should return null when note_attributes is an empty array', async () => {
const event = { note_attributes: [] };
const result = await getAnonymousIdFromAttributes(event);
expect(result).toBeNull();
});

it('get anonymousId from noteAttributes', async () => {
const event = {
note_attributes: [{ name: 'rudderAnonymousId', value: '123456' }],
};
const result = await getAnonymousIdFromAttributes(event);
expect(result).toEqual('123456');
});
});
});

0 comments on commit 83c8f52

Please sign in to comment.