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