import { ShippingAddressDTO } from '@swagger/crm';
import { ShippingAddressHelper } from './shipping-address.helper';

describe('ShippingAddressHelper', () => {
  describe('getDefaultShippingAddress', () => {
    it('should return undefined if function gets called with invalid arguments', () => {
      const shippingAdress = undefined;
      expect(ShippingAddressHelper.getDefaultShippingAddress(shippingAdress)).toEqual(undefined);
    });

    it('should return the latest default shippingAdress', () => {
      const shippingAdress: ShippingAddressDTO[] = [{ isDefault: new Date().toJSON() }, { isDefault: new Date(2020, 5, 15).toJSON() }, {}];
      expect(ShippingAddressHelper.getDefaultShippingAddress(shippingAdress)).toEqual(shippingAdress[0]);
    });
  });
});
