Skip to content

Commit

Permalink
Use fetch-mock for tests and switch from node-fetch to isomorphic-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
armenzg committed Jul 5, 2018
1 parent 17fe887 commit ea8c860
Show file tree
Hide file tree
Showing 15 changed files with 107,681 additions and 8 deletions.
1 change: 0 additions & 1 deletion .neutrinorc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = {
'@neutrinojs/mocha', {
exit: true,
recursive: true,
timeout: 600000,
}
],
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"dotenv": "^4.0.0",
"googleapis": "^27.0.0",
"ical-with-secure-request": "^0.6.0",
"isomorphic-fetch": "^2.2.1",
"json2csv": "^3.11.0",
"koa": "^2.3.0",
"koa-cors": "0.0.16",
Expand All @@ -42,7 +43,6 @@
"koa-router": "^7.2.1",
"lodash": "^4.17.2",
"moment": "^2.19.3",
"node-fetch": "^1.7.1",
"qs": "^6.5.0",
"query-string": "^5.0.1",
"redis": "^2.7.0",
Expand All @@ -55,6 +55,7 @@
"@neutrinojs/mocha": "^8.0.18",
"@neutrinojs/node": "^8.0.18",
"coveralls": "^3.0.0",
"fetch-mock": "^6.5.0",
"husky": "^0.14.3",
"lint-staged": "^7.0.5",
"mocha-lcov-reporter": "^1.3.0",
Expand Down
8 changes: 7 additions & 1 deletion src/fetch/text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/* global fetch */
import { createClient } from 'then-redis';
import fetch from 'node-fetch';
// This is important for being able to use 'fetch-mock' in tests
// I also switch from node-fetch to isomorphic-fetch to make it work
// both on node (test run) and the browser (loading the API)
// Read 'fetch is assigned to a local variable, not a global'
// http://www.wheresrhys.co.uk/fetch-mock/troubleshooting
import 'isomorphic-fetch';
import moment from 'moment';

const defaultTtl = moment.duration(8, 'hours').as('seconds');
Expand Down
Loading

0 comments on commit ea8c860

Please sign in to comment.