import { MockConfigurableProduct } from '@daffodil/product-configurable/testing'
Mocked DaffConfigurableProduct object.
class MockConfigurableProduct extends MockProduct implements DaffConfigurableProduct {
type: DaffProductTypeEnum = DaffProductTypeEnum.Configurable
configurableAttributes: { code: string; label: string; order: number; values: { value: string; label: string; swatch: { value: string; thumbnail: any; }; }[]; }[] = [
{
code: 'color',
label: 'Color',
order: 0,
values: [
{
value: '0',
label: 'Blue',
swatch: {
value: '#0000FF',
thumbnail: null,
},
},
{
value: '1',
label: 'Yellow',
swatch: {
value: '#FFFF00',
thumbnail: null,
},
},
{
value: '2',
label: 'Red',
swatch: {
value: '#FF0000',
thumbnail: null,
},
},
],
},
{
code: 'size',
label: 'Size',
order: 1,
values: [
{
value: '0',
label: 'Small',
swatch: null,
},
{
value: '1',
label: 'Medium',
swatch: null,
},
{
value: '2',
label: 'Large',
swatch: null,
},
],
},
{
code: 'material',
label: 'Material',
order: 2,
values: [
{
value: '0',
label: 'Cotton',
swatch: null,
},
{
value: '1',
label: 'Polyester',
swatch: null,
},
{
value: '2',
label: 'Spandex',
swatch: null,
},
],
},
]
variants: { appliedAttributes: { color: string; size: string; material: string; }; price: any; discount: { amount: any; percent: number; }; id: any; in_stock: boolean; }[] = [
{
appliedAttributes: {
color: '0',
size: '0',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '0',
size: '1',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '0',
size: '1',
material: '2',
},
price: this.stubPriceVariant3,
discount: {
amount: this.stubDiscountVariant3,
percent: Math.floor((this.stubDiscountVariant3/this.stubPriceVariant3) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '0',
size: '2',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '1',
size: '0',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '1',
size: '0',
material: '2',
},
price: this.stubPriceVariant3,
discount: {
amount: this.stubDiscountVariant3,
percent: Math.floor((this.stubDiscountVariant3/this.stubPriceVariant3) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '1',
size: '2',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '1',
size: '2',
material: '1',
},
price: this.stubPriceVariant2,
discount: {
amount: this.stubDiscountVariant2,
percent: Math.floor((this.stubDiscountVariant2/this.stubPriceVariant2) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '2',
size: '0',
material: '0',
},
price: this.stubPriceVariant3,
discount: {
amount: this.stubDiscountVariant3,
percent: Math.floor((this.stubDiscountVariant3/this.stubPriceVariant3) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
{
appliedAttributes: {
color: '2',
size: '2',
material: '0',
},
price: this.stubPriceVariant1,
discount: {
amount: this.stubDiscountVariant1,
percent: Math.floor((this.stubDiscountVariant1/this.stubPriceVariant1) * 100),
},
id: faker.datatype.uuid(),
in_stock: true,
},
]
}