GitHub

MockDaffCompositeProductFacade

class

import { MockDaffCompositeProductFacade } from '@daffodil/product-composite/state/testing'

@Injectable()
class MockDaffCompositeProductFacade implements DaffCompositeProductFacadeInterface {
  getRequiredItemPricesForConfiguration(
    id: string
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): BehaviorSubject<DaffPriceRange>
  getOptionalItemPricesForConfiguration(
    id: string
    configuration?: Dictionary<DaffCompositeConfigurationItem>
  ): BehaviorSubject<DaffPriceRange>
  getPricesAsCurrentlyConfigured(id: string): BehaviorSubject<DaffPriceRange>
  getAppliedOptions(id: string): BehaviorSubject<Dictionary<DaffCompositeProductItemOption>>
  getDiscountAmount(id: string): BehaviorSubject<number>
  getDiscountPercent(id: string): BehaviorSubject<number>
  isItemRequired(
    id: string
    item_id: string
  ): BehaviorSubject<boolean>
  dispatch(action): void
  hasDiscount(priceRange: DaffPriceRange): boolean
  hasPriceRange(priceRange: DaffPriceRange): boolean
}

() Methods

getRequiredItemPricesForConfiguration
BehaviorSubject<DaffPriceRange>

Get a DaffPriceRange for a composite product based on the configuration provided excluding unselected, optional item prices.

Parameters
Parameterid: string
Description
Parameterconfiguration: Dictionary<DaffCompositeConfigurationItem>
Description
getOptionalItemPricesForConfiguration
BehaviorSubject<DaffPriceRange>

Get the broadest possible DaffPriceRange for a composite product based on the configuration provided including optional item prices.

Parameters
Parameterid: string
Description
Parameterconfiguration: Dictionary<DaffCompositeConfigurationItem>
Description
getPricesAsCurrentlyConfigured
BehaviorSubject<DaffPriceRange>

Get the DaffPriceRange for a composite product based on the current configuration of selected item options in redux state and excluding unselected, optional item prices.

Parameters
Parameterid: string
Description
getAppliedOptions
BehaviorSubjectDaffCompositeProductItemOption>>

Returns the applied options for a composite product.

Parameters
Parameterid: string
Description
getDiscountAmount
BehaviorSubject

Returns the discount amount of a composite product based on the current configuration of the selected item options in redux state and excluding unselected, optional item prices. Will return undefined if all required options are not chosen.

Parameters
Parameterid: string
Description
getDiscountPercent
BehaviorSubject

Returns the discount percent of a composite product based on the current configuration of the selected item options in redux state and excluding unselected, optional item prices. Will return undefined if all required options are not chosen. Note: This percent is computed client-side and should be treated as an estimate rather than an exact value.

Parameters
Parameterid: string
Description
isItemRequired
BehaviorSubject

Returns whether the item of a composite product is required.

Parameters
Parameterid: string
Description
Parameteritem_id: string
Description
dispatch
void
Parameters
Parameteraction: undefined
Description
hasDiscount
boolean

Returns whether a DaffPriceRange has a discount.

Parameters
ParameterpriceRange: DaffPriceRange
Description
hasPriceRange
boolean

Returns whether the min and max prices of a DaffPriceRange are different.

Parameters
ParameterpriceRange: DaffPriceRange
Description