-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path20_restTests.mjs
More file actions
95 lines (81 loc) · 3.02 KB
/
Copy path20_restTests.mjs
File metadata and controls
95 lines (81 loc) · 3.02 KB
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
import { describe, it, beforeEach } from 'node:test';
import assert from 'node:assert/strict';
import request from 'supertest';
import { reqRest } from '../utils/request.mjs';
import { timestamp } from '../utils/timestamp.mjs';
import { envUrlRest, headers } from '../config/envConfig.mjs';
describe('20. REST tests', () => {
beforeEach(timestamp);
//REST tests Folder
it('[rest] Named query Get Related', () => {
return reqRest('/Related/?select(id,name)')
.expect((r) => assert.equal(r.body.length, 5, r.text))
.expect((r) => {
r.body.forEach((row, i) => {
assert.equal(row.id, (i + 1).toString(), r.text);
});
})
.expect(200);
});
it('[rest] Named query Get SubObject', () => {
return reqRest('/SubObject/?select(id,relatedId)')
.expect((r) => assert.equal(r.body.length, 6, r.text))
.expect((r) => {
r.body.forEach((row, i) => {
assert.equal(row.id, i.toString(), r.text);
});
})
.expect(200);
});
it('[rest] Query by primary key field', () => {
return reqRest('/Related/?id==1&select(id,name)')
.expect((r) => assert.equal(r.body[0].id, '1', r.text))
.expect(200);
});
it('[rest] Query by variable non null', () => {
return reqRest('/Related/?id==2&select(id,name)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query by var nullable', () => {
return reqRest('/SubObject/?any==any-2&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query by var with null var', () => {
return reqRest('/SubObject/?any==null&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '0', r.text))
.expect((r) => assert.equal(r.body[0].any, null, r.text))
.expect(200);
});
it('[rest] Query by nested attribute', () => {
return reqRest('/SubObject/?related.name==name-2&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query by multiple nested attributes', () => {
return reqRest('/SubObject/?any==any-2&related.name==name-2&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query by nested attribute primary key', () => {
return reqRest('/SubObject/?related.id==2&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query by doubly nested attribute', () => {
return reqRest('/SubObject/?related.subObject.any==any-2&select(id,any)')
.expect((r) => assert.equal(r.body[0].id, '2', r.text))
.expect(200);
});
it('[rest] Query with nested fragments', () => {
return reqRest('/Related/?id==3')
.expect((r) => assert.equal(r.body[0].id, '3', r.text))
.expect(200);
});
it('[rest] Request POST with too large of body', function (t) {
if (process.platform === 'win32') return t.skip('Windows: Connection gets reset instead of 413');
const bigProperty = Array(1000000).fill('this is a test');
return request(envUrlRest).post('/Related/').set(headers).send({ bigProperty }).expect(413);
});
});