GitHub

DaffMockStatefulCompositeCartItem

Mock

import { DaffMockStatefulCompositeCartItem } from '@daffodil/cart/state/testing'

class DaffMockStatefulCompositeCartItem extends DaffMockCompositeCartItem implements DaffOperationEntity<DaffCompositeCartItem> {
  daffState: DaffState = DaffState.Stable
  daffErrors: any[] = []
  daffTemp: boolean = false
  type: DaffCartItemInputType = DaffCartItemInputType.Composite
  options: { id: any; option_label: any; value_label: any; }[] = [
      {
        id: faker.string.uuid(),
        option_label: faker.lorem.word(),
        value_label: faker.lorem.word(),
      },
      {
        id: faker.string.uuid(),
        option_label: faker.lorem.word(),
        value_label: faker.lorem.word(),
      },
    ]
  id: faker.string.uuid() = faker.string.uuid()
  product_id: faker.string.uuid() = faker.string.uuid()
  parent_item_id: faker.string.uuid() = faker.string.uuid()
  image: DaffProductImage = <DaffProductImage>new DaffProductImageFactory().create()
  sku: string = 'sku'
  name: string = 'Product Name'
  url: string = `/${faker.internet.domainWord()}.html`
  qty: faker.number.int({ min: 1, max: 100 }) = faker.number.int({ min: 1, max: 100 })
  price: faker.number.int({ min: 10, max: 1500 }) = faker.number.int({ min: 10, max: 1500 })
  row_total: number = this.qty * this.price
  in_stock: boolean = true
  _numberOfDiscounts: faker.number.int({ min: 1, max: 2 }) = faker.number.int({ min: 1, max: 2 })
  discounts: DaffCartItemDiscount[] = this._discounts(this._numberOfDiscounts, Math.floor(this.price / this._numberOfDiscounts))
}