From bfdcf986c3d09a3e3eca6101442364b17ec9d153 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Fri, 25 Dec 2020 18:11:45 +0100 Subject: [PATCH 1/7] fix: Remove mocks-server-plugin tag from package.json (#93) --- CHANGELOG.md | 1 + package.json | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f27b1..6481f40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed ### Fixed +- fix: Remove mocks-server-plugin tag from package.json (#93) ### Removed ## [2.0.5] - 2020-12-21 diff --git a/package.json b/package.json index 1a16a7a..ac4d534 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "2.0.5", "description": "Client of @mocks-server/plugin-admin-api", "keywords": [ - "mocks-server-plugin", "administration", "admin", "api", From 842bfd8e7d1d226574af56e900bf251ab7584de3 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Fri, 25 Dec 2020 18:16:47 +0100 Subject: [PATCH 2/7] chore(lint): Lint mocks folder --- CHANGELOG.md | 1 + mocks/mocks-server.config.js | 4 ++-- mocks/mocks/behaviors.js | 2 +- mocks/mocks/fixtures.js | 10 +++++----- package-lock.json | 6 +++--- package.json | 7 ++++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6481f40..3b8a5ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] ### Added ### Changed +- chore(lint): Lint mocks folder ### Fixed - fix: Remove mocks-server-plugin tag from package.json (#93) ### Removed diff --git a/mocks/mocks-server.config.js b/mocks/mocks-server.config.js index fcc3ecd..0c49c4a 100644 --- a/mocks/mocks-server.config.js +++ b/mocks/mocks-server.config.js @@ -1,5 +1,5 @@ module.exports = { options: { - port: 3200 - } + port: 3200, + }, }; diff --git a/mocks/mocks/behaviors.js b/mocks/mocks/behaviors.js index 8ca9887..fdef5ae 100644 --- a/mocks/mocks/behaviors.js +++ b/mocks/mocks/behaviors.js @@ -7,5 +7,5 @@ const user2 = new Behavior([getUser2]); module.exports = { base, - user2 + user2, }; diff --git a/mocks/mocks/fixtures.js b/mocks/mocks/fixtures.js index 0eec0a3..8451f91 100644 --- a/mocks/mocks/fixtures.js +++ b/mocks/mocks/fixtures.js @@ -3,8 +3,8 @@ const getUser = { method: "GET", response: { status: 200, - body: [{ email: "foo@foo.com" }] - } + body: [{ email: "foo@foo.com" }], + }, }; const getUser2 = { @@ -12,11 +12,11 @@ const getUser2 = { method: "GET", response: { status: 200, - body: [{ email: "foo2@foo2.com" }] - } + body: [{ email: "foo2@foo2.com" }], + }, }; module.exports = { getUser, - getUser2 + getUser2, }; diff --git a/package-lock.json b/package-lock.json index 081776e..f092507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2712,9 +2712,9 @@ } }, "@mocks-server/admin-api-paths": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@mocks-server/admin-api-paths/-/admin-api-paths-1.0.8.tgz", - "integrity": "sha512-UH7PqoUWhUjUexP5IeS08frHKsKa5mzLi/HosbWLxo0rkk6SqzOmxg+2mtBPPx+y/Pw8RygfiwvRdUJGvK1byA==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mocks-server/admin-api-paths/-/admin-api-paths-1.1.0.tgz", + "integrity": "sha512-qFcIsRtfD9uXj3Js0qKyKZKUeoCgzcjxZWPw3Xe64bPByE5lrPYlMzVMbmENVLIkQS5aOlVttxOzpG8jHO/DxA==" }, "@rollup/plugin-babel": { "version": "5.2.1", diff --git a/package.json b/package.json index ac4d534..0fddfb7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "module": "dist/index.esm.js", "scripts": { "build": "rollup --config", - "lint": "eslint *.js test src jest.config.js", + "lint": "eslint *.js test src mocks/*.js mocks/mocks/*.js", "lint-staged": "lint-staged", "mocks:install": "cd mocks && npm i", "mocks:ci": "cd mocks && npm run mocks:ci", @@ -32,7 +32,7 @@ }, "dependencies": { "cross-fetch": "3.0.6", - "@mocks-server/admin-api-paths": "1.0.8" + "@mocks-server/admin-api-paths": "1.1.0" }, "devDependencies": { "@babel/preset-env": "7.12.1", @@ -59,7 +59,8 @@ "test/**/*.js": "eslint", "src/**/*.js": "eslint", "*.js": "eslint", - "jest.config.js": "eslint" + "mocks/*.js": "eslint", + "mocks/mocks/*.js": "eslint" }, "husky": { "hooks": { From 8bcfa3248b513d8408fcbc2fdfae71bc0a36465f Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 26 Dec 2020 11:32:45 +0100 Subject: [PATCH 3/7] feat: Add method for reading alerts (#94) --- CHANGELOG.md | 1 + README.md | 8 +- mocks/mocks-server.config.js | 1 + mocks/mocks-with-error/fixtures.js | 2 + mocks/package-lock.json | 380 ++++++++++++----------------- mocks/package.json | 2 +- src/methods.js | 9 +- test/.eslintrc.json | 8 + test/index.js | 31 ++- test/index.spec.js | 52 +++- 10 files changed, 264 insertions(+), 230 deletions(-) create mode 100644 mocks/mocks-with-error/fixtures.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b8a5ab..2e0216b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] ### Added +- feat: Add method for reading alerts (#94) ### Changed - chore(lint): Lint mocks folder ### Fixed diff --git a/README.md b/README.md index 98943a7..56d3e0e 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ # Mocks-server administration api client -This package contains methods for administrating the mocks-server _(through the [@mocks-server/plugin-admin-api](https://github.com/mocks-server/plugin-admin-api) REST API)_. +This package contains methods for administrating `mocks-server` _(through the [@mocks-server/plugin-admin-api](https://github.com/mocks-server/plugin-admin-api) REST API)_. -Requests to the @mocks-server are made using [cross-fetch](https://www.npmjs.com/package/cross-fetch), which makes this package compatible with browsers and nodejs environments, but, if you are going to build a browser application, you'll probably prefer to use the [@mocks-server/admin-api-client-data-provider package](https://www.npmjs.com/package/@mocks-server/admin-api-client-data-provider), which uses [@data-provider](https://github.com/data-provider), and works well with Redux, React, etc. +Requests to `mocks-server` are made using [cross-fetch](https://www.npmjs.com/package/cross-fetch), which makes this package compatible with browsers and nodejs environments, but, if you are going to build a browser application, you'll probably prefer to use the [@mocks-server/admin-api-client-data-provider package](https://www.npmjs.com/package/@mocks-server/admin-api-client-data-provider), which uses [@data-provider](https://github.com/data-provider), and works well with Redux, React, etc. ## Install @@ -24,7 +24,7 @@ The UMD build is also available on unpkg: ``` -> The umd distribution is bundled with the "cross-env" dependency, but requires the "@mocks-server/admin-api-paths" dependency to be added separately. +> The umd distribution is bundled with the `cross-env` dependency, but requires the `@mocks-server/admin-api-paths` dependency to be added separately. ## Usage @@ -59,6 +59,8 @@ example(); * `behavior(behaviorName).read()` - Returns an specific behavior. * `fixtures.read()` - Returns collection of available fixtures. * `fixture(fixtureId).read()` - Returns an specific fixture. +* `alerts.read()` - Returns array of current alerts. +* `alert(alertId).read()` - Returns an specific alert. ## Configuration diff --git a/mocks/mocks-server.config.js b/mocks/mocks-server.config.js index 0c49c4a..5460b3f 100644 --- a/mocks/mocks-server.config.js +++ b/mocks/mocks-server.config.js @@ -1,5 +1,6 @@ module.exports = { options: { port: 3200, + log: "debug", }, }; diff --git a/mocks/mocks-with-error/fixtures.js b/mocks/mocks-with-error/fixtures.js new file mode 100644 index 0000000..6a09ab7 --- /dev/null +++ b/mocks/mocks-with-error/fixtures.js @@ -0,0 +1,2 @@ +//eslint-disable-next-line +FOO diff --git a/mocks/package-lock.json b/mocks/package-lock.json index a47a54d..c674426 100644 --- a/mocks/package-lock.json +++ b/mocks/package-lock.json @@ -4,6 +4,17 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@dabh/diagnostics": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", + "integrity": "sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q==", + "dev": true, + "requires": { + "colorspace": "1.1.x", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, "@hapi/boom": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/@hapi/boom/-/boom-9.1.0.tgz", @@ -14,79 +25,74 @@ } }, "@hapi/hoek": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.4.tgz", - "integrity": "sha512-EwaJS7RjoXUZ2cXXKZZxZqieGtc7RbvQhUy8FwDoMQtxWVi14tFjeFCYPZAM1mBCpOpiBpyaZbb9NeHc7eGKgw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.1.0.tgz", + "integrity": "sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw==", "dev": true }, "@mocks-server/admin-api-paths": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@mocks-server/admin-api-paths/-/admin-api-paths-1.0.7.tgz", - "integrity": "sha512-9AOpcA6YLLq8ssS7niWLNsvLMTcxM0gs1sogirPr7M3J6hap0La1uSncwfSt5nDAqgL6pv7ivhdL13dq7A1b8A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mocks-server/admin-api-paths/-/admin-api-paths-1.1.0.tgz", + "integrity": "sha512-qFcIsRtfD9uXj3Js0qKyKZKUeoCgzcjxZWPw3Xe64bPByE5lrPYlMzVMbmENVLIkQS5aOlVttxOzpG8jHO/DxA==", "dev": true }, "@mocks-server/core": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/@mocks-server/core/-/core-1.4.8.tgz", - "integrity": "sha512-YSJ/kcIB4wfmxLICk2Dw3Jii+Q+VGtjLKBvrsXqIpBooq8jq8ACLEGnp8bOwR3uSmpAmbcrpMOB1svp7fpIhPw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@mocks-server/core/-/core-1.6.0.tgz", + "integrity": "sha512-Gh2C7RGXvs09x7qDArby2XN1G11iOyLY5AcZzSaJXHM59F59NV9E17rNKf5i8S2XJVv1aNA4WO/AqsIfMFDcXQ==", "dev": true, "requires": { "@hapi/boom": "9.1.0", "body-parser": "1.19.0", - "commander": "5.1.0", + "commander": "6.2.0", "cors": "2.8.5", "express": "4.17.1", "express-request-id": "1.4.1", "fs-extra": "9.0.1", "is-promise": "4.0.0", - "lodash": "4.17.15", - "md5": "2.2.1", - "node-watch": "0.6.4", + "lodash": "4.17.20", + "md5": "2.3.0", + "node-watch": "0.7.0", "require-all": "3.0.0", "route-parser": "0.0.5", - "winston": "3.2.1" + "winston": "3.3.3" } }, "@mocks-server/main": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@mocks-server/main/-/main-1.8.6.tgz", - "integrity": "sha512-G4G+yDcz32QZmsiuyle1VsS9r/ye4TJtHrfTsnzvKtkx4eSZJG8iGv4m2Or9zyPpPbmDmoGnTjW+mHm76TkjCA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@mocks-server/main/-/main-1.9.0.tgz", + "integrity": "sha512-42UjkNiyzDPTo+LsNFz5hKC1TJsbF77TwdM1FDPSQc2PYFfUFswnjAz3Oz5NIfpTsCdV5CBbIWaHqvR2sTudUQ==", "dev": true, "requires": { - "@mocks-server/core": "1.4.8", - "@mocks-server/plugin-admin-api": "1.4.5", - "@mocks-server/plugin-inquirer-cli": "1.3.5" + "@mocks-server/core": "1.6.0", + "@mocks-server/plugin-admin-api": "1.5.0", + "@mocks-server/plugin-inquirer-cli": "1.4.1" } }, "@mocks-server/plugin-admin-api": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/@mocks-server/plugin-admin-api/-/plugin-admin-api-1.4.5.tgz", - "integrity": "sha512-Y2qwGCNRqu0ZxLu3m39HeADw/mmIwIbL9alHH+e1yQt419kF2FHVGUEwBSxOEIwnpJD6y2iL5f0JBvQMf4oGQg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@mocks-server/plugin-admin-api/-/plugin-admin-api-1.5.0.tgz", + "integrity": "sha512-yR5RQ4zgNxO4iR206tV5tWOpqKaGw5CHvXY1qUkGK3h6Kj8M+qNu/I8JWihx/mAvoW/LgUvzFylNAFQEY9MewQ==", "dev": true, "requires": { "@hapi/boom": "9.1.0", - "@mocks-server/admin-api-paths": "1.0.7", + "@mocks-server/admin-api-paths": "1.1.0", "express": "4.17.1" } }, "@mocks-server/plugin-inquirer-cli": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@mocks-server/plugin-inquirer-cli/-/plugin-inquirer-cli-1.3.5.tgz", - "integrity": "sha512-sbaHW4ZDAhhQzGm3j6a4ePcOeVM7u3pNKVCMNajeu6qWuajZMljXmGHsqvX61E9R1uZ3wNZJX20f4lJdkLD+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@mocks-server/plugin-inquirer-cli/-/plugin-inquirer-cli-1.4.1.tgz", + "integrity": "sha512-njA1fxorXaueoH4VU2j4YMLbvxpm058s2Xav2OOovUXY5lU1EWpBJ0zBEDolsjnkQNsx0MnfRPopsCwxjfcORw==", "dev": true, "requires": { "chalk": "4.1.0", - "inquirer": "7.2.0", - "inquirer-autocomplete-prompt": "1.0.2", - "lodash": "4.17.15" + "inquirer": "7.3.3", + "inquirer-autocomplete-prompt": "1.3.0", + "lodash": "4.17.20", + "node-emoji": "1.10.0" } }, - "@types/color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", - "dev": true - }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -113,12 +119,11 @@ "dev": true }, "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" }, "dependencies": { @@ -146,13 +151,10 @@ "dev": true }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", - "dev": true, - "requires": { - "lodash": "^4.17.14" - } + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", + "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", + "dev": true }, "at-least-node": { "version": "1.0.0", @@ -216,9 +218,9 @@ } }, "cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", "dev": true }, "color": { @@ -247,21 +249,15 @@ "dev": true }, "color-string": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", - "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.4.tgz", + "integrity": "sha512-57yF5yt8Xa3czSEW1jfQDE79Idk0+AkN/4KWad6tbdxUmAs3MvjxlWSWD4deYytcRfoZ9nhKyFl1kj5tBvidbw==", "dev": true, "requires": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" } }, - "colornames": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", - "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=", - "dev": true - }, "colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", @@ -279,9 +275,9 @@ } }, "commander": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", - "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz", + "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==", "dev": true }, "content-disposition": { @@ -354,17 +350,6 @@ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", "dev": true }, - "diagnostics": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", - "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", - "dev": true, - "requires": { - "colorspace": "1.1.x", - "enabled": "1.0.x", - "kuler": "1.0.x" - } - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -378,13 +363,10 @@ "dev": true }, "enabled": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", - "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", - "dev": true, - "requires": { - "env-variable": "0.0.x" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "dev": true }, "encodeurl": { "version": "1.0.2", @@ -392,12 +374,6 @@ "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", "dev": true }, - "env-variable": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.6.tgz", - "integrity": "sha512-bHz59NlBbtS0NhftmR8+ExBEekE7br0e01jw+kk0NDro7TtZzBYZ5ScGPs3OmwnpyfHTHOtr1Y6uedCdrIldtg==", - "dev": true - }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -510,6 +486,12 @@ "unpipe": "~1.0.0" } }, + "fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", + "dev": true + }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", @@ -575,100 +557,37 @@ "dev": true }, "inquirer": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.2.0.tgz", - "integrity": "sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ==", + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^3.0.0", + "chalk": "^4.1.0", "cli-cursor": "^3.1.0", - "cli-width": "^2.0.0", + "cli-width": "^3.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", - "lodash": "^4.17.15", + "lodash": "^4.17.19", "mute-stream": "0.0.8", "run-async": "^2.4.0", - "rxjs": "^6.5.3", + "rxjs": "^6.6.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0", "through": "^2.3.6" - }, - "dependencies": { - "chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - } } }, "inquirer-autocomplete-prompt": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/inquirer-autocomplete-prompt/-/inquirer-autocomplete-prompt-1.0.2.tgz", - "integrity": "sha512-vNmAhhrOQwPnUm4B9kz1UB7P98rVF1z8txnjp53r40N0PBCuqoRWqjg3Tl0yz0UkDg7rEUtZ2OZpNc7jnOU9Zw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/inquirer-autocomplete-prompt/-/inquirer-autocomplete-prompt-1.3.0.tgz", + "integrity": "sha512-zvAc+A6SZdcN+earG5SsBu1RnQdtBS4o8wZ/OqJiCfL34cfOx+twVRq7wumYix6Rkdjn1N2nVCcO3wHqKqgdGg==", "dev": true, "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "figures": "^2.0.0", - "run-async": "^2.3.0" - }, - "dependencies": { - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "ansi-escapes": "^4.3.1", + "chalk": "^4.0.0", + "figures": "^3.2.0", + "run-async": "^2.4.0", + "rxjs": "^6.6.2" } }, "ipaddr.js": { @@ -702,9 +621,9 @@ "dev": true }, "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", "dev": true }, "isarray": { @@ -714,28 +633,39 @@ "dev": true }, "jsonfile": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", - "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "requires": { "graceful-fs": "^4.1.6", - "universalify": "^1.0.0" + "universalify": "^2.0.0" + }, + "dependencies": { + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + } } }, "kuler": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", - "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", - "dev": true, - "requires": { - "colornames": "^1.1.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "dev": true }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + }, + "lodash.toarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.toarray/-/lodash.toarray-4.4.0.tgz", + "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", "dev": true }, "logform": { @@ -752,22 +682,22 @@ }, "dependencies": { "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true } } }, "md5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz", - "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", "dev": true, "requires": { - "charenc": "~0.0.1", - "crypt": "~0.0.1", - "is-buffer": "~1.1.1" + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" } }, "media-typer": { @@ -833,10 +763,19 @@ "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", "dev": true }, + "node-emoji": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", + "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", + "dev": true, + "requires": { + "lodash.toarray": "^4.4.0" + } + }, "node-watch": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.6.4.tgz", - "integrity": "sha512-cI6CHzivIFESe8djiK3Wh90CtWQBxLwMem8x8S+2GSvCvFgoMuOKVlfJtQ/2v3Afg3wOnHl/+tXotEs8z5vOrg==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.7.0.tgz", + "integrity": "sha512-OOBiglke5SlRQT5WYfwXTmYqTfXjcTNBHpalyHLtLxDpQYVpVRkJqabcch1kmwJsjV/J4OZuzEafeb4soqtFZA==", "dev": true }, "object-assign": { @@ -855,15 +794,18 @@ } }, "one-time": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", - "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=", - "dev": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "dev": true, + "requires": { + "fn.name": "1.x.x" + } }, "onetime": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", - "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, "requires": { "mimic-fn": "^2.1.0" @@ -967,9 +909,9 @@ "dev": true }, "rxjs": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.5.tgz", - "integrity": "sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz", + "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -1099,9 +1041,9 @@ } }, "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" @@ -1141,9 +1083,9 @@ "dev": true }, "tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, "type-fest": { @@ -1199,20 +1141,20 @@ "dev": true }, "winston": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", - "integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.3.3.tgz", + "integrity": "sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw==", "dev": true, "requires": { - "async": "^2.6.1", - "diagnostics": "^1.1.1", - "is-stream": "^1.1.0", - "logform": "^2.1.1", - "one-time": "0.0.4", - "readable-stream": "^3.1.1", + "@dabh/diagnostics": "^2.0.2", + "async": "^3.1.0", + "is-stream": "^2.0.0", + "logform": "^2.2.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", - "winston-transport": "^4.3.0" + "winston-transport": "^4.4.0" } }, "winston-transport": { diff --git a/mocks/package.json b/mocks/package.json index 7f87b59..c2ef5cb 100644 --- a/mocks/package.json +++ b/mocks/package.json @@ -7,6 +7,6 @@ "mocks:ci": "mocks-server --cli=false" }, "devDependencies": { - "@mocks-server/main": "1.8.6" + "@mocks-server/main": "1.9.0" } } diff --git a/src/methods.js b/src/methods.js index 3ff8930..3600c29 100644 --- a/src/methods.js +++ b/src/methods.js @@ -6,6 +6,7 @@ import { SETTINGS, BEHAVIORS, FIXTURES, + ALERTS, } from "@mocks-server/admin-api-paths"; const DEFAULT_OPTIONS = { @@ -27,7 +28,7 @@ export const config = (options) => { class Fetcher { constructor(url, id) { this._url = url; - this._id = id ? `/${id}` : ""; + this._id = id ? `/${encodeURIComponent(id)}` : ""; } get url() { @@ -72,3 +73,9 @@ export const fixtures = new Fetcher(FIXTURES); export const fixture = (id) => { return new Fetcher(FIXTURES, id); }; + +export const alerts = new Fetcher(ALERTS); + +export const alert = (id) => { + return new Fetcher(ALERTS, id); +}; diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 2378e5a..3305270 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -1,4 +1,12 @@ { + "env": { + "node": true, + "es6": true + }, + "parserOptions": { + "ecmaVersion": "2018", + "sourceType": "module" + }, "globals": { "jest": true, "beforeAll": true, diff --git a/test/index.js b/test/index.js index 399e757..6f06b98 100644 --- a/test/index.js +++ b/test/index.js @@ -1,4 +1,14 @@ -import { about, behaviors, behavior, fixtures, fixture, settings, config } from "../index"; +import { + about, + behaviors, + behavior, + fixtures, + fixture, + settings, + config, + alerts, + alert, +} from "../index"; config({ baseUrl: "http://localhost:3200", @@ -32,6 +42,22 @@ const updateSettings = (newSettings) => { return settings.update(newSettings); }; +const readAlerts = () => { + return alerts.read(); +}; + +const readAlert = (id) => { + return alert(id).read(); +}; + +const wait = (time = 1000) => { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, time); + }); +}; + module.exports = { readAbout, readBehaviors, @@ -40,4 +66,7 @@ module.exports = { readFixture, readSettings, updateSettings, + readAlerts, + readAlert, + wait, }; diff --git a/test/index.spec.js b/test/index.spec.js index d312330..f0ef8c7 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -5,18 +5,60 @@ import { readFixtures, readFixture, readSettings, + readAlerts, + readAlert, updateSettings, + wait, } from "./index"; describe("react-admin-client methods used through node", () => { - describe("whe reading about", () => { + describe("when reading about", () => { it("should return current version", async () => { const about = await readAbout(); expect(about.version).toBeDefined(); }); }); - describe("whe reading fixtures", () => { + describe("when reading alerts", () => { + describe("when there are no alerts", () => { + it("should return an empty array", async () => { + const alerts = await readAlerts(); + expect(alerts).toEqual([]); + }); + }); + + describe("when there are alerts", () => { + it("should return alerts array", async () => { + expect.assertions(1); + await updateSettings({ + path: "mocks-with-error", + }); + await wait(2000); + const alerts = await readAlerts(); + expect(alerts.length).toEqual(1); + }); + + it("first alert model should exist", async () => { + const alerts = await readAlerts(); + const alertId = alerts[0].id; + const alert = await readAlert(alertId); + expect(alert.id).toEqual(alertId); + }); + }); + + describe("when alerts are removed", () => { + it("should return an empty array again", async () => { + await updateSettings({ + path: "mocks", + }); + await wait(2000); + const alerts = await readAlerts(); + expect(alerts).toEqual([]); + }); + }); + }); + + describe("when reading fixtures", () => { it("should return current fixtures collection", async () => { const fixtures = await readFixtures(); expect(fixtures.length).toEqual(2); @@ -37,7 +79,7 @@ describe("react-admin-client methods used through node", () => { }); }); - describe("whe reading behaviors", () => { + describe("when reading behaviors", () => { it("should return behaviors collection", async () => { const behaviors = await readBehaviors(); expect(behaviors.length).toEqual(2); @@ -79,7 +121,7 @@ describe("react-admin-client methods used through node", () => { }); }); - describe("whe reading settings", () => { + describe("when reading settings", () => { it("should return current behavior", async () => { const settings = await readSettings(); expect(settings.behavior).toEqual("base"); @@ -92,7 +134,7 @@ describe("react-admin-client methods used through node", () => { }); }); - describe("whe updating settings", () => { + describe("when updating settings", () => { it("should update current behavior", async () => { await updateSettings({ behavior: "user2", From c0f417a762cab3dc35bce15cdd3d40c824be8ad6 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 26 Dec 2020 11:35:14 +0100 Subject: [PATCH 4/7] test(refactor): Move helpers to a support folder --- CHANGELOG.md | 1 + jest.config.js | 5 +---- test/index.spec.js | 2 +- test/{index.js => support/helpers.js} | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) rename test/{index.js => support/helpers.js} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e0216b..7273da0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - feat: Add method for reading alerts (#94) ### Changed - chore(lint): Lint mocks folder +- test(refactor): Move helpers to a support folder ### Fixed - fix: Remove mocks-server-plugin tag from package.json (#93) ### Removed diff --git a/jest.config.js b/jest.config.js index a41d05f..26be6ce 100644 --- a/jest.config.js +++ b/jest.config.js @@ -25,10 +25,7 @@ module.exports = { }, // The glob patterns Jest uses to detect test files - testMatch: [ - "/test/?(*.)+(spec|test).js?(x)", - "/test/*/?(*.)+(spec|test).js?(x)", - ], + testMatch: ["/test/*.spec.js"], transform: { ".js$": "babel-jest", diff --git a/test/index.spec.js b/test/index.spec.js index f0ef8c7..a3636fe 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -9,7 +9,7 @@ import { readAlert, updateSettings, wait, -} from "./index"; +} from "./support/helpers"; describe("react-admin-client methods used through node", () => { describe("when reading about", () => { diff --git a/test/index.js b/test/support/helpers.js similarity index 97% rename from test/index.js rename to test/support/helpers.js index 6f06b98..a687845 100644 --- a/test/index.js +++ b/test/support/helpers.js @@ -8,7 +8,7 @@ import { config, alerts, alert, -} from "../index"; +} from "../../index"; config({ baseUrl: "http://localhost:3200", From 2a41237ed14da1a28d33225922c7e821ad0a0810 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 26 Dec 2020 11:42:34 +0100 Subject: [PATCH 5/7] chore(release): Upgrade version --- CHANGELOG.md | 10 +++++++++- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7273da0..b6d694e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] +### Added +### Changed +### Fixed +### Removed + +## [2.1.0] - 2020-12-26 + ### Added - feat: Add method for reading alerts (#94) + ### Changed - chore(lint): Lint mocks folder - test(refactor): Move helpers to a support folder + ### Fixed - fix: Remove mocks-server-plugin tag from package.json (#93) -### Removed ## [2.0.5] - 2020-12-21 diff --git a/package-lock.json b/package-lock.json index f092507..c7b7b16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mocks-server/admin-api-client", - "version": "2.0.5", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0fddfb7..0415824 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mocks-server/admin-api-client", - "version": "2.0.5", + "version": "2.1.0", "description": "Client of @mocks-server/plugin-admin-api", "keywords": [ "administration", diff --git a/sonar-project.properties b/sonar-project.properties index 9dc60e5..3647429 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.organization=mocks-server sonar.projectKey=mocks-server-admin-api-client -sonar.projectVersion=2.0.5 +sonar.projectVersion=2.1.0 sonar.javascript.file.suffixes=.js sonar.sourceEncoding=UTF-8 From 902db926a739b28c45abd71baba329cf2078b861 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 26 Dec 2020 11:46:30 +0100 Subject: [PATCH 6/7] chore(sonar): Exclude mocks folders --- sonar-project.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 3647429..967fcd9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,10 +4,10 @@ sonar.projectVersion=2.1.0 sonar.javascript.file.suffixes=.js sonar.sourceEncoding=UTF-8 -sonar.exclusions=node_modules/**,*.config.js +sonar.exclusions=node_modules/**,*.config.js,mocks/mocks-with-error/**,mocks/node_modules/** sonar.test.exclusions=test/**/*,mocks/**/* sonar.coverage.exclusions=test/**/*,mocks/**/* -sonar.cpd.exclusions=test/**,test-e2e/**/* +sonar.cpd.exclusions=test/**,mocks/**/* sonar.javascript.lcov.reportPaths=coverage/lcov.info sonar.host.url=https://sonarcloud.io From 55e4d689a3beaf172fc3c1bf0b9d3c834ed86156 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Sat, 26 Dec 2020 11:48:27 +0100 Subject: [PATCH 7/7] chore(sonar): Exclude mocks folders --- mocks/mocks-with-error/fixtures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mocks/mocks-with-error/fixtures.js b/mocks/mocks-with-error/fixtures.js index 6a09ab7..64fce11 100644 --- a/mocks/mocks-with-error/fixtures.js +++ b/mocks/mocks-with-error/fixtures.js @@ -1,2 +1,2 @@ //eslint-disable-next-line -FOO +module.exports = FOO