const configValues = require('../../config/config'); const constants = require('../../helper/constants'); const asyncRedis = require('async-redis'); const redisClient = asyncRedis.createClient({ port: configValues.redisPort, host: configValues.redisHost }); module.exports = { clearDataFromRedis: async(userId) => { let removeUserDetails=await redisClient.del(userId+'_userDetails'); return removeUserDetails; }, closeRedisInstance :()=>{ redisClient.quit(); } };
const {clearDataFromRedis ,closeRedisInstance} = require('../..//../src/shared-module/service'); const redis_mock = require("redis-mock"); const client = redis_mock.createClient(); describe('clearDataFromRedis',()=>{ it('should clear data from redis',async ()=>{ client.del=jest.fn().mockReturnValue(1); const result=await clearDataFromRedis('userData'); expect(result).toBe(1); }) }); afterAll(() => closeRedisInstance());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)