Skip to content

Commit

Permalink
fix: fixed tests with ioredis-mock
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jun 7, 2022
1 parent 77453cd commit b6cc4b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"eslint-config-xo-lass": "^2.0.1",
"fixpack": "^4.0.0",
"husky": "^8.0.1",
"ioredis": "^5.0.6",
"ioredis-mock": "^8.2.2",
"lint-staged": "^13.0.0",
"nyc": "^15.1.0",
"pug": "^3.0.2",
Expand Down
13 changes: 8 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Passport = require('@ladjs/passport');
const Redis = require('ioredis-mock');
const Router = require('@koa/router');
const request = require('supertest');
const test = require('ava');
Expand All @@ -13,7 +14,8 @@ test('allows custom routes', async (t) => {
});

const web = new Web({
routes: router.routes()
routes: router.routes(),
redis: new Redis()
});

const response = await request(web.server).get('/en');
Expand All @@ -33,7 +35,8 @@ test('default method override', async (t) => {
});

const web = new Web({
routes: router.routes()
routes: router.routes(),
redis: new Redis()
});

const response = await request(web.server)
Expand All @@ -46,7 +49,7 @@ test('default method override', async (t) => {
});

test('with redis instance', (t) => {
const api = new Web();
const api = new Web({ redis: new Redis() });
t.is(typeof api.client, 'object');
t.is(typeof api.app.context.client, 'object');
});
Expand All @@ -59,13 +62,13 @@ test('without redis instance', (t) => {

test('with passport instance', (t) => {
const passport = new Passport({});
const api = new Web({ passport });
const api = new Web({ passport, redis: new Redis() });
t.is(typeof api.passport, 'object');
t.is(typeof api.app.context.passport, 'object');
});

test('without passport instance', (t) => {
const api = new Web();
const api = new Web({ redis: new Redis() });
t.is(api.passport, false);
t.is(api.app.context.passport, false);
});

0 comments on commit b6cc4b2

Please sign in to comment.