GitHub

MockMagentoCustomerOrder

import { MockMagentoCustomerOrder } from '@daffodil/customer-order/driver/magento/2-4-6/testing'

class MockMagentoCustomerOrder implements MagentoCustomerOrder {
  protected _numberOfSuborders: faker.datatype.number({ min: 1, max: 3 }) = faker.datatype.number({ min: 1, max: 3 })
  __typename: "CustomerOrder" = <const>'CustomerOrder'
  id: faker.datatype.uuid() = faker.datatype.uuid()
  order_date: faker.date.past().toString() = faker.date.past().toString()
  status: faker.random.word() = faker.random.word()
  carrier: faker.random.word() = faker.random.word()
  number: faker.datatype.uuid() = faker.datatype.uuid()
  shipping_method: faker.random.word() = faker.random.word()
  total: MagentoOrderTotal = this.totalFactory.create({
      __typename: 'OrderTotal',
    })
  items: MagentoOrderItem[] = this.itemFactory.createMany(faker.datatype.number({ min: 1, max: 5 }))
  billing_address: MagentoOrderAddress = this.addressFactory.create()
  shipping_address: MagentoOrderAddress = this.addressFactory.create()
  shipments: MagentoOrderShipment[] = this.shipmentFactory.createMany(this._numberOfSuborders)
  payment_methods: MagentoOrderPayment[] = this.paymentFactory.createMany(this._numberOfSuborders)
  invoices: MagentoOrderInvoice[] = this.invoiceFactory.createMany(this._numberOfSuborders)
  credit_memos: MagentoOrderCredit[] = this.creditFactory.createMany(faker.datatype.number({ min: 1, max: this._numberOfSuborders }))
  protected totalFactory: MagentoOrderTotalFactory
  protected itemFactory: MagentoOrderItemFactory
  protected addressFactory: MagentoOrderAddressFactory
  protected shipmentFactory: MagentoOrderShipmentFactory
  protected paymentFactory: MagentoOrderPaymentFactory
  protected invoiceFactory: MagentoOrderInvoiceFactory
  protected creditFactory: MagentoOrderCreditFactory
}