GitHub

MockDaffCategoryFacade

import { MockDaffCategoryFacade } from '@daffodil/category/state/testing'

Can be used to mock out the DaffCategoryFacade in testing environments.

@Injectable()
class MockDaffCategoryFacade implements DaffCategoryFacadeInterface {
  category$: BehaviorSubject<DaffCategory> = new BehaviorSubject(null)
  loadingState$: BehaviorSubject<DaffCategoryReducerState['daffState']> = new BehaviorSubject(null)
  loading$: BehaviorSubject<boolean> = new BehaviorSubject(false)
  mutating$: BehaviorSubject<boolean> = new BehaviorSubject(false)
  resolving$: BehaviorSubject<boolean> = new BehaviorSubject(false)
  hasErrors$: BehaviorSubject<boolean> = new BehaviorSubject(false)
  products$: BehaviorSubject<DaffProduct[]> = new BehaviorSubject([])
  errors$: BehaviorSubject<DaffStateError[]> = new BehaviorSubject([])
  isCategoryEmpty$: BehaviorSubject<boolean> = new BehaviorSubject(true)

  getCategoryById(id: string): BehaviorSubject<DaffCategory>
  getProductsByCategory(categoryId: string): BehaviorSubject<DaffProduct[]>
  getTotalProductsByCategory(categoryId: string): BehaviorSubject<number>
  dispatch(action: Action<string>): void
}

Properties

category$
BehaviorSubject<DaffCategory>
Defaultnew BehaviorSubject(null)
Description

The currently selected category.

loadingState$
BehaviorSubject<DaffCategoryReducerState['daffState']>
Defaultnew BehaviorSubject(null)
Description
loading$
BehaviorSubject<boolean>
Defaultnew BehaviorSubject(false)
Description
mutating$
BehaviorSubject<boolean>
Defaultnew BehaviorSubject(false)
Description
resolving$
BehaviorSubject<boolean>
Defaultnew BehaviorSubject(false)
Description
hasErrors$
BehaviorSubject<boolean>
Defaultnew BehaviorSubject(false)
Description
products$
BehaviorSubject<DaffProduct[]>
Defaultnew BehaviorSubject([])
Description

Products of the current category.

errors$
BehaviorSubject<DaffStateError[]>
Defaultnew BehaviorSubject([])
Description
isCategoryEmpty$
BehaviorSubject<boolean>
Defaultnew BehaviorSubject(true)
Description

Is the category page empty of products.

() Methods

getCategoryById
BehaviorSubject<DaffCategory>

Get a category by the provided Id.

Parameters
Parameterid: string
Description
getProductsByCategory
BehaviorSubject<DaffProduct[]>

Get products by a category Id.

Parameters
ParametercategoryId: string
Description
getTotalProductsByCategory
BehaviorSubject<number>

Get products by a category Id.

Parameters
ParametercategoryId: string
Description
dispatch
void
Parameters
Parameteraction: Action
Description