Created
April 19, 2021 05:06
-
-
Save wiserfirst/701d319ea4def830058166b19df57eaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const encode64 = str => Buffer.from(str).toString('base64') | |
describe('base64 encoding comparison', () => { | |
const triggerId = 'direct1' | |
const fulfilmentType = 'ClickandCollect' | |
const orderId = '000000123' | |
const string = `{"property-value-westfield_direct_trigger_id":["${triggerId}"],"property-value-westfield_direct_received_fulfilment_type":["${fulfilmentType}"],"property-value-westfield_direct_received_order_id":["${orderId}"]}` | |
it('should produce same result', () => { | |
const encoded = encode64(string) | |
const result = | |
encode64('{"property-value-westfield_direct_trigger_id":["') + | |
encode64(triggerId) + | |
encode64( | |
'"],"property-value-westfield_direct_received_fulfilment_type":["' | |
) + | |
encode64(fulfilmentType) + | |
encode64('"],"property-value-westfield_direct_received_order_id":["') + | |
encode64(orderId) + | |
encode64('"]}') | |
expect(result).toEqual(encoded) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment