From fc0a710d519901038258f80d330c1fc3a186b2b6 Mon Sep 17 00:00:00 2001 From: C-A de Salaberry Date: Sun, 22 Mar 2020 14:57:22 +0100 Subject: [PATCH] fix(docs): :pencil2: stick to jest expect convention https://jestjs.io/docs/en/expect#tobevalue > Use .toBe() to compare primitive values or to check referential identity of object instances. `.toEqual()` is rather used to compare the content of an object. actual and expected values were also the other way around; The reference value is supposed to used as a parameter of the `toBe` function rather than the `expect` function. --- _chapters/unit-tests-in-serverless.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/_chapters/unit-tests-in-serverless.md b/_chapters/unit-tests-in-serverless.md index 411f61c22..526137bb9 100644 --- a/_chapters/unit-tests-in-serverless.md +++ b/_chapters/unit-tests-in-serverless.md @@ -46,28 +46,28 @@ import { calculateCost } from "../libs/billing-lib"; test("Lowest tier", () => { const storage = 10; - const cost = 4000; - const expectedCost = calculateCost(storage); + const actualCost = calculateCost(storage); + const expectedCost = 4000; - expect(cost).toEqual(expectedCost); + expect(actualCost).toBe(expectedCost); }); test("Middle tier", () => { const storage = 100; - const cost = 20000; - const expectedCost = calculateCost(storage); + const actualCost = calculateCost(storage); + const expectedCost = 20000; - expect(cost).toEqual(expectedCost); + expect(actualCost).toBe(expectedCost); }); test("Highest tier", () => { const storage = 101; - const cost = 10100; - const expectedCost = calculateCost(storage); + const actualCost = calculateCost(storage); + const expectedCost = 10100; - expect(cost).toEqual(expectedCost); + expect(actualCost).toBe(expectedCost); }); ```