Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Request, Response, Router } from "express";
- import * as redis from "redis";
- const redisOption: redis.ClientOpts = {
- host: "13.125.255.140",
- port: 6379,
- detect_buffers : true,
- db: 0,
- retry_strategy: () => 60000
- }
- const redisClient: redis.RedisClient = redis.createClient(redisOption);
- export class IndexRoutes {
- public router: Router;
- constructor() {
- this.router = Router();
- this.init();
- }
- public init() {
- this.router.get("/", this.getFunc);
- }
- private getFunc = async (req: Request, res: Response) => {
- return res.status(200).send(await redisClient.set("test", "123"));
- }
- }
- import * as redis from 'redis';
- describe('my redis wrapper', () => {
- it('Should call get when my wrapper's getFunc is called', () => {
- let myRedisSpy = jest.spyOn(redis.prototype, 'get');
- // call your function here
- expect(myRedisSpy).toHaveBeenCalledOnce();
- });
- });
Add Comment
Please, Sign In to add comment