How to use the ioredis-mock.default 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
sinon.test(function (done) {
        const client = new RedisMock()
        this.stub(noderedis, 'createClient').returns(client)
        // const spy = this.spy(client, 'set')

        let metadata = {
          foo: 'bar',
          baz: 123
        }

        cache = new Cache({
          directory: { enabled: false, path: './cache', extension: 'json' },
          redis: { enabled: true, host: '127.0.0.1', port: 6379 }
        })
        cache.set('key-string', 'data', { metadata }).then(() => {
          cache.getMetadata('key-string').then(metadata => {
            metadata.should.eql(metadata)
github dadi / cache / test / unit / redis.js View on Github external
sinon.test(function (done) {
        const client = new RedisMock()
        this.stub(noderedis, 'createClient').returns(client)
        const spy = this.spy(client, 'set')

        let metadata = {
          foo: 'bar',
          baz: 123
        }

        cache = new Cache({
          directory: { enabled: false, path: './cache', extension: 'json' },
          redis: { enabled: true, host: '127.0.0.1', port: 6379 }
        })
        cache.set('key-string', 'data', { metadata }).then(() => {
          spy.called.should.eql(true)
          spy.firstCall.args[0].indexOf('key-string').should.be.above(-1)
          spy.secondCall.args[0].should.eql('___key-string___')
github dadi / cache / test / unit / redis.js View on Github external
sinon.test(function (done) {
        const stream = new Stream.Readable()
        stream.push('data')
        stream.push(null)

        const client = new RedisMock()
        this.stub(client, 'exists').yields(null, 1)

        const getRange = this.stub(client, 'getrange')
        getRange
          .withArgs(Buffer.from('key1'), 0, 16383)
          .yields(null, Buffer.from('data'))
        getRange
          .withArgs(Buffer.from('key1'), 16384, 32767)
          .yields(null, Buffer.from(''))

        this.stub(noderedis, 'createClient').returns(client)

        cache = new Cache({
          directory: { enabled: false, path: './cache', extension: 'json' },
          redis: { enabled: true, host: '127.0.0.1', port: 6379 }
        })

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