Skip to content

Commit

Permalink
Merge 3d3a2a3 into 28f4ac3
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed May 30, 2019
2 parents 28f4ac3 + 3d3a2a3 commit e90a6aa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 114 deletions.
6 changes: 3 additions & 3 deletions lib/gavel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { HttpRequest, ExpectedHttpRequest } = require('./model/http-request');
const { HttpResponse, ExpectedHttpResponse } = require('./model/http-response');
const { isValid, isValidatable } = require('./validate');
const { isValid } = require('./validate');

const validate = require('./next/validate');

module.exports = {
Expand All @@ -12,6 +13,5 @@ module.exports = {
HttpResponse,
ExpectedHttpRequest,
ExpectedHttpResponse,
isValid,
isValidatable
isValid
};
7 changes: 1 addition & 6 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ const { isValid } = result;\
return proxy(getValidatableObject(real, expected, type), 'isValid', cb);
}

function isValidatable(real, expected, type, cb) {
return proxy(getValidatableObject(real, expected, type), 'isValidatable', cb);
}

module.exports = {
isValid,
isValidatable
isValid
};
29 changes: 0 additions & 29 deletions test/unit/mixins/validatable-http-message-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const fixtures = require('../../fixtures');
describe('Http validatable mixin', () => {
describe('when mixed in any HTTP Message class', () => {
const methods = [
'isValidatable',
'validate',
'isValid',
'validationResults',
Expand Down Expand Up @@ -44,34 +43,6 @@ describe('Http validatable mixin', () => {
});
});

describe('#isValidatable()', () => {
describe('when no validatable HTTP component in the object', () => {
it('should return false', () => {
const instance = new HttpResponse({ foo: 'bar' });
assert.isFalse(instance.isValidatable());
});
});

describe('when any validatable HTTP component is present in the object', () => {
it('should return true for some headers', () => {
const instance = new HttpResponse({
headers: { 'content-type:': 'application/json' }
});
assert.isTrue(instance.isValidatable());
});

it('should return true for some body', () => {
const instance = new HttpResponse({ body: '' });
assert.isTrue(instance.isValidatable());
});

it('should return true for some statusCode', () => {
const instance = new HttpResponse({ statusCode: 200 });
assert.isTrue(instance.isValidatable());
});
});
});

describe('any HTTP Message instance', () => {
let instance = {};
let response = {
Expand Down
77 changes: 1 addition & 76 deletions test/unit/validate-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { assert } = require('chai');
const clone = require('clone');
const { validate, isValid, isValidatable } = require('../../lib/gavel');
const { validate, isValid } = require('../../lib/gavel');

describe('Gavel proxies to functions with callbacks', () => {
// Examples from README.md
Expand Down Expand Up @@ -42,81 +42,6 @@ describe('Gavel proxies to functions with callbacks', () => {
body: '{"origin":"1.2.3.4"}'
};

describe('isValidatable', () => {
describe('when I provide data from README (good objects)', () => {
['response', 'request'].forEach((variant) => {
describe(`for two cloned ${variant}s`, () => {
let results = null;
let error = null;

before((done) => {
isValidatable(
cloneHttpMessage,
baseHttpMessage,
variant,
(err, result) => {
error = err;
results = result;
done();
}
);
});

it('should call the callback without any errors', () =>
assert.isNull(error));
it('should be ok as a result of isValidatable', () =>
assert.isTrue(results));
});

describe('for similar #{variant}s', () => {
let results = null;
let error = null;

before((done) => {
isValidatable(
similarHttpMessage,
baseHttpMessage,
variant,
(err, result) => {
error = err;
results = result;
done();
}
);
});

it('should call the callback without any errors', () =>
assert.isNull(error));
it('should be ok as a result of isValidatable', () =>
assert.isTrue(results));
});

describe('for different #{variant}s', () => {
let results = null;
let error = null;

before((done) => {
isValidatable(
differentHttpMessage,
baseHttpMessage,
variant,
(err, result) => {
error = err;
results = result;
done();
}
);
});

it('should call the callback without any errors', () =>
assert.isNull(error));
it('should be ok as a result of isValidatable', () =>
assert.isTrue(results));
});
});
});
});

describe('isValid', () => {
describe('when I provide data', () => {
['response', 'request'].forEach((variant) => {
Expand Down

0 comments on commit e90a6aa

Please sign in to comment.