From 8d76f63f5c473773a782325a10f352857cba1845 Mon Sep 17 00:00:00 2001 From: nprimo Date: Wed, 21 Dec 2022 16:19:30 +0100 Subject: [PATCH] feat(veterinary): add tests --- js/tests/veterinary_test.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 js/tests/veterinary_test.js diff --git a/js/tests/veterinary_test.js b/js/tests/veterinary_test.js new file mode 100644 index 000000000..aef3a17ee --- /dev/null +++ b/js/tests/veterinary_test.js @@ -0,0 +1,37 @@ +export const tests = [] + +const testProperties = () => { + return ( + Array.isArray(veterinary.animalKnowledge) && + typeof veterinary.canTreat === 'function' && + typeof veterinary.respondClient === 'function' + ) +} + +const testCanTreat = () => { + veterinary.animalKnowledge.push('dog', 'cat', 'elephant') + return ( + veterinary.canTreat('dog') && + veterinary.canTreat('cat') && + veterinary.canTreat('elephant') && + !veterinary.canTreat('') && + !veterinary.canTreat('goldfish') + ) +} + +const testRespondClient = () => { + veterinary.animalKnowledge.push('parrot') + const vetResponse1 = veterinary.respondClient('Jack', 'parrot') + const vetResponse2 = veterinary.respondClient('Matias', 'cobra') + + return ( + vetResponse1.includes('Jack') && + vetResponse1.toLowerCase().includes('yes') && + vetResponse2.includes('Matias') && + vetResponse2.toLowerCase().includes('no') + ) +} + +tests.push(testProperties, testCanTreat, testRespondClient) + +Object.freeze(tests)