@@ -246,6 +246,28 @@ describe('OrderToPayloadTransformer', function () {
246246 let payload = new OrderToPayloadTransformer ( ) . transform ( new Order ( data ) ) ;
247247 expect ( 'promo_codes' in payload . order ) . to . eq ( false ) ;
248248 } ) ;
249+
250+ it ( 'uses empty string for name when shipping address name is null' , function ( ) {
251+ let data = DataLoader ( 'order' , 'guestWithNoHistory' ) ;
252+ data . defaultShipment . shippingAddress . firstName = null ;
253+ data . defaultShipment . shippingAddress . lastName = null ;
254+ let payload = new OrderToPayloadTransformer ( ) . transform ( new Order ( data ) ) ;
255+ expect ( payload . customer . first_name ) . to . eq ( '' ) ;
256+ expect ( typeof payload . customer . first_name ) . to . eq ( 'string' ) ;
257+ expect ( payload . customer . last_name ) . to . eq ( '' ) ;
258+ expect ( typeof payload . customer . last_name ) . to . eq ( 'string' ) ;
259+ } ) ;
260+
261+ it ( 'uses empty string for name when billing address name is null' , function ( ) {
262+ let data = DataLoader ( 'order' , 'guestWithNoShippingAddress' ) ;
263+ data . billingAddress . firstName = null ;
264+ data . billingAddress . lastName = null ;
265+ let payload = new OrderToPayloadTransformer ( ) . transform ( new Order ( data ) ) ;
266+ expect ( payload . customer . first_name ) . to . eq ( '' ) ;
267+ expect ( typeof payload . customer . first_name ) . to . eq ( 'string' ) ;
268+ expect ( payload . customer . last_name ) . to . eq ( '' ) ;
269+ expect ( typeof payload . customer . last_name ) . to . eq ( 'string' ) ;
270+ } ) ;
249271 } ) ;
250272
251273 describe ( 'guest with previous orders' , function ( ) {
0 commit comments