View prixDuPanierCalculSteps.ts
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) |
View basketPriceCalculation.feature
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
# language: fr | |
Fonctionnalité: Calcul du prix du panier | |
Plan du Scénario: Prix du panier sans réduction | |
Étant donné Un panier contenant aucun livre | |
Quand J’ajoute <fois> fois le livre <titre> dans le panier | |
Alors Le prix du panier est <prix> | |
Exemples: | |
| fois | titre | prix | |
View basketPriceCalculationSteps.ts
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 BasketPriceCalculationSteps { | |
private addToBasket: AddToBasket = null | |
private getBasketInformation: GetBasketInformation = null | |
@given(/^A basket that not contains any book$/) | |
public givenABasket(): void { | |
const basketRepository = new InMemoryBasketRepository() | |
this.addToBasket = new AddToBasket(basketRepository) | |
this.getBasketInformation = new GetBasketInformation(basketRepository) |
View basketPriceCalculation.feature
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
Feature: Basket price calculation | |
Scenario Outline: Basket without discounted price | |
Given A basket that not contains any book | |
When I add <time> times the book <book_title> into the basket | |
Then The price of the basket is <basket_price> | |
Examples: | |
| time | book_title | basket_price | | |
| 1 | 2 | 8.00 | | |
| 2 | 1 | 15.20 | |
View getBookInformation.spec.ts
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
describe('Integration | Controller | Book information', () => { | |
let app: Express | |
let fakeDependencies: Dependencies | |
beforeEach(() => { | |
fakeDependencies = { | |
bookInformation: sinon.stub() | |
} | |
app = express() | |
bookstoreRoutes(app, fakeDependencies) |
View bookInformationCard.spec.ts
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
describe('Integration | Component | Book information Card', () => { | |
it('Vérification du snapshot avec un livre', async () => { | |
const book = new BookDetails('title', true) | |
const { asFragment } = render(<BookInformationCard book={ book }/>) | |
await waitFor(() => { | |
expect(asFragment()).toMatchSnapshot() | |
}) | |
}) |
View bookInformation.spec.ts
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
describe('Integration | Component | Book information', () => { | |
let dependencies: Dependencies | |
beforeEach(() => { | |
dependencies = { | |
bookInformation: jest.fn().mockResolvedValue(null) | |
} | |
}) | |
it('Vérification du snapshot', async () => { |
View getBookById.ts
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
interface BookDetailsViewModel { | |
title: string | |
is_available: boolean | |
} | |
export function getBookById(dependencies: Dependencies) { | |
return async (req: Request, res: Response) => { | |
try { | |
const result = await dependencies | |
.bookInformation(req.params.id) |
View routes.ts
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
export const bookstoreRoutes = (app: Express, dependencies: Dependencies) => { | |
app.get('/books/:id', getBookById(dependencies)) | |
} |
View bookInformation.spec.ts
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
describe('Integration | Controller | Book information', () => { | |
let app: Express | |
let fakeDependencies: Dependencies | |
beforeEach(() => { | |
fakeDependencies = { | |
bookInformation: sinon.stub() | |
} | |
app = express() | |
bookstoreRoutes(app, fakeDependencies) |
NewerOlder