Created
September 18, 2020 14:39
-
-
Save mickaelw/ceb172eecdc76d8a1a26825a37a14195 to your computer and use it in GitHub Desktop.
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