-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11d729d
commit 868c88b
Showing
18 changed files
with
287 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/app/shared/components/basket/basket-promotion/basket-promotion.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<ng-container *ngIf="promotion$ | async as promotion" | ||
><div *ngIf="promotion && !promotion.disableMessages"> | ||
<div class="promotion-title" [ishServerHtml]="promotion.title"></div> | ||
<ish-promotion-details [promotion]="promotion"></ish-promotion-details> | ||
<div class="promotion-details-and-remove-links"> | ||
<ish-promotion-details [promotion]="promotion"></ish-promotion-details> | ||
<ish-promotion-remove [code]="rebate.code"></ish-promotion-remove> | ||
</div> | ||
</div> | ||
</ng-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/app/shared/components/promotion/promotion-remove/promotion-remove.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ng-container *ngIf="code && (basket$ | async)"> | ||
<span class="promotion-links-seperator">|</span> | ||
<a data-testing-id="promo-remove-link" class="details-link promotion-remove-link" (click)="removePromotion()">{{ | ||
'promotion.removelink.text' | translate | ||
}}</a> | ||
</ng-container> |
46 changes: 46 additions & 0 deletions
46
src/app/shared/components/promotion/promotion-remove/promotion-remove.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { of } from 'rxjs'; | ||
import { instance, mock, when } from 'ts-mockito'; | ||
|
||
import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; | ||
import { BasketView } from 'ish-core/models/basket/basket.model'; | ||
|
||
import { PromotionRemoveComponent } from './promotion-remove.component'; | ||
|
||
describe('Promotion Remove Component', () => { | ||
let component: PromotionRemoveComponent; | ||
let fixture: ComponentFixture<PromotionRemoveComponent>; | ||
let element: HTMLElement; | ||
let checkoutFacade: CheckoutFacade; | ||
|
||
beforeEach(async(() => { | ||
checkoutFacade = mock(CheckoutFacade); | ||
when(checkoutFacade.basket$).thenReturn(of({} as BasketView)); | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [PromotionRemoveComponent], | ||
imports: [TranslateModule.forRoot()], | ||
providers: [{ provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) }], | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PromotionRemoveComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
component.code = 'test'; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
|
||
it('should display the link and input field on component', () => { | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
|
||
expect(element.querySelector('[data-testing-id=promo-remove-link]')).toBeTruthy(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/app/shared/components/promotion/promotion-remove/promotion-remove.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; | ||
import { BasketView } from 'ish-core/models/basket/basket.model'; | ||
|
||
@Component({ | ||
selector: 'ish-promotion-remove', | ||
templateUrl: './promotion-remove.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
// tslint:disable-next-line: ccp-no-intelligence-in-components | ||
export class PromotionRemoveComponent implements OnInit { | ||
basket$: Observable<BasketView>; | ||
|
||
@Input() code: string; | ||
|
||
constructor(private checkoutFacade: CheckoutFacade) {} | ||
|
||
ngOnInit() { | ||
this.basket$ = this.checkoutFacade.basket$; | ||
} | ||
|
||
removePromotion() { | ||
this.checkoutFacade.removePromotionCodeFromBasket(this.code); | ||
} | ||
} |
Oops, something went wrong.