GitHub

DaffCategoryFactory

Model Factory

import { DaffCategoryFactory } from '@daffodil/category/testing'

A factory for creating a DaffCategory.

@Injectable()
class DaffCategoryFactory extends DaffModelFactory<DaffCategory, typeof MockCategory> {
  _instantiationArgs: ConstructorParameters<Klass>
  type: Constructable<DaffAccountRegistration, any[]>

  createTree(
    depth: number
    productIds: string[] = []
    partial: Partial<DaffCategory> = {}
  ): DaffCategory
  create(partial: Partial<T> = {}): T
  createMany(
    qty: number = 1
    partial: Partial<T> = {}
  ): T[]
}

() Methods

createTree
DaffCategory

Creates a category tree of specified depth, optionally using the passed product IDs. This is very useful for creating a category tree that closely resembles those found in the wild. Each child has a minimum of half of the parent's products.

Parameters
Parameterdepth: number
Description
ParameterproductIds: string[]
Default[]
Description
Parameterpartial: Partial<DaffCategory>
Default{}
Description
create
T
Parameters
Parameterpartial: Partial
Default{}
Description
createMany
T[]
Parameters
Parameterqty: number
Default1
Description
Parameterpartial: Partial
Default{}
Description