GitHub

MockProduct

Mocked DaffProduct object.

import { MockProduct } from '@daffodil/product/testing'
class MockProduct implements DaffProduct {
  type: DaffProductTypeEnum.Simple
  id: faker.datatype.uuid()
  url: `/${faker.internet.domainWord()}.html`
  canonicalUrl: faker.internet.url()
  price: this.stubPrice
  in_stock: true
  discount: {
      amount: this.stubDiscount,
      percent: Math.floor((this.stubDiscount / this.stubPrice) * 100)
  }
  images: this.imageFactory.createMany(faker.datatype.number({ min: 1, max: 10 }))
  thumbnail: this.imageFactory.create()
  name: faker.commerce.productName()
  brand: faker.company.name()
  description: faker.commerce.productDescription()
  short_description: faker.commerce.productDescription()
  meta_title: faker.commerce.productName()
  meta_description: faker.commerce.productDescription()
  protected imageFactory: DaffProductImageFactory
}

Properties

Name Type Description
type DaffProductTypeEnum.Simple
id faker.datatype.uuid()
url `/${faker.internet.domainWord()}.html`
canonicalUrl faker.internet.url()
price this.stubPrice
in_stock true
discount { amount: this.stubDiscount, percent: Math.floor((this.stubDiscount / this.stubPrice) * 100) }
images this.imageFactory.createMany(faker.datatype.number({ min: 1, max: 10 }))
thumbnail this.imageFactory.create()
name faker.commerce.productName()
brand faker.company.name()
description faker.commerce.productDescription()
short_description faker.commerce.productDescription()
meta_title faker.commerce.productName()
meta_description faker.commerce.productDescription()
imageFactory DaffProductImageFactory