Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #259 from mocks-server/release
Browse files Browse the repository at this point in the history
Release v2.5.2
  • Loading branch information
javierbrea committed Mar 3, 2022
2 parents d253600 + 67cf95b commit 50d2be9
Show file tree
Hide file tree
Showing 7 changed files with 2,053 additions and 1,989 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-package-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2
- name: Get NPM version is new
id: check
uses: EndBug/version-check@v2.0.1
uses: EndBug/version-check@v2.1.0
with:
diff-search: true
file-name: ./package.json
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Removed
### BREAKING CHANGES

## [2.5.2] - 2022-03-03

### Fixed
- fix: validation of added route handlers was not working due to ajv cache

### Changed
- chore(deps): Update dependencies
- chore(deps): Update devDependencies

## [2.5.1] - 2021-12-04

### Fixed
Expand Down
3,972 changes: 2,004 additions & 1,968 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mocks-server/core",
"version": "2.5.1",
"version": "2.5.2",
"description": "Pluggable mock server supporting multiple route variants and mocks",
"keywords": [
"mocks",
Expand Down Expand Up @@ -40,43 +40,43 @@
"prepare": "is-ci || husky install"
},
"dependencies": {
"@babel/register": "7.16.0",
"@babel/register": "7.16.9",
"@hapi/boom": "9.1.4",
"ajv": "8.8.2",
"ajv": "8.9.0",
"ajv-errors": "3.0.0",
"body-parser": "1.19.0",
"body-parser": "1.19.1",
"commander": "8.3.0",
"cors": "2.8.5",
"express": "4.17.1",
"express": "4.17.2",
"express-request-id": "1.4.1",
"fs-extra": "10.0.0",
"globule": "1.3.3",
"is-promise": "4.0.0",
"lodash": "4.17.21",
"md5": "2.3.0",
"node-watch": "0.7.2",
"node-watch": "0.7.3",
"require-all": "3.0.0",
"route-parser": "0.0.5",
"winston": "3.3.3",
"winston-array-transport": "1.1.5"
"winston": "3.5.0",
"winston-array-transport": "1.1.7"
},
"devDependencies": {
"@babel/preset-env": "7.16.4",
"@babel/preset-typescript": "7.16.0",
"cross-fetch": "3.1.4",
"@babel/preset-env": "7.16.11",
"@babel/preset-typescript": "7.16.7",
"cross-fetch": "3.1.5",
"cross-spawn": "7.0.3",
"eslint": "8.4.0",
"eslint": "8.8.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"is-ci": "3.0.1",
"jest": "27.4.3",
"lint-staged": "12.1.2",
"prettier": "2.5.0",
"jest": "27.4.7",
"lint-staged": "12.3.2",
"prettier": "2.5.1",
"request": "2.88.2",
"request-promise": "4.2.6",
"sinon": "11.1.2",
"sinon": "12.0.1",
"strip-ansi": "6.0.0",
"tree-kill": "1.2.2",
"wait-on": "6.0.0"
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.organization=mocks-server
sonar.projectKey=mocks-server_core
sonar.projectVersion=2.5.1
sonar.projectVersion=2.5.2

sonar.javascript.file.suffixes=.js
sonar.sourceEncoding=UTF-8
Expand Down
7 changes: 4 additions & 3 deletions src/mocks/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ function getIds(objs) {
function compileRouteValidator(routesHandlers) {
if (validatorInited) {
const supportedRouteHandlersIds = getIds(routesHandlers);
routesSchema.properties.variants.items.properties.handler.enum = supportedRouteHandlersIds;
routesSchema.properties.variants.items.properties.handler.errorMessage = `Property "handler" should be one of "${supportedRouteHandlersIds.join(
const schema = { ...routesSchema };
schema.properties.variants.items.properties.handler.enum = supportedRouteHandlersIds;
schema.properties.variants.items.properties.handler.errorMessage = `Property "handler" should be one of "${supportedRouteHandlersIds.join(
","
)}" in variant \${1#}`;
routeValidator = ajv.compile(routesSchema);
routeValidator = ajv.compile(schema);
} else {
routeValidator = fooValidator;
}
Expand Down
18 changes: 18 additions & 0 deletions test/unit/mocks/validations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@ describe("mocks validations", () => {
});
});

describe("when adding routeHandlers to routeValidation", () => {
it("routeValidationErrors should return null if routes uses new handler", () => {
compileRouteValidator([{ id: "foo-handler" }, { id: "foo-new-handler" }]);
const errors = routeValidationErrors({
id: "foo-new-route",
url: "/foo",
method: "POST",
variants: [
{
id: "foo-new-variant",
handler: "foo-new-handler",
},
],
});
expect(errors).toEqual(null);
});
});

describe("variantValidationErrors", () => {
it("should return null if Hanlder has not validationSchema", () => {
expect(variantValidationErrors({}, {}, {})).toEqual(null);
Expand Down

0 comments on commit 50d2be9

Please sign in to comment.