diff --git a/packages/bruno-app/src/components/RequestPane/Assertions/AssertionOperator/index.js b/packages/bruno-app/src/components/RequestPane/Assertions/AssertionOperator/index.js index 1bc1c3f88..523fcf73d 100644 --- a/packages/bruno-app/src/components/RequestPane/Assertions/AssertionOperator/index.js +++ b/packages/bruno-app/src/components/RequestPane/Assertions/AssertionOperator/index.js @@ -20,6 +20,7 @@ import React from 'react'; * endsWith : ends with * between : between * isEmpty : is empty + * isNotEmpty : is not empty * isNull : is null * isUndefined : is undefined * isDefined : is defined @@ -51,6 +52,7 @@ const AssertionOperator = ({ operator, onChange }) => { 'endsWith', 'between', 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', diff --git a/packages/bruno-app/src/components/RequestPane/Assertions/AssertionRow/index.js b/packages/bruno-app/src/components/RequestPane/Assertions/AssertionRow/index.js index 38250f8ea..953db9e8d 100644 --- a/packages/bruno-app/src/components/RequestPane/Assertions/AssertionRow/index.js +++ b/packages/bruno-app/src/components/RequestPane/Assertions/AssertionRow/index.js @@ -24,6 +24,7 @@ import { useTheme } from 'providers/Theme'; * endsWith : ends with * between : between * isEmpty : is empty + * isNotEmpty : is not empty * isNull : is null * isUndefined : is undefined * isDefined : is defined @@ -61,6 +62,7 @@ const parseAssertionOperator = (str = '') => { 'endsWith', 'between', 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', @@ -75,6 +77,7 @@ const parseAssertionOperator = (str = '') => { const unaryOperators = [ 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', @@ -113,6 +116,7 @@ const parseAssertionOperator = (str = '') => { const isUnaryOperator = (operator) => { const unaryOperators = [ 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', diff --git a/packages/bruno-js/src/runtime/assert-runtime.js b/packages/bruno-js/src/runtime/assert-runtime.js index b338730cc..d62bd22bf 100644 --- a/packages/bruno-js/src/runtime/assert-runtime.js +++ b/packages/bruno-js/src/runtime/assert-runtime.js @@ -58,6 +58,7 @@ chai.use(function (chai, utils) { * endsWith : ends with * between : between * isEmpty : is empty + * isNotEmpty : is not empty * isNull : is null * isUndefined : is undefined * isDefined : is defined @@ -95,6 +96,7 @@ const parseAssertionOperator = (str = '') => { 'endsWith', 'between', 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', @@ -109,6 +111,7 @@ const parseAssertionOperator = (str = '') => { const unaryOperators = [ 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', @@ -147,6 +150,7 @@ const parseAssertionOperator = (str = '') => { const isUnaryOperator = (operator) => { const unaryOperators = [ 'isEmpty', + 'isNotEmpty', 'isNull', 'isUndefined', 'isDefined', @@ -345,6 +349,14 @@ class AssertRuntime { case 'isEmpty': expect(lhs).to.be.empty; break; + case 'isNotEmpty': + expect(lhs).to.not.be.oneOf([null, 0, false, '', []]); + if (Array.isArray(lhs)) { + expect(lhs).to.have.length.above(0); + } else if (typeof lhs === 'object' && lhs !== null) { + expect(Object.keys(lhs)).to.have.length.above(0); + } + break; case 'isNull': expect(lhs).to.be.null; break;