Skip to content

Commit 32c1731

Browse files
committed
Check that the Spy is doing it's job!
1 parent b555f2d commit 32c1731

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Diff for: exercises/function_spies/exercise.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ var exercise = module.exports = runner.custom(function(Spy, input) {
3232
exercise.emit('fail', exercise.__('incorrect_return'))
3333
}
3434
})
35+
count++
36+
37+
if (!spy.count || spy.count !== count) {
38+
exercise.emit('fail', exercise.__('incorrect_count'))
39+
} else {
40+
result.push(exercise.__('call_times', spy.count))
41+
}
3542

36-
result.push(exercise.__('call_times', spy.count))
3743
return result
3844
}).quiet(input)

Diff for: i18n/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"call_times": "Method called %d times.",
3232
"incorrect_return": "Check your function's return value!",
3333
"incorrect_this": "Check the function's this! Hint: Function#apply",
34-
"not_all_args": "Check you are passing ALL the arguments! Hint: Function#apply"
34+
"not_all_args": "Check you are passing ALL the arguments! Hint: Function#apply",
35+
"incorrect_count": "Check that your Spy is counting the method invocations correctly!"
3536
},
3637
"Trampoline": {
3738
"intro": "repeating %d times",

Diff for: i18n/fr.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"call_times": "Méthode appelée %d fois.",
5252
"incorrect_return": "Vérifiez la valeur de retour de votre fonction !",
5353
"incorrect_this": "Vérifiez le `this` de votre fonction ! Conseil : `Function#apply()`.",
54-
"not_all_args": "Vérifiez que vous transmettez bien TOUS les arguments ! Conseil : `Function#apply()`."
54+
"not_all_args": "Vérifiez que vous transmettez bien TOUS les arguments ! Conseil : `Function#apply()`.",
55+
"incorrect_count": "Vérifiez que votre Spy est compter les appels de méthode correctement!"
5556
},
5657
"Trampoline": {
5758
"intro": "Répétition de la fonction %d fois",

Diff for: i18n/ko.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"call_times": "메소드가 %d번 호출되었습니다.",
5252
"incorrect_return": "함수의 반환값을 확인하세요!",
5353
"incorrect_this": "함수의 this를 확인하세요! 힌트: Function#apply",
54-
"not_all_args": "인자를 모두 넘겼는지 확인하세요! 힌트: Function#apply"
54+
"not_all_args": "인자를 모두 넘겼는지 확인하세요! 힌트: Function#apply",
55+
"incorrect_count": "Check that your Spy is counting the method invocations correctly!"
5556
},
5657
"Trampoline": {
5758
"intro": "%d번 반복 중",

0 commit comments

Comments
 (0)