Skip to content

Commit

Permalink
Merge b9e7e9d into 2e0dbd4
Browse files Browse the repository at this point in the history
  • Loading branch information
kobik committed Apr 16, 2020
2 parents 2e0dbd4 + b9e7e9d commit f76f9cc
Show file tree
Hide file tree
Showing 9 changed files with 8,957 additions and 4,781 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: node_js
node_js:
- "8"
- "10"
- "12"
- "node"

before_script: "npm run lint"
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/jest/schema-matcher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const diff = require('jest-diff');
const diff = require('jest-diff').default;
const matcherUtils = require('jest-matcher-utils');
const validators = require('../../validators');

Expand Down
13,635 changes: 8,906 additions & 4,729 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@
},
"homepage": "https://github.com/PayU/api-contract-validator#readme",
"dependencies": {
"api-schema-builder": "^1.2.0",
"api-schema-builder": "^1.2.2",
"chalk": "^2.4.2",
"columnify": "^1.5.4",
"jest-diff": "^24.9.0",
"jest-matcher-utils": "^24.9.0",
"jest-diff": "^25.3.0",
"jest-matcher-utils": "^25.3.0",
"lodash": "^4.17.15"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.1.0",
"@typescript-eslint/parser": "^2.1.0",
"axios": "^0.19.0",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"axios": "^0.19.2",
"chai": "^4.2.0",
"chai-like": "^1.1.1",
"coveralls": "^3.0.6",
"dtslint": "^0.9.6",
"eslint": "^6.3.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"coveralls": "^3.0.11",
"dtslint": "^3.4.1",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"jest": "^24.9.0",
"mocha": "^6.2.0",
"nock": "^10.0.6",
"nyc": "^14.1.1",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"eslint-plugin-react": "^7.19.0",
"jest": "^25.3.0",
"mocha": "^7.1.1",
"nock": "^12.0.3",
"nyc": "^15.0.1",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"should": "^13.2.3",
"sinon": "^7.4.2",
"sinon": "^9.0.2",
"supertest": "^4.0.2",
"typescript": "^3.5.3"
"typescript": "^3.8.3"
},
"nyc": {
"check-coverage": true,
Expand Down
12 changes: 6 additions & 6 deletions test/chai-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('Chai.js plugin schema', () => {
it('Response object matches the schema', async () => {
const response = await request({
status: 200,
body: responses.body.valid.value,
headers: responses.headers.valid.value,
body: { ...responses.body.valid.value },
headers: { ...responses.headers.valid.value },
});

expect(response).to.matchApiSchema();
Expand All @@ -25,16 +25,16 @@ describe('Chai.js plugin schema', () => {
method: 'get',
status: 200,
path: '/v2/pet/123',
body: responses.body.valid.value,
headers: responses.headers.valid.value,
body: { ...responses.body.valid.value },
headers: { ...responses.headers.valid.value },
}).to.matchApiSchema();
});

it('Response body does not match the schema', async () => {
const response = await request({
status: 200,
body: responses.body.invalid.value,
headers: responses.headers.valid.value,
body: { ...responses.body.invalid.value },
headers: { ...responses.headers.valid.value },
});

expect(response).to.not.matchApiSchema();
Expand Down
34 changes: 17 additions & 17 deletions test/data/responses.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const validBody = {
const validBody = Object.freeze({
value: {
description: 'Usually found in South-America',
name: 'Llama',
age: 4,
},
};
});

const validHeaders = {
const validHeaders = Object.freeze({
value: {
'x-expires-after': '2019-03-13T10:07:38.376Z',
'x-rate-limit': 5,
'x-elapsed-time': 130,
'x-rate-limit': '5',
'x-elapsed-time': '130',
'x-request-id': '12345',
},
};
});

const invalidBody = {
const invalidBody = Object.freeze({
value: {
description: 'Oops',
age: -1,
Expand Down Expand Up @@ -56,23 +56,23 @@ const invalidBody = {
name: 'should have required property',
},
},
};
});

const invalidHeaders = {
const invalidHeaders = Object.freeze({
value: {
'x-expires-after': [],
'x-expires-after': 'abc',
'x-rate-limit': -5,
'x-request-id': '123',
},
actual: {
headers: {
'x-expires-after': [],
'x-expires-after': 'abc',
'x-rate-limit': -5,
},
},
expected: {
headers: {
'x-expires-after': 'should be string',
'x-expires-after': 'should match format "date-time"',
'x-rate-limit': 'should be >= 0',
},
},
Expand All @@ -90,15 +90,15 @@ const invalidHeaders = {
},
{
dataPath: ".headers['x-expires-after']",
keyword: 'type',
message: 'should be string',
keyword: 'format',
message: 'should match format "date-time"',
params: {
type: 'string',
format: 'date-time',
},
schemaPath: '#/headers/properties/x-expires-after/type',
schemaPath: '#/headers/properties/x-expires-after/format',
},
],
};
});

module.exports = Object.freeze({
body: {
Expand Down
8 changes: 4 additions & 4 deletions test/response-adapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('responseAdapter', () => {
});
});

const expectedResponse = {
const expectedResponse = Object.freeze({
request: {
method: 'get',
path: '/v2/pet/123',
Expand All @@ -162,9 +162,9 @@ const expectedResponse = {
body: responses.body.valid.value,
headers: responses.headers.valid.value,
},
};
});

const expected400Response = {
const expected400Response = Object.freeze({
request: {
method: 'get',
path: '/v2/pet/123',
Expand All @@ -173,4 +173,4 @@ const expected400Response = {
status: 400,
body: responses.body.valid.value,
},
};
});
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// TypeScript Version: 3.2
declare global {
// eslint-disable-next-line no-redeclare
namespace jest {
interface Matchers<R> {
toMatchApiSchema: () => void;
Expand Down
3 changes: 0 additions & 3 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"importHelpers": true,
"baseUrl": "..",
"paths": {
Expand Down

0 comments on commit f76f9cc

Please sign in to comment.