Skip to content

Commit

Permalink
Merge pull request #63 from rokka-io/use-jest
Browse files Browse the repository at this point in the history
use jest/nock instead of ava
  • Loading branch information
chregu authored Dec 13, 2019
2 parents cd6a5b2 + caede9e commit 8b3677a
Show file tree
Hide file tree
Showing 102 changed files with 11,886 additions and 6,308 deletions.
5 changes: 2 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"browsers": [">0.1%", "not op_mini all"],
"node": "current"
}
}],
"@ava/stage-4"
}]
],
"plugins": [
["@babel/plugin-transform-runtime", { corejs: 2 }]
["@babel/plugin-transform-runtime", { "corejs": 2 }]
]
}
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ env:
node: true
browser: true
es6: true
jest: true

rules:
prefer-const: error
12,156 changes: 7,001 additions & 5,155 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"/src/*"
],
"scripts": {
"test": "npm run lint && npm run ava",
"test": "npm run lint && npm run jest",
"lint": "./node_modules/.bin/eslint .",
"ava": "ava",
"coverage": "BABEL_ENV=coverage nyc npm run ava",
"coveralls": "npm run coverage; nyc report --reporter=text-lcov | coveralls",
"jest": "jest",
"coverage": "BABEL_ENV=coverage npm run jest -- --coverage",
"coveralls": "BABEL_ENV=coverage npm run jest -- --coverage --coverageReporters=text-lcov | coveralls",
"docs": "cd ./docs; node generate.js",
"compile": "rm -rf ./dist && rollup -c",
"prepare": "npm run compile",
"watch": "rollup -c -w",
"fix": "prettier-eslint --write '{src,test}/**/*.js'"
"fix": "prettier-eslint --write '{src,tests}/**/*.js'"
},
"repository": {
"type": "git",
Expand All @@ -42,13 +42,12 @@
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"cross-fetch": "^3.0.4",
"form-data": "^2.5.1",
"form-data": "^3.0.0",
"query-string": "^6.8.3"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/runtime-corejs2": "^7.6.3",
"ava": "^2.4.0",
"coveralls": "^3.0.7",
"eslint": "^6.6.0",
"eslint-config-standard": "^14.1.0",
Expand All @@ -57,9 +56,10 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"markdox": "^0.1.10",
"nyc": "^14.1.1",
"nock": "^11.7.0",
"prettier": "^1.18.2",
"prettier-eslint-cli": "^5.0.0",
"rollup": "^1.26.3",
Expand All @@ -68,12 +68,6 @@
"rollup-plugin-terser": "^5.1.2",
"testdouble": "^3.12.4"
},
"ava": {
"require": [
"@babel/register"
],
"failWithoutAssertions": false
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm run docs && npm run lint"
Expand Down
26 changes: 11 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,17 @@ export default (config = {}) => {
}

const t = transport(uri, request)
// currently in the tests, we don't have then...
if (t && t.then) {
return t.then(async response => {
const rokkaResponse = RokkaResponse(response)
rokkaResponse.body = await getResponseBody(response)
if (response.status >= 400) {
rokkaResponse.error = rokkaResponse.body
rokkaResponse.message =
response.status + ' - ' + JSON.stringify(rokkaResponse.body)
throw rokkaResponse
}
return rokkaResponse
})
}
return t
return t.then(async response => {
const rokkaResponse = RokkaResponse(response)
rokkaResponse.body = await getResponseBody(response)
if (response.status >= 400) {
rokkaResponse.error = rokkaResponse.body
rokkaResponse.message =
response.status + ' - ' + JSON.stringify(rokkaResponse.body)
throw rokkaResponse
}
return rokkaResponse
})
}
}

Expand Down
93 changes: 0 additions & 93 deletions test/apis/memberships.test.js

This file was deleted.

47 changes: 0 additions & 47 deletions test/apis/operations.test.js

This file was deleted.

50 changes: 0 additions & 50 deletions test/apis/organizations.test.js

This file was deleted.

42 changes: 0 additions & 42 deletions test/apis/render.test.js

This file was deleted.

Loading

0 comments on commit 8b3677a

Please sign in to comment.