Skip to content

Instantly share code, notes, and snippets.

View panierCalcule.ts
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)
})
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 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 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 bookInformation.tsx
export const BookInformation: React.FC<Props & DependenciesProps> = ({
bookTitle,
dependencies
}) => {
const [book, setBook] = useState<BookDetails>()
const onRefresh = () => fetchBookInformation()
useEffect(() => {
fetchBookInformation()
}, [])
View bookInformation.spec.tsx
describe('Integration | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Matches to snapshot', async () => {
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 getBookInformation.spec.ts
describe('Integration | Controller | Book information', () => {
let app: Express
let fakeDependencies: Dependencies
beforeEach(() => {
fakeDependencies = {
bookInformation: sinon.stub()
}
app = express()
bookstoreRoutes(app, fakeDependencies)