From afdec85a9d6fc1b408af4c05bafc6ed5f699e40f Mon Sep 17 00:00:00 2001 From: artem-zakharchenko Date: Mon, 8 Jul 2019 11:48:37 +0200 Subject: [PATCH] test: adjusts tests for "error[n].location" property --- lib/units/validateBody.js | 1 + test/chai.js | 2 +- test/integration/validate.test.js | 5 ++++- test/unit/support/amanda-to-gavel-shared.js | 4 ++-- test/unit/units/validateHeaders.test.js | 5 ++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/units/validateBody.js b/lib/units/validateBody.js index 374affbf..c121a45d 100644 --- a/lib/units/validateBody.js +++ b/lib/units/validateBody.js @@ -245,6 +245,7 @@ function validateBody(expected, actual) { actual.body, usesJsonSchema ? expected.bodySchema : expected.body ); + // Without ".validate()" it cannot evaluate output to result. // TODO Re-do this. validator && validator.validate(); diff --git a/test/chai.js b/test/chai.js index 1deb78d9..aa798319 100644 --- a/test/chai.js +++ b/test/chai.js @@ -52,7 +52,7 @@ ${JSON.stringify(target)} }; createErrorPropertyAssertion('message', 'withMessage'); - createErrorPropertyAssertion('pointer', 'withPointer'); + createErrorPropertyAssertion('location', 'withLocation'); createErrorPropertyAssertion('values', 'withValues'); // diff --git a/test/integration/validate.test.js b/test/integration/validate.test.js index 255a6244..f39e1f4f 100644 --- a/test/integration/validate.test.js +++ b/test/integration/validate.test.js @@ -237,7 +237,10 @@ describe('validate', () => { it('has pointer to missing "Content-Type"', () => { expect(result.fields.headers) .to.have.errorAtIndex(0) - .withPointer('/content-type'); + .withLocation({ + pointer: '/content-type', + property: ['content-type'] + }); }); it('has explanatory message', () => { diff --git a/test/unit/support/amanda-to-gavel-shared.js b/test/unit/support/amanda-to-gavel-shared.js index 1a233c18..5f3171f4 100644 --- a/test/unit/support/amanda-to-gavel-shared.js +++ b/test/unit/support/amanda-to-gavel-shared.js @@ -45,7 +45,7 @@ exports.shouldBehaveLikeAmandaToGavel = (instance) => { assert.isObject(item); }); - const props = ['message', 'pointer']; + const props = ['message', 'location']; props.forEach((key) => { it('should have "' + key + '"', () => { assert.include(Object.keys(item), key); @@ -55,7 +55,7 @@ exports.shouldBehaveLikeAmandaToGavel = (instance) => { describe('pointer key value', () => { value = null; before(() => { - value = item['pointer']; + value = item.location.pointer; }); it('should be a string', () => { diff --git a/test/unit/units/validateHeaders.test.js b/test/unit/units/validateHeaders.test.js index 6d45767e..4114e4f1 100644 --- a/test/unit/units/validateHeaders.test.js +++ b/test/unit/units/validateHeaders.test.js @@ -68,7 +68,10 @@ describe('validateHeaders', () => { it('has pointer to header name', () => { expect(result) .to.have.errorAtIndex(index) - .withPointer(`/${headerName}`); + .withLocation({ + pointer: `/${headerName}`, + property: [headerName] + }); }); it('has explanatory message', () => {