Skip to content

Commit a28311f

Browse files
fgrandeFabio Grande
authored andcommitted
Added IsArray on Assert (usebruno#2413)
Co-authored-by: Fabio Grande <[email protected]>
1 parent 0efeff8 commit a28311f

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

packages/bruno-app/src/components/RequestPane/Assertions/AssertionOperator/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import lightTheme from 'themes/light';
3232
* isNumber : is number
3333
* isString : is string
3434
* isBoolean : is boolean
35+
* isArray : is array
3536
*/
3637

3738
const AssertionOperator = ({ operator, onChange }) => {
@@ -61,7 +62,8 @@ const AssertionOperator = ({ operator, onChange }) => {
6162
'isJson',
6263
'isNumber',
6364
'isString',
64-
'isBoolean'
65+
'isBoolean',
66+
'isArray'
6567
];
6668

6769
const handleChange = (e) => {

packages/bruno-app/src/components/RequestPane/Assertions/AssertionRow/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { useTheme } from 'providers/Theme';
3333
* isNumber : is number
3434
* isString : is string
3535
* isBoolean : is boolean
36+
* isArray : is array
3637
*/
3738
const parseAssertionOperator = (str = '') => {
3839
if (!str || typeof str !== 'string' || !str.length) {
@@ -68,7 +69,8 @@ const parseAssertionOperator = (str = '') => {
6869
'isJson',
6970
'isNumber',
7071
'isString',
71-
'isBoolean'
72+
'isBoolean',
73+
'isArray'
7274
];
7375

7476
const unaryOperators = [
@@ -81,7 +83,8 @@ const parseAssertionOperator = (str = '') => {
8183
'isJson',
8284
'isNumber',
8385
'isString',
84-
'isBoolean'
86+
'isBoolean',
87+
'isArray'
8588
];
8689

8790
const [operator, ...rest] = str.trim().split(' ');
@@ -118,7 +121,8 @@ const isUnaryOperator = (operator) => {
118121
'isJson',
119122
'isNumber',
120123
'isString',
121-
'isBoolean'
124+
'isBoolean',
125+
'isArray'
122126
];
123127

124128
return unaryOperators.includes(operator);

packages/bruno-js/src/runtime/assert-runtime.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ chai.use(function (chai, utils) {
6666
* isNumber : is number
6767
* isString : is string
6868
* isBoolean : is boolean
69+
* isArray : is array
6970
*/
7071
const parseAssertionOperator = (str = '') => {
7172
if (!str || typeof str !== 'string' || !str.length) {
@@ -101,7 +102,8 @@ const parseAssertionOperator = (str = '') => {
101102
'isJson',
102103
'isNumber',
103104
'isString',
104-
'isBoolean'
105+
'isBoolean',
106+
'isArray'
105107
];
106108

107109
const unaryOperators = [
@@ -114,7 +116,8 @@ const parseAssertionOperator = (str = '') => {
114116
'isJson',
115117
'isNumber',
116118
'isString',
117-
'isBoolean'
119+
'isBoolean',
120+
'isArray'
118121
];
119122

120123
const [operator, ...rest] = str.trim().split(' ');
@@ -151,7 +154,8 @@ const isUnaryOperator = (operator) => {
151154
'isJson',
152155
'isNumber',
153156
'isString',
154-
'isBoolean'
157+
'isBoolean',
158+
'isArray'
155159
];
156160

157161
return unaryOperators.includes(operator);
@@ -313,6 +317,9 @@ class AssertRuntime {
313317
case 'isBoolean':
314318
expect(lhs).to.be.a('boolean');
315319
break;
320+
case 'isArray':
321+
expect(lhs).to.be.a('array');
322+
break;
316323
default:
317324
expect(lhs).to.equal(rhs);
318325
break;

0 commit comments

Comments
 (0)