Skip to content

Commit 85ba10e

Browse files
committed
Add function to test meal counter
1 parent 2a67719 commit 85ba10e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/modules/test/counter.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import counter from '../counter';
2+
3+
describe('Meals Counter function Test', () => {
4+
const mealArray = [
5+
{
6+
mealID: 1234,
7+
mealName: 'Baked beans',
8+
mealDescription: 'it is a canned meal, no need for a description',
9+
},
10+
{
11+
mealID: 1890,
12+
mealName: 'Fried Rice',
13+
mealDescription: 'Just fry the rice',
14+
},
15+
];
16+
test('should return meals array length of 2', () => {
17+
const mealLength = counter.meals(mealArray);
18+
expect(mealLength).toBe(2);
19+
});
20+
21+
test('should return meals array length of 5 ', () => {
22+
mealArray.push(
23+
{
24+
mealID: 2040,
25+
mealName: 'Another meal',
26+
mealDescription: 'Unfortunately there is no description',
27+
},
28+
{
29+
mealID: 2990,
30+
mealName: 'this is a nice meal',
31+
mealDescription: 'Unfortunately there is no description',
32+
},
33+
);
34+
const mealLength = counter.meals(mealArray);
35+
expect(mealLength).toBe(4);
36+
});
37+
});

0 commit comments

Comments
 (0)