GitHub

MockProduct

import { MockProduct } from '@daffodil/product/testing'

Mocked DaffProduct object.

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