Skip to content

Commit f3789ad

Browse files
committed
Fix error message
1 parent fe19a00 commit f3789ad

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test("Arbitrary non-card string", () => {
2626
assert.throws(
2727
() => getCardValue("invalid"),
2828
new RegExp(
29-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
29+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
3030
),
3131
"Expected clear error"
3232
);
@@ -37,7 +37,7 @@ test("Three digit card string", () => {
3737
assert.throws(
3838
() => getCardValue(card),
3939
new RegExp(
40-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
40+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
4141
),
4242
"Expected clear error"
4343
);
@@ -48,7 +48,7 @@ test("Card with leading 0", () => {
4848
assert.throws(
4949
() => getCardValue(card),
5050
new RegExp(
51-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
51+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
5252
),
5353
"Expected clear error"
5454
);
@@ -59,7 +59,7 @@ test("Card with face followed by number", () => {
5959
assert.throws(
6060
() => getCardValue(card),
6161
new RegExp(
62-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
62+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
6363
),
6464
"Expected clear error"
6565
);
@@ -70,7 +70,7 @@ test("Card with number followed by face", () => {
7070
assert.throws(
7171
() => getCardValue(card),
7272
new RegExp(
73-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
73+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
7474
),
7575
"Expected clear error"
7676
);
@@ -81,7 +81,7 @@ test("Card with multiple same suit", () => {
8181
assert.throws(
8282
() => getCardValue(card),
8383
new RegExp(
84-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
84+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
8585
),
8686
"Expected clear error"
8787
);
@@ -92,7 +92,7 @@ test("Card with multiple different suit", () => {
9292
assert.throws(
9393
() => getCardValue(card),
9494
new RegExp(
95-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
95+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
9696
),
9797
"Expected clear error"
9898
);
@@ -103,7 +103,7 @@ test("Card with decimal number", () => {
103103
assert.throws(
104104
() => getCardValue(card),
105105
new RegExp(
106-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
106+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
107107
),
108108
"Expected clear error"
109109
);
@@ -114,7 +114,7 @@ test("Card with negative number", () => {
114114
assert.throws(
115115
() => getCardValue(card),
116116
new RegExp(
117-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
117+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
118118
),
119119
"Expected clear error"
120120
);
@@ -125,7 +125,7 @@ test("Card with leading whitespace", () => {
125125
assert.throws(
126126
() => getCardValue(card),
127127
new RegExp(
128-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
128+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
129129
),
130130
"Expected clear error"
131131
);
@@ -136,7 +136,7 @@ test("Card with trailing whitespace", () => {
136136
assert.throws(
137137
() => getCardValue(card),
138138
new RegExp(
139-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
139+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
140140
),
141141
"Expected clear error"
142142
);
@@ -147,7 +147,7 @@ test("Card with middle whitespace", () => {
147147
assert.throws(
148148
() => getCardValue(card),
149149
new RegExp(
150-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
150+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
151151
),
152152
"Expected clear error"
153153
);
@@ -158,7 +158,7 @@ test("Card with invalid face", () => {
158158
assert.throws(
159159
() => getCardValue(card),
160160
new RegExp(
161-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
161+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
162162
),
163163
"Expected clear error"
164164
);
@@ -169,7 +169,7 @@ test("Card with invalid Ace", () => {
169169
assert.throws(
170170
() => getCardValue(card),
171171
new RegExp(
172-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
172+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
173173
),
174174
"Expected clear error"
175175
);
@@ -180,7 +180,7 @@ test("Card with no suit", () => {
180180
assert.throws(
181181
() => getCardValue(card),
182182
new RegExp(
183-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
183+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
184184
),
185185
"Expected clear error"
186186
);
@@ -191,7 +191,7 @@ test("Card with no rank", () => {
191191
assert.throws(
192192
() => getCardValue(card),
193193
new RegExp(
194-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
194+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
195195
),
196196
"Expected clear error"
197197
);
@@ -202,7 +202,7 @@ test("Empty String", () => {
202202
assert.throws(
203203
() => getCardValue(card),
204204
new RegExp(
205-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
205+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
206206
),
207207
"Expected clear error"
208208
);
@@ -213,7 +213,7 @@ test("Card with invalid number one above max", () => {
213213
assert.throws(
214214
() => getCardValue(card),
215215
new RegExp(
216-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
216+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
217217
),
218218
"Expected clear error"
219219
);
@@ -224,7 +224,7 @@ test("Card with invalid number one below min", () => {
224224
assert.throws(
225225
() => getCardValue(card),
226226
new RegExp(
227-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
227+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
228228
),
229229
"Expected clear error"
230230
);

‎implement-and-rewrite-tests/implement/3-get-card-value.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function getCardValue(card) {
3333

3434
if (!validSuits.includes(suit)) {
3535
throw new Error(
36-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
36+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
3737
);
3838
}
3939
if (validNumberRanks.includes(rank)) {
@@ -49,6 +49,6 @@ export function getCardValue(card) {
4949
}
5050

5151
throw new Error(
52-
`Invalid input. Expected a number followed by a suit, but got "${card}"`
52+
`Invalid input. Expected a valid rank followed by a suit, but got "${card}"`
5353
);
5454
}

0 commit comments

Comments
 (0)