Skip to content

Commit 24a79d1

Browse files
author
Serhat Bolsu
committed
Chagned global.api into resources to support intellisense with test case files.
1 parent c1cc380 commit 24a79d1

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

config/setup.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
const api = require('../resources/api.js');
2-
global.api = api;

resources/api.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/resources.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import VegetableResource from './vegetable.resource';
2+
3+
class Resources {
4+
vegetable() {
5+
return new VegetableResource();
6+
}
7+
}
8+
9+
export default new Resources();

test/basic_api_resource.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
// notice that `api` is globally available to use
1+
import resources from '../resources/resources';
22

33
describe('Vegetables - using Api Resource facade', function() {
44
it('should get default', async function() {
5-
const vegetables = await api.vegetable().getAll();
5+
const vegetables = await resources.vegetable().getAll();
66
expect(vegetables[0]).toHaveProperty('id');
7-
console.log(api.vegetable().getUniqueVegetables());
7+
console.log(resources.vegetable().getUniqueVegetables());
88
});
99

1010
it('should get without optional', async function() {
11-
const vegetables = await api.vegetable().getAll(false);
11+
const vegetables = await resources.vegetable().getAll(false);
1212
expect(vegetables[0]).not.toHaveProperty('origin');
1313
});
1414

1515
it('should create vegetable', async function() {
16-
const res = await api.vegetable().create(
16+
const res = await resources.vegetable().create(
1717
"Orange", "UAE", "5", "2020-03-10");
1818
expect(res.status).toBe(201);
1919
expect(res.text).toMatch(/added: Orange/);
2020
});
2121

2222
it('should delete vegetable', async function() {
23-
const res = await api.vegetable().create(
23+
const res = await resources.vegetable().create(
2424
"Orange", "UAE", "5", "2020-03-10");
2525
expect(res.status).toBe(201);
2626
const id = res.body.id;
27-
const res2 = await api.vegetable().delete('/vegetables' + '/' + id);
27+
const res2 = await resources.vegetable().delete('/vegetables' + '/' + id);
2828
expect(res2.status).toBe(200);
2929
});
3030
});

0 commit comments

Comments
 (0)