feat(hero-banner): update image handling to support responsive images and refactor template
feat(cart): enhance editing logic and add tests for editable state feat(tenant): modify HeroConfig to include responsive image type
This commit is contained in:
@@ -408,6 +408,54 @@ describe('CartComponent', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('hides the edit toggle and disables quantity changes when editable is false', async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CartComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: CartService,
|
||||
useValue: {
|
||||
cart: signal(null).asReadonly(),
|
||||
updateItemQuantity: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
},
|
||||
},
|
||||
{ provide: ModalService, useValue: {} },
|
||||
{
|
||||
provide: ToastService,
|
||||
useValue: { success: vi.fn(), info: vi.fn(), danger: vi.fn() },
|
||||
},
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
const fixture = TestBed.createComponent(CartComponent);
|
||||
fixture.componentRef.setInput('items', [
|
||||
{
|
||||
cartItemId: 10,
|
||||
imageUrl: null,
|
||||
product: 'Producto de prueba',
|
||||
originalPrice: null,
|
||||
discountedPrice: 1000,
|
||||
discountPercentage: null,
|
||||
attributes: [],
|
||||
quantity: 1,
|
||||
},
|
||||
]);
|
||||
fixture.componentRef.setInput('allowEditing', true);
|
||||
fixture.componentRef.setInput('editable', false);
|
||||
const quantityChange = vi.fn();
|
||||
fixture.componentInstance.itemQuantityChange.subscribe(quantityChange);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.query(By.css('.cart-edit-btn'))).toBeNull();
|
||||
const cartItem = fixture.debugElement.query(By.css('app-cart-item'));
|
||||
expect(cartItem.componentInstance.quantityDisabled()).toBe(true);
|
||||
|
||||
cartItem.triggerEventHandler('quantityChange', 2);
|
||||
|
||||
expect(quantityChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('persists a variant selected from a cart row', async () => {
|
||||
const updateItemVariant = vi.fn().mockReturnValue(
|
||||
of({
|
||||
|
||||
Reference in New Issue
Block a user