Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
You can’t perform that action at this time.