Skip to content

Commit

Permalink
Added IsArray on Assert (#2413)
Browse files Browse the repository at this point in the history
Co-authored-by: Fabio Grande <[email protected]>
  • Loading branch information
fgrande and Fabio Grande authored Jun 19, 2024
1 parent d88bb68 commit 9ec67b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import lightTheme from 'themes/light';
* isNumber : is number
* isString : is string
* isBoolean : is boolean
* isArray : is array
*/

const AssertionOperator = ({ operator, onChange }) => {
Expand Down Expand Up @@ -61,7 +62,8 @@ const AssertionOperator = ({ operator, onChange }) => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

const handleChange = (e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useTheme } from 'providers/Theme';
* isNumber : is number
* isString : is string
* isBoolean : is boolean
* isArray : is array
*/
const parseAssertionOperator = (str = '') => {
if (!str || typeof str !== 'string' || !str.length) {
Expand Down Expand Up @@ -68,7 +69,8 @@ const parseAssertionOperator = (str = '') => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

const unaryOperators = [
Expand All @@ -81,7 +83,8 @@ const parseAssertionOperator = (str = '') => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

const [operator, ...rest] = str.trim().split(' ');
Expand Down Expand Up @@ -118,7 +121,8 @@ const isUnaryOperator = (operator) => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

return unaryOperators.includes(operator);
Expand Down
13 changes: 10 additions & 3 deletions packages/bruno-js/src/runtime/assert-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ chai.use(function (chai, utils) {
* isNumber : is number
* isString : is string
* isBoolean : is boolean
* isArray : is array
*/
const parseAssertionOperator = (str = '') => {
if (!str || typeof str !== 'string' || !str.length) {
Expand Down Expand Up @@ -101,7 +102,8 @@ const parseAssertionOperator = (str = '') => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

const unaryOperators = [
Expand All @@ -114,7 +116,8 @@ const parseAssertionOperator = (str = '') => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

const [operator, ...rest] = str.trim().split(' ');
Expand Down Expand Up @@ -151,7 +154,8 @@ const isUnaryOperator = (operator) => {
'isJson',
'isNumber',
'isString',
'isBoolean'
'isBoolean',
'isArray'
];

return unaryOperators.includes(operator);
Expand Down Expand Up @@ -313,6 +317,9 @@ class AssertRuntime {
case 'isBoolean':
expect(lhs).to.be.a('boolean');
break;
case 'isArray':
expect(lhs).to.be.a('array');
break;
default:
expect(lhs).to.equal(rhs);
break;
Expand Down

0 comments on commit 9ec67b5

Please sign in to comment.