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
@binding() | |
export class PrixDuPanierCalculSteps { | |
private addToBasket: AddToBasket = null | |
private getBasketInformation: GetBasketInformation = null | |
@given(/^Un panier contenant aucun livre$/) | |
public givenUnPanierContenantAucunLivre(): void { | |
const basketRepository = new InMemoryBasketRepository() | |
this.addToBasket = new AddToBasket(basketRepository) | |
this.getBasketInformation = new GetBasketInformation(basketRepository) | |
} | |
@when(/^J’ajoute (.*) fois le livre (.*) dans le panier$/) | |
public async whenJAjouteXFoisLeMemeLivreDansLePanier(time: string, bookTitle: string): Promise<void> { | |
const book = new Book(bookTitle) | |
for (let i = 1; i <= parseInt(time); i++) | |
await this.addToBasket.execute(book) | |
} | |
@when(/^J’ajout les livres (.*) dans le panier$/) | |
public async whenJAjoutDesLivresDansLePanier(books: string): Promise<void> { | |
for (const bookTitle of books.split(',')) { | |
const book = new Book(bookTitle) | |
await this.addToBasket.execute(book) | |
} | |
} | |
@then(/^Le prix du panier est (.*)$/) | |
public async thenLePrixDuPanierEst(basketPrice: string): Promise<void> { | |
const basket = await this.getBasketInformation().execute() | |
expect(basket.price).to.be.equals(parseFloat(basketPrice)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment