Skip to content

Commit

Permalink
fixup! fix: do not display "add to cart" button if product has no pri…
Browse files Browse the repository at this point in the history
…ce (#1657)
  • Loading branch information
shauke committed May 16, 2024
1 parent 6640158 commit 665fe95
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions src/app/core/facades/product-context.facade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,112 @@ describe('Product Context Facade', () => {
`);
});
});

describe('add to basket handling', () => {
let product: ProductView;

beforeEach(() => {
product = {
sku: '123',
completenessLevel: ProductCompletenessLevel.Detail,
available: true,
readyForShipmentMin: 0,
readyForShipmentMax: 2,
} as ProductView;

when(shoppingFacade.product$(anything(), anything())).thenReturn(of(product));

context.set('sku', () => '123');
});

it('should set "addToBasket" to "false" for a product without a price', () => {
expect(context.get('displayProperties')).toMatchInlineSnapshot(`
{
"addToBasket": false,
"addToCompare": true,
"addToNotification": true,
"addToOrderTemplate": true,
"addToQuote": true,
"addToWishlist": true,
"bundleParts": false,
"description": true,
"inventory": true,
"name": true,
"price": true,
"promotions": true,
"quantity": true,
"readOnly": undefined,
"retailSetParts": false,
"shipment": true,
"sku": true,
"variations": false,
}
`);
});

it('should set "addToBasket" to "true" for a product with price', () => {
context.set('prices', () => ({ salePrice: PriceHelper.empty() }));
expect(context.get('displayProperties')).toMatchInlineSnapshot(`
{
"addToBasket": true,
"addToCompare": true,
"addToNotification": true,
"addToOrderTemplate": true,
"addToQuote": true,
"addToWishlist": true,
"bundleParts": false,
"description": true,
"inventory": true,
"name": true,
"price": true,
"promotions": true,
"quantity": true,
"readOnly": undefined,
"retailSetParts": false,
"shipment": true,
"sku": true,
"variations": false,
}
`);
});

it('should set "addToBasket" to "true" for a retail set independend from a price', () => {
when(shoppingFacade.product$(anything(), anything())).thenReturn(
of({
sku: '456',
completenessLevel: ProductCompletenessLevel.Detail,
minOrderQuantity: 1,
maxOrderQuantity: 100,
type: 'RetailSet',
available: true,
} as ProductView)
);
context.set('sku', () => '456');

expect(context.get('displayProperties')).toMatchInlineSnapshot(`
{
"addToBasket": true,
"addToCompare": true,
"addToNotification": false,
"addToOrderTemplate": true,
"addToQuote": true,
"addToWishlist": true,
"bundleParts": false,
"description": true,
"inventory": false,
"name": true,
"price": true,
"promotions": true,
"quantity": false,
"readOnly": undefined,
"retailSetParts": true,
"shipment": false,
"sku": true,
"variations": false,
}
`);
});
});
});

describe('Product Context Facade', () => {
Expand Down

0 comments on commit 665fe95

Please sign in to comment.