import { getReceiptItemQuantity } from './get-receipt-item-quantity.helper';

describe('getItemQuantity', () => {
  it('should return item quantity when not present in quantity map', () => {
    // Arrange
    const item = { id: 123, quantity: { quantity: 5 } };

    // Act
    const result = getReceiptItemQuantity(item);

    // Assert
    expect(result).toBe(5);
  });

  it('should return 1 as default when item quantity is 0', () => {
    // Arrange
    const item = { id: 123, quantity: { quantity: 0 } };

    // Act
    const result = getReceiptItemQuantity(item);

    // Assert
    expect(result).toBe(1);
  });

  it('should return 1 as default when item quantity is null', () => {
    // Arrange
    const item = { id: 123, quantity: { quantity: null as unknown as number } };

    // Act
    const result = getReceiptItemQuantity(item);

    // Assert
    expect(result).toBe(1);
  });
});
