|
1 | | -// notice that `api` is globally available to use |
| 1 | +import resources from '../resources/resources'; |
2 | 2 |
|
3 | 3 | describe('Vegetables - using Api Resource facade', function() { |
4 | 4 | it('should get default', async function() { |
5 | | - const vegetables = await api.vegetable().getAll(); |
| 5 | + const vegetables = await resources.vegetable().getAll(); |
6 | 6 | expect(vegetables[0]).toHaveProperty('id'); |
7 | | - console.log(api.vegetable().getUniqueVegetables()); |
| 7 | + console.log(resources.vegetable().getUniqueVegetables()); |
8 | 8 | }); |
9 | 9 |
|
10 | 10 | it('should get without optional', async function() { |
11 | | - const vegetables = await api.vegetable().getAll(false); |
| 11 | + const vegetables = await resources.vegetable().getAll(false); |
12 | 12 | expect(vegetables[0]).not.toHaveProperty('origin'); |
13 | 13 | }); |
14 | 14 |
|
15 | 15 | it('should create vegetable', async function() { |
16 | | - const res = await api.vegetable().create( |
| 16 | + const res = await resources.vegetable().create( |
17 | 17 | "Orange", "UAE", "5", "2020-03-10"); |
18 | 18 | expect(res.status).toBe(201); |
19 | 19 | expect(res.text).toMatch(/added: Orange/); |
20 | 20 | }); |
21 | 21 |
|
22 | 22 | it('should delete vegetable', async function() { |
23 | | - const res = await api.vegetable().create( |
| 23 | + const res = await resources.vegetable().create( |
24 | 24 | "Orange", "UAE", "5", "2020-03-10"); |
25 | 25 | expect(res.status).toBe(201); |
26 | 26 | const id = res.body.id; |
27 | | - const res2 = await api.vegetable().delete('/vegetables' + '/' + id); |
| 27 | + const res2 = await resources.vegetable().delete('/vegetables' + '/' + id); |
28 | 28 | expect(res2.status).toBe(200); |
29 | 29 | }); |
30 | 30 | }); |
0 commit comments