Skip to content

Instantly share code, notes, and snippets.

describe('Unit | Calcule du prix du panier', () => {
let getBasketInformation: GetBasketInformation
let addToBasket: AddToBasket
beforeEach(() => {
const basketRepository = new InMemoryBasketRepository()
getBasketInformation = new GetBasketInformation(basketRepository)
addToBasket = new AddToBasket(basketRepository)
})
@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 | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Vérification du snapshot', async () => {
export const BookInformation: React.FC<Props & DependenciesProps> = ({
bookTitle,
dependencies
}) => {
const [book, setBook] = useState<BookDetails>()
const onRefresh = () => fetchBookInformation()
useEffect(() => {
fetchBookInformation()
}, [])
describe('Integration | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Matches to snapshot', async () => {
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 | Controller | Book information', () => {
let app: Express
let fakeDependencies: Dependencies
beforeEach(() => {
fakeDependencies = {
bookInformation: sinon.stub()
}
app = express()
bookstoreRoutes(app, fakeDependencies)