Added IsArray on Assert (#2413)

Co-authored-by: Fabio Grande <fabio.grande@hdhome.it>
This commit is contained in:
Fabio GRANDE 2024-06-19 12:34:57 +02:00 committed by GitHub
parent d88bb68014
commit 9ec67b5da9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 7 deletions

View File

@ -32,6 +32,7 @@ import lightTheme from 'themes/light';
* isNumber : is number * isNumber : is number
* isString : is string * isString : is string
* isBoolean : is boolean * isBoolean : is boolean
* isArray : is array
*/ */
const AssertionOperator = ({ operator, onChange }) => { const AssertionOperator = ({ operator, onChange }) => {
@ -61,7 +62,8 @@ const AssertionOperator = ({ operator, onChange }) => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
const handleChange = (e) => { const handleChange = (e) => {

View File

@ -33,6 +33,7 @@ import { useTheme } from 'providers/Theme';
* isNumber : is number * isNumber : is number
* isString : is string * isString : is string
* isBoolean : is boolean * isBoolean : is boolean
* isArray : is array
*/ */
const parseAssertionOperator = (str = '') => { const parseAssertionOperator = (str = '') => {
if (!str || typeof str !== 'string' || !str.length) { if (!str || typeof str !== 'string' || !str.length) {
@ -68,7 +69,8 @@ const parseAssertionOperator = (str = '') => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
const unaryOperators = [ const unaryOperators = [
@ -81,7 +83,8 @@ const parseAssertionOperator = (str = '') => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
const [operator, ...rest] = str.trim().split(' '); const [operator, ...rest] = str.trim().split(' ');
@ -118,7 +121,8 @@ const isUnaryOperator = (operator) => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
return unaryOperators.includes(operator); return unaryOperators.includes(operator);

View File

@ -66,6 +66,7 @@ chai.use(function (chai, utils) {
* isNumber : is number * isNumber : is number
* isString : is string * isString : is string
* isBoolean : is boolean * isBoolean : is boolean
* isArray : is array
*/ */
const parseAssertionOperator = (str = '') => { const parseAssertionOperator = (str = '') => {
if (!str || typeof str !== 'string' || !str.length) { if (!str || typeof str !== 'string' || !str.length) {
@ -101,7 +102,8 @@ const parseAssertionOperator = (str = '') => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
const unaryOperators = [ const unaryOperators = [
@ -114,7 +116,8 @@ const parseAssertionOperator = (str = '') => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
const [operator, ...rest] = str.trim().split(' '); const [operator, ...rest] = str.trim().split(' ');
@ -151,7 +154,8 @@ const isUnaryOperator = (operator) => {
'isJson', 'isJson',
'isNumber', 'isNumber',
'isString', 'isString',
'isBoolean' 'isBoolean',
'isArray'
]; ];
return unaryOperators.includes(operator); return unaryOperators.includes(operator);
@ -313,6 +317,9 @@ class AssertRuntime {
case 'isBoolean': case 'isBoolean':
expect(lhs).to.be.a('boolean'); expect(lhs).to.be.a('boolean');
break; break;
case 'isArray':
expect(lhs).to.be.a('array');
break;
default: default:
expect(lhs).to.equal(rhs); expect(lhs).to.equal(rhs);
break; break;