Skip to content

Commit

Permalink
feat: add 'isNotEmpty' assertion operator
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjai0py committed Nov 21, 2024
1 parent aff7c40 commit 4a4481a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +52,7 @@ const AssertionOperator = ({ operator, onChange }) => {
'endsWith',
'between',
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,6 +62,7 @@ const parseAssertionOperator = (str = '') => {
'endsWith',
'between',
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand All @@ -75,6 +77,7 @@ const parseAssertionOperator = (str = '') => {

const unaryOperators = [
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand Down Expand Up @@ -113,6 +116,7 @@ const parseAssertionOperator = (str = '') => {
const isUnaryOperator = (operator) => {
const unaryOperators = [
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand Down
12 changes: 12 additions & 0 deletions packages/bruno-js/src/runtime/assert-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,6 +96,7 @@ const parseAssertionOperator = (str = '') => {
'endsWith',
'between',
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand All @@ -109,6 +111,7 @@ const parseAssertionOperator = (str = '') => {

const unaryOperators = [
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand Down Expand Up @@ -147,6 +150,7 @@ const parseAssertionOperator = (str = '') => {
const isUnaryOperator = (operator) => {
const unaryOperators = [
'isEmpty',
'isNotEmpty',
'isNull',
'isUndefined',
'isDefined',
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4a4481a

Please sign in to comment.