adminmate-express-mongoose 1.2.2 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/jest.config.js +7 -1
- package/package.json +17 -6
- package/src/controllers/chart-pie.js +32 -0
- package/src/controllers/chart-ranking.js +9 -0
- package/src/controllers/chart-time.js +147 -0
- package/src/controllers/chart-value.js +55 -0
- package/src/controllers/model-autocomplete.js +2 -2
- package/src/controllers/model-getall.js +8 -8
- package/src/controllers/model-getone.js +5 -4
- package/src/controllers/model-query.js +35 -195
- package/test/__snapshots__/actions.test.js.snap +0 -56
- package/test/__snapshots__/model-getall.test.js.snap +0 -656
- package/test/__snapshots__/model-getone.test.js.snap +0 -33
- package/test/actions.test.js +0 -163
- package/test/app.js +0 -63
- package/test/model-getall.test.js +0 -203
- package/test/model-getone.test.js +0 -69
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Testing POST /api/models/cars/5cd5308e695db945d3cc81b1 Simple get one route 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"data": Object {
|
|
6
|
-
"_id": "5cd5308e695db945d3cc81b1",
|
|
7
|
-
"createdAt": "2021-04-02T00:00:00.000Z",
|
|
8
|
-
"manufacturer": "Porsche",
|
|
9
|
-
"name": "Porsche 356",
|
|
10
|
-
"updatedAt": "2021-04-02T00:00:00.000Z",
|
|
11
|
-
"user_id": Object {
|
|
12
|
-
"id": "5cd5308e695db945d3cc81a1",
|
|
13
|
-
"label": "5cd5308e695db945d3cc81a1",
|
|
14
|
-
"type": "ref",
|
|
15
|
-
},
|
|
16
|
-
"year": 1948,
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
exports[`Testing POST /api/models/users/5cd5308e695db945d3cc81a1 Simple get one route 1`] = `
|
|
22
|
-
Object {
|
|
23
|
-
"data": Object {
|
|
24
|
-
"_id": "5cd5308e695db945d3cc81a1",
|
|
25
|
-
"birthdate": "2021-04-02T00:00:00.000Z",
|
|
26
|
-
"createdAt": "2021-04-02T00:00:00.000Z",
|
|
27
|
-
"firstname": "John",
|
|
28
|
-
"lastname": "Doe",
|
|
29
|
-
"rating": 4,
|
|
30
|
-
"updatedAt": "2021-04-02T00:00:00.000Z",
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
`;
|
package/test/actions.test.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// Hide console.log
|
|
2
|
-
global.console = {
|
|
3
|
-
log: jest.fn(),
|
|
4
|
-
// Keep native behaviour for other methods
|
|
5
|
-
error: console.error,
|
|
6
|
-
warn: console.warn,
|
|
7
|
-
info: console.info,
|
|
8
|
-
debug: console.debug,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const supertest = require('supertest');
|
|
12
|
-
const jwt = require('jwt-simple');
|
|
13
|
-
|
|
14
|
-
// Include the app
|
|
15
|
-
const app = require('./app.js');
|
|
16
|
-
|
|
17
|
-
// Endpoint prefix
|
|
18
|
-
const prefix = '/adminmate/api';
|
|
19
|
-
|
|
20
|
-
// Generate the admin token
|
|
21
|
-
const adminToken = jwt.encode({
|
|
22
|
-
exp_date: Date.now() + 1000
|
|
23
|
-
}, 'authkey_secret');
|
|
24
|
-
|
|
25
|
-
// Generate the perm token
|
|
26
|
-
const permToken = jwt.encode({
|
|
27
|
-
exp_date: Date.now() + 1000,
|
|
28
|
-
data: {
|
|
29
|
-
authorized_models: ['*']
|
|
30
|
-
}
|
|
31
|
-
}, '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko');
|
|
32
|
-
|
|
33
|
-
// Generate the users perm token
|
|
34
|
-
const ModelPermToken_Users = jwt.encode({
|
|
35
|
-
exp_date: Date.now() + 1000,
|
|
36
|
-
data: {
|
|
37
|
-
model: 'users',
|
|
38
|
-
can_create: true,
|
|
39
|
-
can_update: ['*'],
|
|
40
|
-
can_delete: true,
|
|
41
|
-
can_configure: true,
|
|
42
|
-
can_use_actions: ['*'],
|
|
43
|
-
can_use_segments: ['*']
|
|
44
|
-
}
|
|
45
|
-
}, '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko');
|
|
46
|
-
|
|
47
|
-
// Generate the users perm token
|
|
48
|
-
const ModelPermToken_Cars = jwt.encode({
|
|
49
|
-
exp_date: Date.now() + 1000,
|
|
50
|
-
data: {
|
|
51
|
-
model: 'cars',
|
|
52
|
-
can_create: true,
|
|
53
|
-
can_update: ['*'],
|
|
54
|
-
can_delete: true,
|
|
55
|
-
can_configure: true,
|
|
56
|
-
can_use_actions: ['*'],
|
|
57
|
-
can_use_segments: ['*']
|
|
58
|
-
}
|
|
59
|
-
}, '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko');
|
|
60
|
-
|
|
61
|
-
// Before all
|
|
62
|
-
beforeAll(done => {
|
|
63
|
-
done();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Actions
|
|
67
|
-
describe('Testing GET /api/models/:model/actions', () => {
|
|
68
|
-
it('should return a 403 http response', async () => {
|
|
69
|
-
// Make request
|
|
70
|
-
const response = await supertest(app)
|
|
71
|
-
.get(prefix + '/models/users/actions');
|
|
72
|
-
|
|
73
|
-
// Check response
|
|
74
|
-
expect(response.status).toBe(403);
|
|
75
|
-
expect(response.body.code).toBe('not_authorized');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should return a 403 http response', async () => {
|
|
79
|
-
// Make request
|
|
80
|
-
const response = await supertest(app)
|
|
81
|
-
.get(prefix + '/models/users/actions')
|
|
82
|
-
.set('x-access-token', adminToken)
|
|
83
|
-
.set('x-perm-token', permToken)
|
|
84
|
-
.query({ ids: [], target: '' })
|
|
85
|
-
|
|
86
|
-
// Check response
|
|
87
|
-
expect(response.status).toBe(403);
|
|
88
|
-
expect(response.body.message).toBe('Invalid request');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should return a 200 http response for users', async () => {
|
|
92
|
-
// Make request
|
|
93
|
-
const response = await supertest(app)
|
|
94
|
-
.get(prefix + '/models/users/actions')
|
|
95
|
-
.set('x-access-token', adminToken)
|
|
96
|
-
.set('x-perm-token', permToken)
|
|
97
|
-
.set('x-model-perm-token', ModelPermToken_Users)
|
|
98
|
-
.query({
|
|
99
|
-
ids: '9',
|
|
100
|
-
target: 'item'
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Check response
|
|
104
|
-
expect(response.status).toBe(200);
|
|
105
|
-
expect(response.body).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should return a 200 http response for cars', async () => {
|
|
109
|
-
// Make request
|
|
110
|
-
const response = await supertest(app)
|
|
111
|
-
.get(prefix + '/models/cars/actions')
|
|
112
|
-
.set('x-access-token', adminToken)
|
|
113
|
-
.set('x-perm-token', permToken)
|
|
114
|
-
.set('x-model-perm-token', ModelPermToken_Cars)
|
|
115
|
-
.query({
|
|
116
|
-
ids: '5cd5308e695db945d3cc81c5,5cd5308e695db945d3cc81c6,5cd5308e695db945d3cc81c7',
|
|
117
|
-
target: 'bulk'
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Check response
|
|
121
|
-
expect(response.status).toBe(200);
|
|
122
|
-
expect(response.body).toMatchSnapshot();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should return a 200 http response for cars-bulk', async () => {
|
|
126
|
-
// Make request
|
|
127
|
-
const response = await supertest(app)
|
|
128
|
-
.get(prefix + '/models/cars/actions')
|
|
129
|
-
.set('x-access-token', adminToken)
|
|
130
|
-
.set('x-perm-token', permToken)
|
|
131
|
-
.set('x-model-perm-token', ModelPermToken_Cars)
|
|
132
|
-
.query({
|
|
133
|
-
ids: '5cd5308e695db945d3cc81c6',
|
|
134
|
-
target: 'bulk'
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Check response
|
|
138
|
-
expect(response.status).toBe(200);
|
|
139
|
-
expect(response.body).toMatchSnapshot();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should return a 200 http response for cars-item', async () => {
|
|
143
|
-
// Make request
|
|
144
|
-
const response = await supertest(app)
|
|
145
|
-
.get(prefix + '/models/cars/actions')
|
|
146
|
-
.set('x-access-token', adminToken)
|
|
147
|
-
.set('x-perm-token', permToken)
|
|
148
|
-
.set('x-model-perm-token', ModelPermToken_Cars)
|
|
149
|
-
.query({
|
|
150
|
-
ids: '5cd5308e695db945d3cc81c6',
|
|
151
|
-
target: 'item'
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Check response
|
|
155
|
-
expect(response.status).toBe(200);
|
|
156
|
-
expect(response.body).toMatchSnapshot();
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// After all
|
|
161
|
-
afterAll(done => {
|
|
162
|
-
done();
|
|
163
|
-
})
|
package/test/app.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const express = require('express');
|
|
4
|
-
|
|
5
|
-
// If you want to use the dev version of @adminmate-express-core
|
|
6
|
-
global.AM_DEV_MODE = true;
|
|
7
|
-
|
|
8
|
-
// Create express app
|
|
9
|
-
const app = express();
|
|
10
|
-
|
|
11
|
-
app.use(express.json());
|
|
12
|
-
app.use(express.urlencoded({
|
|
13
|
-
extended: true
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
// Connect to database
|
|
17
|
-
const { models, connectDb } = require('../database');
|
|
18
|
-
connectDb().then(async () => {
|
|
19
|
-
console.log('MongoDB connected');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Init
|
|
23
|
-
const amConfig = {
|
|
24
|
-
projectId: '6037b459cbb0f63c219789eb',
|
|
25
|
-
secretKey: '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko',
|
|
26
|
-
authKey: 'authkey_secret',
|
|
27
|
-
masterPassword: 'demo-password',
|
|
28
|
-
models: [
|
|
29
|
-
{
|
|
30
|
-
slug: 'users',
|
|
31
|
-
model: models.User,
|
|
32
|
-
actions: []
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
slug: 'cars',
|
|
36
|
-
model: models.Car,
|
|
37
|
-
actions: [
|
|
38
|
-
{
|
|
39
|
-
label: 'Block the car',
|
|
40
|
-
code: 'block_car',
|
|
41
|
-
target: ['item'],
|
|
42
|
-
filter: car => {
|
|
43
|
-
return car.year === 1960
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
segments: [
|
|
48
|
-
{
|
|
49
|
-
label: 'Ferrari',
|
|
50
|
-
code: 'ferrari',
|
|
51
|
-
query: {
|
|
52
|
-
name: { $regex: 'erra', $options: 'i' }
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const plugin = require('../index.js');
|
|
61
|
-
app.use(plugin.init(amConfig));
|
|
62
|
-
|
|
63
|
-
module.exports = app;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// Hide console.log
|
|
2
|
-
global.console = {
|
|
3
|
-
log: jest.fn(),
|
|
4
|
-
// Keep native behaviour for other methods
|
|
5
|
-
error: console.error,
|
|
6
|
-
warn: console.warn,
|
|
7
|
-
info: console.info,
|
|
8
|
-
debug: console.debug,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const supertest = require('supertest');
|
|
12
|
-
const jwt = require('jwt-simple');
|
|
13
|
-
|
|
14
|
-
// Include the app
|
|
15
|
-
const app = require('./app.js');
|
|
16
|
-
|
|
17
|
-
// Endpoint prefix
|
|
18
|
-
const prefix = '/adminmate/api';
|
|
19
|
-
|
|
20
|
-
// Generate the admin token
|
|
21
|
-
const adminToken = jwt.encode({
|
|
22
|
-
exp_date: Date.now() + 1000
|
|
23
|
-
}, 'authkey_secret');
|
|
24
|
-
|
|
25
|
-
// Generate the perm token
|
|
26
|
-
const permToken = jwt.encode({
|
|
27
|
-
exp_date: Date.now() + 1000,
|
|
28
|
-
data: {
|
|
29
|
-
authorized_models: ['*']
|
|
30
|
-
}
|
|
31
|
-
}, '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko');
|
|
32
|
-
|
|
33
|
-
// Before all
|
|
34
|
-
beforeAll(done => {
|
|
35
|
-
done();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// POST /models/users
|
|
39
|
-
describe('Testing POST /api/models/users', () => {
|
|
40
|
-
it('Without access token', async () => {
|
|
41
|
-
// Make request
|
|
42
|
-
const response = await supertest(app)
|
|
43
|
-
.post(prefix + '/models/users');
|
|
44
|
-
|
|
45
|
-
// Check response
|
|
46
|
-
expect(response.status).toBe(403);
|
|
47
|
-
expect(response.body.code).toBe('not_authorized');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('With access token', async () => {
|
|
51
|
-
// Make request
|
|
52
|
-
const response = await supertest(app)
|
|
53
|
-
.post(prefix + '/models/users')
|
|
54
|
-
.set('x-access-token', adminToken)
|
|
55
|
-
.set('x-perm-token', permToken);
|
|
56
|
-
|
|
57
|
-
// Check response
|
|
58
|
-
expect(response.status).toBe(200);
|
|
59
|
-
expect(response.body).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// POST /models/cars
|
|
64
|
-
describe('Testing POST /api/models/cars', () => {
|
|
65
|
-
it('With access token', async () => {
|
|
66
|
-
// Make request
|
|
67
|
-
const response = await supertest(app)
|
|
68
|
-
.post(prefix + '/models/cars')
|
|
69
|
-
.set('x-access-token', adminToken)
|
|
70
|
-
.set('x-perm-token', permToken);
|
|
71
|
-
|
|
72
|
-
// Check response
|
|
73
|
-
expect(response.status).toBe(200);
|
|
74
|
-
expect(response.body).toMatchSnapshot();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('With "refFields" parameter', async () => {
|
|
78
|
-
// Make request
|
|
79
|
-
const response = await supertest(app)
|
|
80
|
-
.post(prefix + '/models/cars')
|
|
81
|
-
.set('x-access-token', adminToken)
|
|
82
|
-
.set('x-perm-token', permToken)
|
|
83
|
-
.send({
|
|
84
|
-
refFields: {
|
|
85
|
-
users: 'firstname lastname'
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Check response
|
|
90
|
-
expect(response.status).toBe(200);
|
|
91
|
-
expect(response.body).toMatchSnapshot();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('With "fields" parameter (name & manufacturer only)', async () => {
|
|
95
|
-
// Make request
|
|
96
|
-
const response = await supertest(app)
|
|
97
|
-
.post(prefix + '/models/cars')
|
|
98
|
-
.set('x-access-token', adminToken)
|
|
99
|
-
.set('x-perm-token', permToken)
|
|
100
|
-
.send({
|
|
101
|
-
fields: ['name', 'manufacturer']
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Check response
|
|
105
|
-
expect(response.status).toBe(200);
|
|
106
|
-
expect(response.body).toMatchSnapshot();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('With "page" parameter set to 2', async () => {
|
|
110
|
-
// Make request
|
|
111
|
-
const response = await supertest(app)
|
|
112
|
-
.post(prefix + '/models/cars')
|
|
113
|
-
.set('x-access-token', adminToken)
|
|
114
|
-
.set('x-perm-token', permToken)
|
|
115
|
-
.send({
|
|
116
|
-
page: 2
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Check response
|
|
120
|
-
expect(response.status).toBe(200);
|
|
121
|
-
expect(response.body).toMatchSnapshot();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('With a "search" parameter', async () => {
|
|
125
|
-
// Make request
|
|
126
|
-
const response = await supertest(app)
|
|
127
|
-
.post(prefix + '/models/cars')
|
|
128
|
-
.set('x-access-token', adminToken)
|
|
129
|
-
.set('x-perm-token', permToken)
|
|
130
|
-
.send({
|
|
131
|
-
fields: ['name'],
|
|
132
|
-
search: 'Porsche 91'
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Check response
|
|
136
|
-
expect(response.status).toBe(200);
|
|
137
|
-
expect(response.body).toMatchSnapshot();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('With a "order" parameter', async () => {
|
|
141
|
-
// Make request
|
|
142
|
-
const response = await supertest(app)
|
|
143
|
-
.post(prefix + '/models/cars')
|
|
144
|
-
.set('x-access-token', adminToken)
|
|
145
|
-
.set('x-perm-token', permToken)
|
|
146
|
-
.send({
|
|
147
|
-
fields: ['name'],
|
|
148
|
-
search: 'Porsche 91',
|
|
149
|
-
order: [['name', 'ASC']]
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// Check response
|
|
153
|
-
expect(response.status).toBe(200);
|
|
154
|
-
expect(response.body).toMatchSnapshot();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('With a "filters" parameter', async () => {
|
|
158
|
-
// Make request
|
|
159
|
-
const response = await supertest(app)
|
|
160
|
-
.post(prefix + '/models/cars')
|
|
161
|
-
.set('x-access-token', adminToken)
|
|
162
|
-
.set('x-perm-token', permToken)
|
|
163
|
-
.send({
|
|
164
|
-
fields: ['name', 'year'],
|
|
165
|
-
search: 'Porsche',
|
|
166
|
-
filters: {
|
|
167
|
-
operator: 'or',
|
|
168
|
-
list: [
|
|
169
|
-
{ field: 'year', operator: 'is', value: 1968 },
|
|
170
|
-
{ field: 'year', operator: 'is', value: 1969 }
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Check response
|
|
176
|
-
expect(response.status).toBe(200);
|
|
177
|
-
expect(response.body).toMatchSnapshot();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('With a "segment" parameter', async () => {
|
|
181
|
-
// Make request
|
|
182
|
-
const response = await supertest(app)
|
|
183
|
-
.post(prefix + '/models/cars')
|
|
184
|
-
.set('x-access-token', adminToken)
|
|
185
|
-
.set('x-perm-token', permToken)
|
|
186
|
-
.send({
|
|
187
|
-
fields: ['name', 'year'],
|
|
188
|
-
segment: {
|
|
189
|
-
type: 'code',
|
|
190
|
-
data: 'ferrari'
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Check response
|
|
195
|
-
expect(response.status).toBe(200);
|
|
196
|
-
expect(response.body).toMatchSnapshot();
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// After all
|
|
201
|
-
afterAll(done => {
|
|
202
|
-
done();
|
|
203
|
-
})
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Hide console.log
|
|
2
|
-
global.console = {
|
|
3
|
-
log: jest.fn(),
|
|
4
|
-
// Keep native behaviour for other methods
|
|
5
|
-
error: console.error,
|
|
6
|
-
warn: console.warn,
|
|
7
|
-
info: console.info,
|
|
8
|
-
debug: console.debug,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const supertest = require('supertest');
|
|
12
|
-
const jwt = require('jwt-simple');
|
|
13
|
-
|
|
14
|
-
// Include the app
|
|
15
|
-
const app = require('./app.js');
|
|
16
|
-
|
|
17
|
-
// Endpoint prefix
|
|
18
|
-
const prefix = '/adminmate/api';
|
|
19
|
-
|
|
20
|
-
// Generate the admin token
|
|
21
|
-
const adminToken = jwt.encode({
|
|
22
|
-
exp_date: Date.now() + 1000
|
|
23
|
-
}, 'authkey_secret');
|
|
24
|
-
|
|
25
|
-
// Generate the perm token
|
|
26
|
-
const permToken = jwt.encode({
|
|
27
|
-
exp_date: Date.now() + 1000,
|
|
28
|
-
data: {
|
|
29
|
-
authorized_models: ['*']
|
|
30
|
-
}
|
|
31
|
-
}, '7dn6m0zrcsqta5b57hug52xlira4upqdempch65mwy5guehr33vt0r1s8cyrnmko');
|
|
32
|
-
|
|
33
|
-
// Before all
|
|
34
|
-
beforeAll(done => {
|
|
35
|
-
done();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('Testing POST /api/models/users/5cd5308e695db945d3cc81a1', () => {
|
|
39
|
-
it('Simple get one route', async () => {
|
|
40
|
-
// Make request
|
|
41
|
-
const response = await supertest(app)
|
|
42
|
-
.post(prefix + '/models/users/5cd5308e695db945d3cc81a1')
|
|
43
|
-
.set('x-access-token', adminToken)
|
|
44
|
-
.set('x-perm-token', permToken);
|
|
45
|
-
|
|
46
|
-
// Check response
|
|
47
|
-
expect(response.status).toBe(200);
|
|
48
|
-
expect(response.body).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('Testing POST /api/models/cars/5cd5308e695db945d3cc81b1', () => {
|
|
53
|
-
it('Simple get one route', async () => {
|
|
54
|
-
// Make request
|
|
55
|
-
const response = await supertest(app)
|
|
56
|
-
.post(prefix + '/models/cars/5cd5308e695db945d3cc81b1')
|
|
57
|
-
.set('x-access-token', adminToken)
|
|
58
|
-
.set('x-perm-token', permToken);
|
|
59
|
-
|
|
60
|
-
// Check response
|
|
61
|
-
expect(response.status).toBe(200);
|
|
62
|
-
expect(response.body).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// After all
|
|
67
|
-
afterAll(done => {
|
|
68
|
-
done();
|
|
69
|
-
})
|