Comparing version 3.5.0 to 3.5.1
{ | ||
"name": "pactum", | ||
"version": "3.5.0", | ||
"version": "3.5.1", | ||
"description": "REST API Testing Tool for all levels in a Test Pyramid", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -8,2 +8,3 @@ const assert = require('assert'); | ||
const utils = require('../helpers/utils'); | ||
const helper = require('../helpers/helper'); | ||
const file = require('../helpers/file.utils'); | ||
@@ -384,12 +385,20 @@ const log = require('../plugins/logger'); | ||
_validateJsonLengthQuery(response) { | ||
const allowedRules = ['LTE', 'GTE', 'LT', 'GT', 'NOT_EQUALS'] | ||
this.jsonLengthQuery = processor.processData(this.jsonLengthQuery); | ||
for (let i = 0; i < this.jsonLengthQuery.length; i++) { | ||
const { path, value: expected } = this.jsonLengthQuery[i]; | ||
const actualValue = jqy(path, { data: response.json }).value; | ||
if (actualValue && Array.isArray(actualValue)) { | ||
const actual = actualValue.length; | ||
assert.strictEqual(actual, expected, `JSON Length ${actual} !== ${expected}`); | ||
} else { | ||
this.fail(`Response does not contain a json array at '${path}'`); | ||
const jQ = clone(this.jsonLengthQuery[i]); | ||
const actualValue = jqy(jQ.path, { data: response.json }).value; | ||
const rules = jmv.getMatchingRules(jQ.value, jQ.path); | ||
const expectedValue = jmv.getRawValue(jQ.value); | ||
if (!actualValue && !Array.isArray(actualValue)) { | ||
this.fail(`Response does not contain a json array at '${jQ.path}'`); | ||
} | ||
if (helper.isValidObject(jQ.value) && !allowedRules.includes(jQ.value.pactum_type)) { | ||
this.fail(`Invalid compare operation ${jQ.value.pactum_type}, allowed operations: ${allowedRules}`); | ||
} | ||
const errors = jmv.validate(actualValue.length, expectedValue, rules, jQ.path); | ||
if (errors) { | ||
const errCondition = jQ.value.pactum_type ? `not ${jQ.value.pactum_type}` : "!=="; | ||
this.fail(`JSON Length ${actualValue.length} ${errCondition} ${expectedValue}`); | ||
} | ||
} | ||
@@ -396,0 +405,0 @@ } |
@@ -337,2 +337,3 @@ import { RequestOptions, IncomingMessage } from 'http'; | ||
expectJsonLength(path: string, value: number): Spec; | ||
expectJsonLength(path: string, matcher: object): Spec; | ||
@@ -339,0 +340,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169160
5060