GitHub

MockMagentoProductPreview

import { MockMagentoProductPreview } from '@daffodil/product/driver/magento/testing'

class MockMagentoProductPreview implements MagentoProductPreview {
  __typename: MagentoProductTypeEnum = MagentoProductTypeEnum.SimpleProduct
  uid: faker.datatype.uuid() = faker.datatype.uuid()
  url_key: faker.random.alphaNumeric(16) = faker.random.alphaNumeric(16)
  url_suffix: string = '.html'
  name: faker.random.word() = faker.random.word()
  sku: faker.random.alphaNumeric(16) = faker.random.alphaNumeric(16)
  stock_status: MagentoProductStockStatusEnum = MagentoProductStockStatusEnum.InStock
  image: { __typename: string; label: any; url: any; } = {
      __typename: 'ProductImage',
      label: faker.random.words(3),
      url: faker.image.imageUrl(),
    }
  description: { __typename: string; html: any; } = {
      __typename: 'ComplexTextValue',
      html: faker.random.words(5),
    }
  price_range: { __typename: string; maximum_price: { __typename: string; regular_price: { __typename: string; value: any; currency: any; }; discount: { __typename: string; amount_off: any; percent_off: any; }; }; } = {
      __typename: 'PriceRange',
      maximum_price: {
        __typename: 'ProductPrice',
        regular_price: {
          __typename: 'Money',
          value: faker.datatype.number({ min: 100, max: 1000 }),
          currency: null,
        },
        discount: {
          __typename: 'ProductDiscount',
          amount_off: faker.datatype.number({ min: 1, max: 99 }),
          percent_off: faker.datatype.number({ min: 1, max: 99 }),
        },
      },
    }
}