import { OrderItem } from './order-item.model'
describe('OrderItem', () => {
	describe('payQuantity method', () => {
		it('should increment paidQuantity', () => {
			const item = new OrderItem({ quantity: 5, paidQuantity: 1 })
			item.payQuantity(3)
			expect(item.paidQuantity).toBe(4)
		})
		it('should set item to paid when quantity becomes equal to paidQuantity', () => {
			const item = new OrderItem({ quantity: 5, paidQuantity: 2 })
			item.payQuantity(3)
			expect(item.paid).toBe(true)
		})
		it('should throw error when paidQuantity exceed total quantity', () => {
			const item = new OrderItem({ quantity: 5, paidQuantity: 2 })
			expect(() => item.payQuantity(5)).toThrow(new Error('Paid quantity must not exceed total quantity'))
		})
	})
})
