Skip to content

Commit

Permalink
test: adjusts tests for "error[n].location" property
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Jul 8, 2019
1 parent dc1cf14 commit afdec85
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/units/validateBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ${JSON.stringify(target)}
};

createErrorPropertyAssertion('message', 'withMessage');
createErrorPropertyAssertion('pointer', 'withPointer');
createErrorPropertyAssertion('location', 'withLocation');
createErrorPropertyAssertion('values', 'withValues');

//
Expand Down
5 changes: 4 additions & 1 deletion test/integration/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/support/amanda-to-gavel-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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', () => {
Expand Down
5 changes: 4 additions & 1 deletion test/unit/units/validateHeaders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit afdec85

Please sign in to comment.