48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { BuyTicketLogic } from './buy-ticket.logic';
|
|
import { BuyTicketButtonComponent } from './buy-ticket-button.component';
|
|
import { FlightModel } from '@shared/models-legacy';
|
|
import { getMockPipe } from '@shared/pipes/pipe.mock';
|
|
describe('BuyTicketButtonComponent', () => {
|
|
let component: BuyTicketButtonComponent;
|
|
let fixture: ComponentFixture<BuyTicketButtonComponent>;
|
|
let logic: BuyTicketLogic;
|
|
const direct: FlightModel = {} as any;
|
|
const returning: FlightModel = {} as any;
|
|
beforeEach(async () => {
|
|
logic = {} as any;
|
|
await TestBed.configureTestingModule({
|
|
declarations: [BuyTicketButtonComponent, getMockPipe('translate')],
|
|
providers: [
|
|
{
|
|
provide: BuyTicketLogic,
|
|
useFactory: () => logic,
|
|
},
|
|
],
|
|
}).compileComponents();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(BuyTicketButtonComponent);
|
|
component = fixture.componentInstance;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should create', () => {
|
|
expect(component).toBeTruthy();
|
|
});
|
|
|
|
it('should buy', () => {
|
|
logic.buyAll = jasmine
|
|
.createSpy('buyAll')
|
|
.withArgs(direct, returning)
|
|
.and.callThrough();
|
|
component.direct = direct;
|
|
component.returning = returning;
|
|
|
|
component.buy();
|
|
|
|
expect(logic.buyAll).toHaveBeenCalled();
|
|
});
|
|
});
|