Skip to content

Instantly share code, notes, and snippets.

@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)
# 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 |
@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)
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 |
describe('Integration | Controller | Book information', () => {
let app: Express
let fakeDependencies: Dependencies
beforeEach(() => {
fakeDependencies = {
bookInformation: sinon.stub()
}
app = express()
bookstoreRoutes(app, fakeDependencies)
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()
})
})
describe('Integration | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Vérification du snapshot', async () => {
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)
export const bookstoreRoutes = (app: Express, dependencies: Dependencies) => {
app.get('/books/:id', getBookById(dependencies))
}
describe('Integration | Controller | Book information', () => {
let app: Express
let fakeDependencies: Dependencies
beforeEach(() => {
fakeDependencies = {
bookInformation: sinon.stub()
}
app = express()
bookstoreRoutes(app, fakeDependencies)