Skip to content

Commit e94d041

Browse files
🐛 fix: (the-)narrow-trails counts (#116)
1 parent e3b1596 commit e94d041

7 files changed

Lines changed: 21 additions & 15 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"label": "🍲 Narrow Trails",
2+
"label": "🍲 The Narrow Trail",
33
"position": 2
44
}

projects/interfaces/playlist-soundness/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "narrow-trail",
2+
"name": "the-narrow-trail",
33
"scripts": {
44
"test": "jest",
55
"test:solutions": "cross-env TEST_SOLUTIONS=1 jest"

projects/unions-and-literals/narrow-trails/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Narrow Trail
1+
# The Narrow Trail
22

33
> A [Learning TypeScript > Unions and Literals](https://learning-typescript.com/unions-and-literals) 🍲 entree project.
44
@@ -8,7 +8,7 @@ This legendary path winds takes a week to cross but is notoriously difficult to
88
Choose your actions on the trail wisely -- or perish.
99

1010
...or at least, that's the marketing material for our in-development video game.
11-
This project will have you implementing game function in TypeScript to help us get to our first demo.
11+
This project will have you implementing a game function in TypeScript to help us get to our first demo.
1212
We'd do it ourselves, except we need someone who's learned about how unions, literals, and type narrowing work in TypeScript.
1313
That's you!
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"label": "🍲 Narrow Trails",
2+
"label": "🍲 The Narrow Trail",
33
"position": 2
44
}

projects/unions-and-literals/narrow-trails/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "narrow-trail",
2+
"name": "the-narrow-trail",
33
"scripts": {
44
"test": "jest",
55
"test:solutions": "cross-env TEST_SOLUTIONS=1 jest"

projects/unions-and-literals/narrow-trails/src/index.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ describe(runCommands, () => {
1313
});
1414

1515
test.each([
16-
[[1, 1, 1, 1, 1, 1], false],
17-
[[2, 2, 2, 2, 2, 2], false],
18-
[[3, 4, 3, 2, 1, 1], false],
19-
[[1, 2, 1, 2, 1, 2], false],
20-
[[3, 3, 3, 3, 3, 3], false],
21-
[[4, 4, 4, 4, 4, 4], false],
22-
[[3, 4, 3, 4, 3, 4, 3], false],
23-
[[3, 4, 5, 3, 4, 5, 3], true],
16+
[[1, 1, 1, 1, 1], false],
17+
[[2, 2, 2, 2, 2], false],
18+
[[3, 4, 3, 2, 1], false],
19+
[[1, 2, 1, 2, 1], false],
20+
[[3, 3, 3, 3, 3], false],
21+
[[4, 4, 4, 4, 4], false],
22+
[[3, 4, 3, 4, 3], false],
23+
[[3, 4, 5, 1, 2], false],
24+
[[3, 4, 5, 3, 4], false],
25+
[[1, 6, 6, 6, 6], false],
26+
[[1, 6, 2, 6, 6, 6, 6], true],
2427
[[1, 2, 3, 4, 5, 6, 1], true],
2528
[[1, 3, 5, 2, 4, 6, 1], true],
29+
[[2, 4, 1, 4, 1, 1, 1], true],
30+
[[2, 3, 1, 3, 2, 2, 2], true],
2631
])("%j", (randomValues: number[], expected: boolean | Error) => {
2732
mockRandom.mockClear();
2833

@@ -33,5 +38,6 @@ describe(runCommands, () => {
3338
const actual = runCommands();
3439

3540
expect(actual).toEqual(expected);
41+
expect(mockRandom).toHaveBeenCalledTimes(randomValues.length);
3642
});
3743
});

projects/unions-and-literals/narrow-trails/src/solution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function runCommands() {
5252
food -= 1;
5353
water -= 1;
5454

55-
if (food < 0 || water < 0) {
55+
if (food === 0 || water === 0) {
5656
return false;
5757
}
5858
}

0 commit comments

Comments
 (0)