Skip to content

Instantly share code, notes, and snippets.

@mickaelw
Created September 18, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickaelw/ceb172eecdc76d8a1a26825a37a14195 to your computer and use it in GitHub Desktop.
Save mickaelw/ceb172eecdc76d8a1a26825a37a14195 to your computer and use it in GitHub Desktop.
@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