How to use the ioredis-mock.default.prototype function in ioredis-mock

To help you get started, we’ve selected a few ioredis-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dadi / cache / test / unit / redis.js View on Github external
const fs = require('fs')
const path = require('path')
const sinon = require('sinon')
const should = require('should')
const noderedis = require('redis')
const Stream = require('stream')
const toString = require('stream-to-string')
const RedisMock = require('ioredis-mock').default
const exec = require('child_process').exec
const EventEmitter = require('events').EventEmitter

const Cache = require('./../../lib/index')

/* RedisMock is not complete, so must create some stubs */
RedisMock.prototype.on = () => {}
RedisMock.prototype.status = 'ready'

var cache

describe('RedisCache', () => {
  describe('set', () => {
    after(done => {
      // remove cache folder contents completely, and recreate
      const cleanup = dir => {
        exec('rm -r ' + dir, (_, stdout, stderr) => {
          exec('mkdir ' + dir)
          done()
        })
      }

      if (cache.cacheHandler.directory) {
        cleanup(path.resolve(cache.cacheHandler.directory))
github dadi / cache / test / unit / redis.js View on Github external
const fs = require('fs')
const path = require('path')
const sinon = require('sinon')
const should = require('should')
const noderedis = require('redis')
const Stream = require('stream')
const toString = require('stream-to-string')
const RedisMock = require('ioredis-mock').default
const exec = require('child_process').exec
const EventEmitter = require('events').EventEmitter

const Cache = require('./../../lib/index')

/* RedisMock is not complete, so must create some stubs */
RedisMock.prototype.on = () => {}
RedisMock.prototype.status = 'ready'

var cache

describe('RedisCache', () => {
  describe('set', () => {
    after(done => {
      // remove cache folder contents completely, and recreate
      const cleanup = dir => {
        exec('rm -r ' + dir, (_, stdout, stderr) => {
          exec('mkdir ' + dir)
          done()
        })
      }

      if (cache.cacheHandler.directory) {

ioredis-mock

This library emulates ioredis by performing all operations in-memory.

MIT
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis