-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegrade_mvp.test.js
101 lines (93 loc) · 4.27 KB
/
codegrade_mvp.test.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const functions = require('./index.js');
const { burger } = require('./index.js');
let reviews;
beforeEach(()=>{
reviews = [
{name: "Daniela", rating: 5, feedback:"Beautiful atmosphere and wonderful vegan options!"},
{name: "Jack", rating: 3, feedback:"A little too hipster for my taste, but the burger was decent, if overpriced"},
{name: "Miranda", rating: 4, feedback:"fun trivia and cool vibes"},
{name: "Wen", rating: 4.5, feedback:"I don't leave my house often, but when I do, it's for this place. Highly reccomend."},
{name: "Brett", rating: 3, feedback: "great selection of snacks and a nice cafe area to get work done during the day."},
{name: "Julius", rating: 2, feedback: "I was largely unimpressed by this venue. Nothing special on the menu and too expensive. The atmosphere is polarizing, and not for me, but I think some would like it." },
{name:"Lauren", rating: 4, feedback: "Absolutely love that they have karaoke Fridays! Food and drink selection is okay."},
{name:"Reyna", rating: 3.5, feedback: "this place is chill with really cool people, great for getting work done on weekdays"},
]
})
describe('fooFunction', ()=>{
it('foo returns foo', ()=>{
expect(functions.foo()).toBe('bar');
})
});
describe('createMenuItem', ()=>{
it('createMenuItem returns object', ()=>{
expect(functions.createMenuItem('taco', 8, 'lunch')).toEqual({name: 'taco', price: 8, category:'lunch'});
})
});
// test burger method discount here
describe('burger.discount', ()=>{
it('discount for teacher', ()=>{
expect(burger.discount('teacher')).toBe(13.5);
})
it('discount for student', ()=>{
expect(burger.discount('student')).toBe(13.5);
})
it('discount for public', ()=>{
expect(burger.discount('public')).toBe(16.2);
})
});
describe('addReview', ()=>{
it('addReview returns an array of objects', ()=>{
expect(functions.addReview(reviews, 'Daniela', 5, 'great eats!')).toEqual([
{
name: 'Daniela',
rating: 5,
feedback: 'Beautiful atmosphere and wonderful vegan options!'
},
{
name: 'Jack',
rating: 3,
feedback: 'A little too hipster for my taste, but the burger was decent, if overpriced'
},
{ name: 'Miranda', rating: 4, feedback: 'fun trivia and cool vibes' },
{
name: 'Wen',
rating: 4.5,
feedback: "I don't leave my house often, but when I do, it's for this place. Highly reccomend."
},
{
name: 'Brett',
rating: 3,
feedback: 'great selection of snacks and a nice cafe area to get work done during the day.'
},
{
name: 'Julius',
rating: 2,
feedback: 'I was largely unimpressed by this venue. Nothing special on the menu and too expensive. The atmosphere is polarizing, and not for me, but I think some would like it.'
},
{
name: 'Lauren',
rating: 4,
feedback: 'Absolutely love that they have karaoke Fridays! Food and drink selection is okay.'
},
{
name: 'Reyna',
rating: 3.5,
feedback: 'this place is chill with really cool people, great for getting work done on weekdays'
},
{ name: 'Daniela', rating: 5, feedback: 'great eats!' }
]);
})
});
describe('getReviewByIndex', ()=>{
it('getReviewByIndex returns a string', ()=>{
expect(functions.getReviewByIndex(reviews, 0)).toBe("Daniela gave the restaurant a 5 star review, and their feedback was: Beautiful atmosphere and wonderful vegan options!");
})
it('getReviewByIndex returns a string', ()=>{
expect(functions.getReviewByIndex(reviews, 2)).toBe("Miranda gave the restaurant a 4 star review, and their feedback was: fun trivia and cool vibes");
})
});
describe('getLastReview', ()=>{
it('getLastReview returns a string', ()=>{
expect(functions.getLastReview(reviews)).toBe(`Reyna gave the restaurant a 3.5 star review, and their feedback was: this place is chill with really cool people, great for getting work done on weekdays`);
})
});