import { TestBed } from '@angular/core/testing' ; import { DaffOrder } from '@daffodil/checkout' ; import { DaffOrderFactory } from '../../order/factories/order.factory' ; import { DaffTestingCheckoutService } from './checkout.service' ; describe ( 'Driver | Testing | Checkout | CheckoutService' , ( ) => { let testingCheckoutService ; const orderFactorySpy = jasmine . createSpyObj ( 'DaffOrderFactory' , [ 'create' ] ) ; let stubOrder ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { providers : [ DaffTestingCheckoutService , { provide : DaffOrderFactory , useValue : orderFactorySpy } , ] , } ) ; stubOrder = new DaffOrderFactory ( ) . create ( ) ; orderFactorySpy . create . and . returnValue ( stubOrder ) ; testingCheckoutService = TestBed . inject ( DaffTestingCheckoutService ) ; } ) ; it ( 'should be created' , ( ) => { expect ( testingCheckoutService ) . toBeTruthy ( ) ; } ) ; describe ( 'placeOrder' , ( ) => { let cartId ; beforeEach ( ( ) => { cartId = 'cartId' ; } ) ; it ( 'should return an order from order factory' , ( ) => { testingCheckoutService . placeOrder ( cartId ) . subscribe ( order => { expect ( order ) . toEqual ( stubOrder ) ; } ) ; } ) ; } ) ; } ) ;