LearningTypeScript / projects

Hands-on real world projects that will help you exercise your knowledge of TypeScript.
https://learningtypescript.com/projects
244 stars 166 forks source link

✍ Typo: [structural-kitchen] - two test names are exactly the same #285

Open alexhippo opened 1 week ago

alexhippo commented 1 week ago

Typo Report Checklist

Impacted Project File

learning-typescript-projects/projects/functions/structural-kitchen/src/index.test.ts

What's Wrong?

Two of the tests for the purchase function appear to have the same it clause:

returns false without changing stock when expense is less than budget on a second call

According to the test content, I think the 2nd test name should be it returns true without changing stock when expense is less than budget on a second call. Unless I am understanding this scenario incorrectly?

Thanks, your book has been very helpful so far.

it("returns false without changing stock when expense is less than budget on a second call", () => {
    const supplier = jest.fn((expense: number) => ({
        breads: expense * 1,
        fruits: expense * 2,
        sauces: expense * 3,
        vegetables: expense * 4,
    }));
    const kitchen = createKitchen(5, jest.fn<index.Cleaner>(), supplier);
    kitchen.purchase(3);

    const result = kitchen.purchase(3);

    expect(result).toBe(false);
    expect(kitchen.announce()).toBe(
        "I have 0 much dirt, 2 budget, 3 bread(s), 6 fruit(s), 9 sauce(s), and 12 vegetable(s)."
    );
});

it("returns false without changing stock when expense is less than budget on a second call", () => {
    const supplier = jest.fn((expense: number) => ({
        breads: expense * 1,
        fruits: expense * 2,
        sauces: expense * 3,
        vegetables: expense * 4,
    }));
    const kitchen = createKitchen(5, jest.fn<index.Cleaner>(), supplier);

    kitchen.purchase(3);
    const result = kitchen.purchase(2);

    expect(result).toBe(true);
    expect(kitchen.announce()).toBe(
        "I have 0 much dirt, 0 budget, 5 bread(s), 10 fruit(s), 15 sauce(s), and 20 vegetable(s)."
    );
});

Additional Info

No response

JoshuaKGoldberg commented 1 week ago

Nice spot, thanks!