forked from MarohnHoward/animal_feeder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedTest.test.ts
More file actions
69 lines (64 loc) · 2.58 KB
/
feedTest.test.ts
File metadata and controls
69 lines (64 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Starting on line 27 is where you will begin your code.
In this exercise you will be adding loops that contain the premade arrays
EX./answer test("Alex likes the food we expect", () => {
lionFood.forEach((food) => {
expect(alex.feed(food)).toBe(`Alex the Lion likes ${food}!`)
})
You will find the animal class that we have created in the animal.ts
You will find the array of animals using that class in zoo.ts
You do not need to edit those you are only editing the test here, but they are nice to look at.
All other instructions are found in the read me file. Good luck and most importantly have fun!
*/
import { Animal } from "./animal";
import { getAnimal } from "./zoo";
const alex: Animal = getAnimal("Alex");
const marty: Animal = getAnimal("Marty");
const melman: Animal = getAnimal("Melman");
const gloria: Animal = getAnimal("Gloria");
const lionFood = ["meat"];
const zebraFood = ["grass", "leaves", "shrubs", "bark"];
const giraffeFood = ["leaves", "hay", "carrots"];
const hippoFood = ["grass", "reeds", "shoots"];
const badFood = ["shrimp", "potatoes", "pizza", "icecream"];
describe("feeding animals", () => {
test("Alex likes the food we expect", () => {
lionFood.forEach((food) => {
expect(alex.feed(food)).toBe(`Alex the Lion likes ${food}!`)
console.log(`Alex ate this ${food}`)
})
badFood.forEach((food) => {
expect(alex.feed(food)).toBe(`Alex the Lion does not like ${food}!`)
console.log(`Alex ate this ${food}`)
})
});
test("Marty likes the food we expect", () => {
zebraFood.forEach((food) => {
expect(marty.feed(food)).toBe(`Marty the Zebra likes ${food}!`)
console.log(`Marty ate this ${food}`)
})
badFood.forEach((food) => {
expect(marty.feed(food)).toBe(`Marty the Zebra does not like ${food}!`)
console.log(`Marty ate ${food}`)
})
});
test("Melman likes the food we expect", () => {
giraffeFood.forEach((food) => {
expect(melman.feed(food)).toBe(`Melman the Giraffe likes ${food}!`)
console.log(`What melman ate ${food}`)
})
badFood.forEach((food) => {
expect(melman.feed(food)).toBe(`Melman the Giraffe does not like ${food}!`)
console.log(`Melman ate ${food} silly melman `)
})
});
test("Gloria likes the food we expect", () => {
hippoFood.forEach((food) => {
expect(gloria.feed(food)).toBe(`Gloria the Hippo likes ${food}!`)
console.log(`Gloria ate ${food}!`)
})
badFood.forEach((food) => {
expect(gloria.feed(food)).toBe(`Gloria the Hippo does not like ${food}!`)
console.log(`Gloria ate ${food}`)
})
});
});