@opra/testing 0.26.5 → 0.27.2
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/cjs/api-expect/api-expect-collection.js +10 -10
- package/cjs/api-expect/api-expect-object.js +3 -3
- package/cjs/api-expect/api-expect.js +5 -5
- package/esm/api-expect/api-expect-collection.js +10 -10
- package/esm/api-expect/api-expect-object.js +3 -3
- package/esm/api-expect/api-expect.js +5 -5
- package/package.json +3 -3
|
@@ -24,7 +24,7 @@ class ApiExpectCollection {
|
|
|
24
24
|
toMatch(expected) {
|
|
25
25
|
try {
|
|
26
26
|
const v = (0, lodash_omitby_1.default)(expected, lodash_isnil_1.default);
|
|
27
|
-
for (const item of this.response.body.
|
|
27
|
+
for (const item of this.response.body.payload) {
|
|
28
28
|
this._expect(item).toMatchObject(v);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -36,7 +36,7 @@ class ApiExpectCollection {
|
|
|
36
36
|
}
|
|
37
37
|
toHaveFields(keys) {
|
|
38
38
|
try {
|
|
39
|
-
for (const item of this.response.body.
|
|
39
|
+
for (const item of this.response.body.payload) {
|
|
40
40
|
this._expect(item).toHaveFields(keys);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -48,7 +48,7 @@ class ApiExpectCollection {
|
|
|
48
48
|
}
|
|
49
49
|
toHaveFieldsOnly(keys) {
|
|
50
50
|
try {
|
|
51
|
-
for (const item of this.response.body.
|
|
51
|
+
for (const item of this.response.body.payload) {
|
|
52
52
|
this._expect(item).toHaveFieldsOnly(keys);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -61,7 +61,7 @@ class ApiExpectCollection {
|
|
|
61
61
|
//
|
|
62
62
|
// toHaveProperty(keyPath, value?): this {
|
|
63
63
|
// try {
|
|
64
|
-
// for (const item of this.response.
|
|
64
|
+
// for (const item of this.response.payload) {
|
|
65
65
|
// this._expect(item).toHaveProperty(keyPath, value);
|
|
66
66
|
// }
|
|
67
67
|
//
|
|
@@ -73,7 +73,7 @@ class ApiExpectCollection {
|
|
|
73
73
|
// }
|
|
74
74
|
toBeSortedBy(...fields) {
|
|
75
75
|
try {
|
|
76
|
-
this._expect(this.response.body.
|
|
76
|
+
this._expect(this.response.body.payload).toBeSortedBy(fields);
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
79
|
Error.captureStackTrace(e, this.toBeSortedBy);
|
|
@@ -85,9 +85,9 @@ class ApiExpectCollection {
|
|
|
85
85
|
const f = convertFilter(filter);
|
|
86
86
|
if (f) {
|
|
87
87
|
const j = ruleJudgment(f);
|
|
88
|
-
const filtered = this.response.body.
|
|
88
|
+
const filtered = this.response.body.payload.filter(j);
|
|
89
89
|
try {
|
|
90
|
-
this._expect(this.response.body.
|
|
90
|
+
this._expect(this.response.body.payload).toStrictEqual(filtered);
|
|
91
91
|
}
|
|
92
92
|
catch (e) {
|
|
93
93
|
Error.captureStackTrace(e, this.toBeFilteredBy);
|
|
@@ -98,7 +98,7 @@ class ApiExpectCollection {
|
|
|
98
98
|
}
|
|
99
99
|
toHaveExactItems(expected) {
|
|
100
100
|
try {
|
|
101
|
-
this._expect(this.response.body.
|
|
101
|
+
this._expect(this.response.body.dapayloadta).toHaveLength(expected);
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
104
|
Error.captureStackTrace(e, this.toHaveExactItems);
|
|
@@ -108,7 +108,7 @@ class ApiExpectCollection {
|
|
|
108
108
|
}
|
|
109
109
|
toHaveMaxItems(expected) {
|
|
110
110
|
try {
|
|
111
|
-
this._expect(this.response.body.
|
|
111
|
+
this._expect(this.response.body.payload.length).toBeLessThanOrEqual(expected);
|
|
112
112
|
}
|
|
113
113
|
catch (e) {
|
|
114
114
|
Error.captureStackTrace(e, this.toHaveMaxItems);
|
|
@@ -118,7 +118,7 @@ class ApiExpectCollection {
|
|
|
118
118
|
}
|
|
119
119
|
toHaveMinItems(expected) {
|
|
120
120
|
try {
|
|
121
|
-
this._expect(this.response.body.
|
|
121
|
+
this._expect(this.response.body.payload.length).toBeGreaterThanOrEqual(expected);
|
|
122
122
|
}
|
|
123
123
|
catch (e) {
|
|
124
124
|
Error.captureStackTrace(e, this.toHaveMinItems);
|
|
@@ -16,7 +16,7 @@ class ApiExpectObject {
|
|
|
16
16
|
toMatch(expected) {
|
|
17
17
|
try {
|
|
18
18
|
const v = (0, lodash_omitby_1.default)(expected, lodash_isnil_1.default);
|
|
19
|
-
this._expect(this.response.body.
|
|
19
|
+
this._expect(this.response.body.payload).toMatchObject(v);
|
|
20
20
|
}
|
|
21
21
|
catch (e) {
|
|
22
22
|
Error.captureStackTrace(e, this.toMatch);
|
|
@@ -26,7 +26,7 @@ class ApiExpectObject {
|
|
|
26
26
|
}
|
|
27
27
|
toHaveFields(fields) {
|
|
28
28
|
try {
|
|
29
|
-
this._expect(this.response.body.
|
|
29
|
+
this._expect(this.response.body.payload).toHaveFields(fields);
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
|
32
32
|
Error.captureStackTrace(e, this.toHaveFields);
|
|
@@ -36,7 +36,7 @@ class ApiExpectObject {
|
|
|
36
36
|
}
|
|
37
37
|
toHaveFieldsOnly(fields) {
|
|
38
38
|
try {
|
|
39
|
-
this._expect(this.response.body.
|
|
39
|
+
this._expect(this.response.body.payload).toHaveFieldsOnly(fields);
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
42
42
|
Error.captureStackTrace(e, this.toHaveFieldsOnly);
|
|
@@ -59,7 +59,7 @@ class ApiExpect {
|
|
|
59
59
|
msg = '"body" is empty';
|
|
60
60
|
expect(this.response.body).toBeDefined();
|
|
61
61
|
msg = '"operation" property is empty';
|
|
62
|
-
expect(this.response.body.
|
|
62
|
+
expect(this.response.body.context).toBeDefined();
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
65
|
if (msg)
|
|
@@ -75,8 +75,8 @@ class ApiExpect {
|
|
|
75
75
|
msg = '"body" is empty';
|
|
76
76
|
expect(this.response.body).toBeDefined();
|
|
77
77
|
expect(typeof this.response.body).toStrictEqual('object');
|
|
78
|
-
msg = `"body.
|
|
79
|
-
expect(typeof this.response.body.
|
|
78
|
+
msg = `"body.payload" is ${typeof typeof this.response.body.payload}`;
|
|
79
|
+
expect(typeof this.response.body.payload).toStrictEqual('object');
|
|
80
80
|
}
|
|
81
81
|
catch (e) {
|
|
82
82
|
if (msg)
|
|
@@ -91,9 +91,9 @@ class ApiExpect {
|
|
|
91
91
|
try {
|
|
92
92
|
msg = '"body" is empty';
|
|
93
93
|
expect(this.response.body).toBeDefined();
|
|
94
|
-
expect(this.response.body.
|
|
94
|
+
expect(this.response.body.payload).toBeDefined();
|
|
95
95
|
msg = '"body" is not an array';
|
|
96
|
-
expect(this.response.body.
|
|
96
|
+
expect(this.response.body.payload).toBeArray();
|
|
97
97
|
}
|
|
98
98
|
catch (e) {
|
|
99
99
|
if (msg)
|
|
@@ -20,7 +20,7 @@ export class ApiExpectCollection {
|
|
|
20
20
|
toMatch(expected) {
|
|
21
21
|
try {
|
|
22
22
|
const v = omitBy(expected, isNil);
|
|
23
|
-
for (const item of this.response.body.
|
|
23
|
+
for (const item of this.response.body.payload) {
|
|
24
24
|
this._expect(item).toMatchObject(v);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -32,7 +32,7 @@ export class ApiExpectCollection {
|
|
|
32
32
|
}
|
|
33
33
|
toHaveFields(keys) {
|
|
34
34
|
try {
|
|
35
|
-
for (const item of this.response.body.
|
|
35
|
+
for (const item of this.response.body.payload) {
|
|
36
36
|
this._expect(item).toHaveFields(keys);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -44,7 +44,7 @@ export class ApiExpectCollection {
|
|
|
44
44
|
}
|
|
45
45
|
toHaveFieldsOnly(keys) {
|
|
46
46
|
try {
|
|
47
|
-
for (const item of this.response.body.
|
|
47
|
+
for (const item of this.response.body.payload) {
|
|
48
48
|
this._expect(item).toHaveFieldsOnly(keys);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -57,7 +57,7 @@ export class ApiExpectCollection {
|
|
|
57
57
|
//
|
|
58
58
|
// toHaveProperty(keyPath, value?): this {
|
|
59
59
|
// try {
|
|
60
|
-
// for (const item of this.response.
|
|
60
|
+
// for (const item of this.response.payload) {
|
|
61
61
|
// this._expect(item).toHaveProperty(keyPath, value);
|
|
62
62
|
// }
|
|
63
63
|
//
|
|
@@ -69,7 +69,7 @@ export class ApiExpectCollection {
|
|
|
69
69
|
// }
|
|
70
70
|
toBeSortedBy(...fields) {
|
|
71
71
|
try {
|
|
72
|
-
this._expect(this.response.body.
|
|
72
|
+
this._expect(this.response.body.payload).toBeSortedBy(fields);
|
|
73
73
|
}
|
|
74
74
|
catch (e) {
|
|
75
75
|
Error.captureStackTrace(e, this.toBeSortedBy);
|
|
@@ -81,9 +81,9 @@ export class ApiExpectCollection {
|
|
|
81
81
|
const f = convertFilter(filter);
|
|
82
82
|
if (f) {
|
|
83
83
|
const j = ruleJudgment(f);
|
|
84
|
-
const filtered = this.response.body.
|
|
84
|
+
const filtered = this.response.body.payload.filter(j);
|
|
85
85
|
try {
|
|
86
|
-
this._expect(this.response.body.
|
|
86
|
+
this._expect(this.response.body.payload).toStrictEqual(filtered);
|
|
87
87
|
}
|
|
88
88
|
catch (e) {
|
|
89
89
|
Error.captureStackTrace(e, this.toBeFilteredBy);
|
|
@@ -94,7 +94,7 @@ export class ApiExpectCollection {
|
|
|
94
94
|
}
|
|
95
95
|
toHaveExactItems(expected) {
|
|
96
96
|
try {
|
|
97
|
-
this._expect(this.response.body.
|
|
97
|
+
this._expect(this.response.body.dapayloadta).toHaveLength(expected);
|
|
98
98
|
}
|
|
99
99
|
catch (e) {
|
|
100
100
|
Error.captureStackTrace(e, this.toHaveExactItems);
|
|
@@ -104,7 +104,7 @@ export class ApiExpectCollection {
|
|
|
104
104
|
}
|
|
105
105
|
toHaveMaxItems(expected) {
|
|
106
106
|
try {
|
|
107
|
-
this._expect(this.response.body.
|
|
107
|
+
this._expect(this.response.body.payload.length).toBeLessThanOrEqual(expected);
|
|
108
108
|
}
|
|
109
109
|
catch (e) {
|
|
110
110
|
Error.captureStackTrace(e, this.toHaveMaxItems);
|
|
@@ -114,7 +114,7 @@ export class ApiExpectCollection {
|
|
|
114
114
|
}
|
|
115
115
|
toHaveMinItems(expected) {
|
|
116
116
|
try {
|
|
117
|
-
this._expect(this.response.body.
|
|
117
|
+
this._expect(this.response.body.payload.length).toBeGreaterThanOrEqual(expected);
|
|
118
118
|
}
|
|
119
119
|
catch (e) {
|
|
120
120
|
Error.captureStackTrace(e, this.toHaveMinItems);
|
|
@@ -12,7 +12,7 @@ export class ApiExpectObject {
|
|
|
12
12
|
toMatch(expected) {
|
|
13
13
|
try {
|
|
14
14
|
const v = omitBy(expected, isNil);
|
|
15
|
-
this._expect(this.response.body.
|
|
15
|
+
this._expect(this.response.body.payload).toMatchObject(v);
|
|
16
16
|
}
|
|
17
17
|
catch (e) {
|
|
18
18
|
Error.captureStackTrace(e, this.toMatch);
|
|
@@ -22,7 +22,7 @@ export class ApiExpectObject {
|
|
|
22
22
|
}
|
|
23
23
|
toHaveFields(fields) {
|
|
24
24
|
try {
|
|
25
|
-
this._expect(this.response.body.
|
|
25
|
+
this._expect(this.response.body.payload).toHaveFields(fields);
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
28
|
Error.captureStackTrace(e, this.toHaveFields);
|
|
@@ -32,7 +32,7 @@ export class ApiExpectObject {
|
|
|
32
32
|
}
|
|
33
33
|
toHaveFieldsOnly(fields) {
|
|
34
34
|
try {
|
|
35
|
-
this._expect(this.response.body.
|
|
35
|
+
this._expect(this.response.body.payload).toHaveFieldsOnly(fields);
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
38
|
Error.captureStackTrace(e, this.toHaveFieldsOnly);
|
|
@@ -56,7 +56,7 @@ export class ApiExpect {
|
|
|
56
56
|
msg = '"body" is empty';
|
|
57
57
|
expect(this.response.body).toBeDefined();
|
|
58
58
|
msg = '"operation" property is empty';
|
|
59
|
-
expect(this.response.body.
|
|
59
|
+
expect(this.response.body.context).toBeDefined();
|
|
60
60
|
}
|
|
61
61
|
catch (e) {
|
|
62
62
|
if (msg)
|
|
@@ -72,8 +72,8 @@ export class ApiExpect {
|
|
|
72
72
|
msg = '"body" is empty';
|
|
73
73
|
expect(this.response.body).toBeDefined();
|
|
74
74
|
expect(typeof this.response.body).toStrictEqual('object');
|
|
75
|
-
msg = `"body.
|
|
76
|
-
expect(typeof this.response.body.
|
|
75
|
+
msg = `"body.payload" is ${typeof typeof this.response.body.payload}`;
|
|
76
|
+
expect(typeof this.response.body.payload).toStrictEqual('object');
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
79
|
if (msg)
|
|
@@ -88,9 +88,9 @@ export class ApiExpect {
|
|
|
88
88
|
try {
|
|
89
89
|
msg = '"body" is empty';
|
|
90
90
|
expect(this.response.body).toBeDefined();
|
|
91
|
-
expect(this.response.body.
|
|
91
|
+
expect(this.response.body.payload).toBeDefined();
|
|
92
92
|
msg = '"body" is not an array';
|
|
93
|
-
expect(this.response.body.
|
|
93
|
+
expect(this.response.body.payload).toBeArray();
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
96
|
if (msg)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.2",
|
|
4
4
|
"description": "Opra testing package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"clean:cover": "rimraf ../../coverage/testing"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opra/client": "^0.
|
|
29
|
-
"@opra/common": "^0.
|
|
28
|
+
"@opra/client": "^0.27.2",
|
|
29
|
+
"@opra/common": "^0.27.2",
|
|
30
30
|
"ansi-colors": "^4.1.3",
|
|
31
31
|
"lodash.isnil": "^4.0.0",
|
|
32
32
|
"lodash.omitby": "^4.6.0",
|