Guest User

Untitled

a guest
Jan 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import { Request, Response, Router } from "express";
  2. import * as redis from "redis";
  3. const redisOption: redis.ClientOpts = {
  4. host: "13.125.255.140",
  5. port: 6379,
  6. detect_buffers : true,
  7. db: 0,
  8. retry_strategy: () => 60000
  9. }
  10. const redisClient: redis.RedisClient = redis.createClient(redisOption);
  11.  
  12. export class IndexRoutes {
  13. public router: Router;
  14. constructor() {
  15. this.router = Router();
  16. this.init();
  17. }
  18. public init() {
  19. this.router.get("/", this.getFunc);
  20. }
  21. private getFunc = async (req: Request, res: Response) => {
  22. return res.status(200).send(await redisClient.set("test", "123"));
  23. }
  24. }
  25.  
  26. import * as redis from 'redis';
  27.  
  28. describe('my redis wrapper', () => {
  29. it('Should call get when my wrapper's getFunc is called', () => {
  30. let myRedisSpy = jest.spyOn(redis.prototype, 'get');
  31. // call your function here
  32. expect(myRedisSpy).toHaveBeenCalledOnce();
  33. });
  34. });
Add Comment
Please, Sign In to add comment