diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86a3a5fb3..a800723dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,3 +39,6 @@ jobs: run: | yarn --frozen-lockfile --ignore-engines yarn test + + - name: E2E test generated jest.js mock + run: yarn test:jest.js diff --git a/.gitignore b/.gitignore index 55c66f699..1ba876a01 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ junit lib node_modules npm-debug.log - +jest.js package-lock.json npm-debug.log* yarn-debug.log* diff --git a/.prettierignore b/.prettierignore index 806deec4e..e4ab766a5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,4 +3,5 @@ package-lock.json lib .nyc_output coverage -junit \ No newline at end of file +junit +jest.js \ No newline at end of file diff --git a/jest.config.jest.js b/jest.config.jest.js new file mode 100644 index 000000000..3f3a856b5 --- /dev/null +++ b/jest.config.jest.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = { + ...require('./jest.config'), + setupFiles: ['/testSetupJest.js'], +}; diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..986418cf4 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + testRunner: 'jest-circus/runner', + testMatch: ['**/test/**/*.js'], + coverageDirectory: 'coverage', + setupFiles: ['/testSetupBabel.js'], +}; diff --git a/package.json b/package.json index 9b9e805d9..76f55fae6 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "main": "./lib", "files": [ "example.js", + "jest.js", "lib/" ], "scripts": { @@ -22,9 +23,13 @@ "coverage": "yarn test --coverage", "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", "lint": "eslint .", - "prepublishOnly": "npx rimraf lib && npx mkdirp lib && babel src --out-dir lib", + "build:babel": "npx rimraf lib && npx mkdirp lib && babel src --out-dir lib", + "build:jest": "esbuild src/index.js --bundle --external:cluster-key-slot --external:debug --external:denque --external:lodash.defaults --external:lodash.flatten --external:p-map --external:redis-commands --external:redis-errors --external:redis-parser --external:array-from --external:es6-map --external:es6-set --external:fengari --external:fengari-interop --external:lodash --external:minimatch --external:standard-as-callback --outfile=jest.js --platform=node --target=node10", + "prepublishOnly": "yarn build:babel && yarn build:jest", "semantic-release": "semantic-release pre && npm publish && semantic-release post", "test": "jest", + "pretest:jest.js": "yarn build:jest", + "test:jest.js": "jest --config jest.config.jest.js", "update-compat": "node scripts/update-compat && git add compat.md README.md && git commit --quiet -m \"docs: Update feature compat table\" &> /dev/null || true" }, "dependencies": { @@ -50,6 +55,7 @@ "chance": "^1.1.7", "codeclimate-test-reporter": "^0.5.1", "coveralls": "^3.1.0", + "esbuild": "^0.9.6", "eslint": "^7.13.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-prettier": "^8.0.0", @@ -93,13 +99,6 @@ "pre-commit": "lint-staged" } }, - "jest": { - "testRunner": "jest-circus/runner", - "testMatch": [ - "**/test/**/*.js" - ], - "coverageDirectory": "coverage" - }, "lint-staged": { "*.js": [ "eslint --fix", diff --git a/renovate.json b/renovate.json index 28221a1e0..f5c7507d1 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,3 @@ { - "extends": [ - "github>stipsan/renovate-presets:auto" - ] + "extends": ["github>stipsan/renovate-presets:auto"] } diff --git a/src/commands/hset.js b/src/commands/hset.js index 910f2522c..86534fc16 100644 --- a/src/commands/hset.js +++ b/src/commands/hset.js @@ -7,8 +7,8 @@ export function hset(key, ...keyValuePairs) { let reply = 0; for (let i = 0; i < keyValuePairs.length; i += 2) { - const field = keyValuePairs[i] - const value = keyValuePairs[i + 1] + const field = keyValuePairs[i]; + const value = keyValuePairs[i + 1]; if (!{}.hasOwnProperty.call(hash, field)) { reply++; diff --git a/src/commands/linsert.js b/src/commands/linsert.js index f53361732..39c1ba016 100644 --- a/src/commands/linsert.js +++ b/src/commands/linsert.js @@ -19,7 +19,7 @@ export function linsert(key, position, pivot, element) { ); } list.splice(elementIndex, 0, element); - const {length} = list; + const { length } = list; this.data.set(key, list); return length; } diff --git a/test/commands/append.js b/test/commands/append.js index c83a87ebf..aca9f2f97 100644 --- a/test/commands/append.js +++ b/test/commands/append.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('append', () => { it('should append to exiting string and return new length', () => { diff --git a/test/commands/auth.js b/test/commands/auth.js index 7eef69037..76d3b130b 100644 --- a/test/commands/auth.js +++ b/test/commands/auth.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('auth', () => { it('should return OK', () => { diff --git a/test/commands/bgrewriteaof.js b/test/commands/bgrewriteaof.js index 32cdd6278..cacc89bae 100644 --- a/test/commands/bgrewriteaof.js +++ b/test/commands/bgrewriteaof.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('bgrewriteaof', () => { it('should return OK', () => { diff --git a/test/commands/bgsave.js b/test/commands/bgsave.js index e3569ac5e..745f931f6 100644 --- a/test/commands/bgsave.js +++ b/test/commands/bgsave.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('bgsave', () => { it('should return OK', () => { diff --git a/test/commands/brpoplpush.js b/test/commands/brpoplpush.js index 4cd0523d6..4ce73358e 100644 --- a/test/commands/brpoplpush.js +++ b/test/commands/brpoplpush.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('brpoplpush', () => { it('should remove one item from the tail of the source list', () => { diff --git a/test/commands/brpoplpushBuffer.js b/test/commands/brpoplpushBuffer.js index 8f2bb2b3d..4c2adbd5f 100644 --- a/test/commands/brpoplpushBuffer.js +++ b/test/commands/brpoplpushBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('brpoplpushBuffer', () => { it('should remove one item from the tail of the source list', () => { diff --git a/test/commands/connect.js b/test/commands/connect.js index a73a1abb3..23ae2a256 100644 --- a/test/commands/connect.js +++ b/test/commands/connect.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('connect', () => { it('should throw if redis has already connected in ctor', (done) => { diff --git a/test/commands/dbsize.js b/test/commands/dbsize.js index 47b80f93a..aa4c7800d 100644 --- a/test/commands/dbsize.js +++ b/test/commands/dbsize.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('dbsize', () => { it('should return how many keys exists in db', () => { diff --git a/test/commands/decr.js b/test/commands/decr.js index bbef4ece1..b17f6a91d 100644 --- a/test/commands/decr.js +++ b/test/commands/decr.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('decr', () => { it('should decrement an integer', () => { diff --git a/test/commands/decrby.js b/test/commands/decrby.js index 3b5b0020f..8ae012589 100644 --- a/test/commands/decrby.js +++ b/test/commands/decrby.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('decrby', () => { it('should decrement an integer with passed decrement', () => { diff --git a/test/commands/defineCommand.js b/test/commands/defineCommand.js index cc479fa24..7e1677108 100644 --- a/test/commands/defineCommand.js +++ b/test/commands/defineCommand.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; import { init, dispose } from '../../src/lua'; describe('defineCommand', () => { diff --git a/test/commands/del.js b/test/commands/del.js index f373ffd00..0a567c980 100644 --- a/test/commands/del.js +++ b/test/commands/del.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('del', () => { const redis = new MockRedis({ diff --git a/test/commands/discard.js b/test/commands/discard.js index 6027b4efc..291241fa0 100644 --- a/test/commands/discard.js +++ b/test/commands/discard.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('discard', () => { it('should discard any batch queue ', () => { diff --git a/test/commands/echo.js b/test/commands/echo.js index 7d27f2d9a..86bbdcab1 100644 --- a/test/commands/echo.js +++ b/test/commands/echo.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('echo', () => { it('should return message', () => { diff --git a/test/commands/eval.js b/test/commands/eval.js index 2ee1f9ea3..2d3365cdc 100644 --- a/test/commands/eval.js +++ b/test/commands/eval.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('eval', () => { it('should execute a lua script through eval and get the return value', () => { diff --git a/test/commands/exists.js b/test/commands/exists.js index e726d2854..451b3709d 100644 --- a/test/commands/exists.js +++ b/test/commands/exists.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('exists', () => { const redis = new MockRedis({ diff --git a/test/commands/expire.js b/test/commands/expire.js index 2cc658c47..876f99bcd 100644 --- a/test/commands/expire.js +++ b/test/commands/expire.js @@ -1,6 +1,6 @@ import Promise from 'bluebird'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('expire', () => { it('should delete key on get', () => { diff --git a/test/commands/expireat.js b/test/commands/expireat.js index b84d3f4ec..6d2e4a269 100644 --- a/test/commands/expireat.js +++ b/test/commands/expireat.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('expireat', () => { it('should set expire status on key', () => { diff --git a/test/commands/flushall.js b/test/commands/flushall.js index 8ca6bfa1f..b38d99335 100644 --- a/test/commands/flushall.js +++ b/test/commands/flushall.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('flushall', () => { const redis = new MockRedis({ diff --git a/test/commands/flushdb.js b/test/commands/flushdb.js index c6110893f..2f75d9e42 100644 --- a/test/commands/flushdb.js +++ b/test/commands/flushdb.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('flushdb', () => { const redis = new MockRedis({ diff --git a/test/commands/get.js b/test/commands/get.js index 85e4d3009..a59834193 100644 --- a/test/commands/get.js +++ b/test/commands/get.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('get', () => { it('should return null on keys that do not exist', () => { diff --git a/test/commands/getBuffer.js b/test/commands/getBuffer.js index eb166155d..ab8842603 100644 --- a/test/commands/getBuffer.js +++ b/test/commands/getBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('getBuffer', () => { it('should return null on keys that do not exist', () => { diff --git a/test/commands/getbit.js b/test/commands/getbit.js index 207c6ead4..a789e5743 100644 --- a/test/commands/getbit.js +++ b/test/commands/getbit.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('getbit', () => { it('should return 0 on keys that do not exist', () => { diff --git a/test/commands/getrange.js b/test/commands/getrange.js index 618e6942d..7b1c1f4fe 100644 --- a/test/commands/getrange.js +++ b/test/commands/getrange.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('getrange', () => { const redis = new MockRedis({ diff --git a/test/commands/getset.js b/test/commands/getset.js index 23e0d893c..a03a20a40 100644 --- a/test/commands/getset.js +++ b/test/commands/getset.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('getset', () => { it('should set the new value and return the old value', () => { diff --git a/test/commands/hdel.js b/test/commands/hdel.js index b35c780a6..e7bac72a3 100644 --- a/test/commands/hdel.js +++ b/test/commands/hdel.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hdel', () => { const redis = new MockRedis({ diff --git a/test/commands/hexists.js b/test/commands/hexists.js index 815f92d00..c126e940a 100644 --- a/test/commands/hexists.js +++ b/test/commands/hexists.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hexists', () => { describe('hash exists', () => { diff --git a/test/commands/hget.js b/test/commands/hget.js index b9959c5df..86e939db8 100644 --- a/test/commands/hget.js +++ b/test/commands/hget.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hget', () => { it('should fetch a property in a hash', () => { diff --git a/test/commands/hgetBuffer.js b/test/commands/hgetBuffer.js index 91047bac1..36804903e 100644 --- a/test/commands/hgetBuffer.js +++ b/test/commands/hgetBuffer.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; import createBuffer from '../../src/buffer'; describe('hgetBuffer', () => { diff --git a/test/commands/hgetall.js b/test/commands/hgetall.js index 3f12a4ae9..03ad885df 100644 --- a/test/commands/hgetall.js +++ b/test/commands/hgetall.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hgetall', () => { it('should return all the keys and values in a hash map', () => { diff --git a/test/commands/hgetallBuffer.js b/test/commands/hgetallBuffer.js index 4673069d9..0d04ef8c8 100644 --- a/test/commands/hgetallBuffer.js +++ b/test/commands/hgetallBuffer.js @@ -1,6 +1,6 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hgetallBuffer', () => { it('should return all the keys and values in a hash map as buffer', () => { diff --git a/test/commands/hincrby.js b/test/commands/hincrby.js index 1390873f2..8308bdcb9 100644 --- a/test/commands/hincrby.js +++ b/test/commands/hincrby.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hincrby', () => { it('should increment an integer with passed increment in hash', () => { diff --git a/test/commands/hincrbyfloat.js b/test/commands/hincrbyfloat.js index f4afe94b9..ffe1104b5 100644 --- a/test/commands/hincrbyfloat.js +++ b/test/commands/hincrbyfloat.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hincrbyfloat', () => { it('should increment an float with passed increment', () => { diff --git a/test/commands/hkeys.js b/test/commands/hkeys.js index 147eeb134..6bfd596d4 100644 --- a/test/commands/hkeys.js +++ b/test/commands/hkeys.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hkeys', () => { it('should return an empty array if there are no keys', () => { diff --git a/test/commands/hlen.js b/test/commands/hlen.js index 571fea543..18bde9824 100644 --- a/test/commands/hlen.js +++ b/test/commands/hlen.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hlen', () => { it('should return an empty array if there are no keys', () => { diff --git a/test/commands/hmget.js b/test/commands/hmget.js index 521fffdac..c7c8b4fef 100644 --- a/test/commands/hmget.js +++ b/test/commands/hmget.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hmget', () => { it('should return the values of specified keys in a hash map', () => { diff --git a/test/commands/hmgetBuffer.js b/test/commands/hmgetBuffer.js index eec18b737..35dfbd1f1 100644 --- a/test/commands/hmgetBuffer.js +++ b/test/commands/hmgetBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hmgetBuffer', () => { it('should return the values as buffers of specified keys in a hash map', () => { diff --git a/test/commands/hmset.js b/test/commands/hmset.js index ac797e0aa..83beb0d87 100644 --- a/test/commands/hmset.js +++ b/test/commands/hmset.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hmset', () => { it('should let you set multiple hash map keys and values in a single command', () => { diff --git a/test/commands/hscan.js b/test/commands/hscan.js index a81e6729b..568fb23dd 100644 --- a/test/commands/hscan.js +++ b/test/commands/hscan.js @@ -1,5 +1,5 @@ import Chance from 'chance'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; const chance = new Chance(); diff --git a/test/commands/hscanStream.js b/test/commands/hscanStream.js index 1cbf0efb7..080446ce8 100644 --- a/test/commands/hscanStream.js +++ b/test/commands/hscanStream.js @@ -1,7 +1,7 @@ import { ObjectWritableMock } from 'stream-mock'; import Chance from 'chance'; import _ from 'lodash'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; const chance = new Chance(); diff --git a/test/commands/hset.js b/test/commands/hset.js index 56c78224f..db1ae912f 100644 --- a/test/commands/hset.js +++ b/test/commands/hset.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hset', () => { const redis = new MockRedis(); diff --git a/test/commands/hsetnx.js b/test/commands/hsetnx.js index 4309eb866..a20a728f4 100644 --- a/test/commands/hsetnx.js +++ b/test/commands/hsetnx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hsetnx', () => { it('should set a key in a hash map if it does not exist already', () => { diff --git a/test/commands/hstrlen.js b/test/commands/hstrlen.js index 705242d13..0f0e9abd3 100644 --- a/test/commands/hstrlen.js +++ b/test/commands/hstrlen.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hstrlen', () => { it('should return 0 on keys that do not exist', () => { diff --git a/test/commands/hvals.js b/test/commands/hvals.js index bd852518d..6c764471f 100644 --- a/test/commands/hvals.js +++ b/test/commands/hvals.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('hvals', () => { it('should return an array over all the values in a hash map', () => { diff --git a/test/commands/incr.js b/test/commands/incr.js index be5b1af18..700464fe0 100644 --- a/test/commands/incr.js +++ b/test/commands/incr.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('incr', () => { it('should increment an integer', () => { diff --git a/test/commands/incrby.js b/test/commands/incrby.js index ac0dd95dc..e30528641 100644 --- a/test/commands/incrby.js +++ b/test/commands/incrby.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('incrby', () => { it('should initialize the key with 0 if there is no key', () => { diff --git a/test/commands/incrbyfloat.js b/test/commands/incrbyfloat.js index 93887c50e..f58067ae0 100644 --- a/test/commands/incrbyfloat.js +++ b/test/commands/incrbyfloat.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('incrbyfloat', () => { it('should initialize the key with 0 if there is no key', () => { diff --git a/test/commands/info.js b/test/commands/info.js index 42e81e4d1..43f1537b4 100644 --- a/test/commands/info.js +++ b/test/commands/info.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('info', () => { it('should return the specific info', () => { diff --git a/test/commands/keys.js b/test/commands/keys.js index 8325a46d8..12e88a140 100644 --- a/test/commands/keys.js +++ b/test/commands/keys.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('keys', () => { it('should return an empty array if there are no keys', () => { diff --git a/test/commands/lastsave.js b/test/commands/lastsave.js index 5272c7a59..1186b280d 100644 --- a/test/commands/lastsave.js +++ b/test/commands/lastsave.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lastsave', () => { it('should return unix time since last save', () => { diff --git a/test/commands/lindex.js b/test/commands/lindex.js index a038fadaf..f8b2991ec 100644 --- a/test/commands/lindex.js +++ b/test/commands/lindex.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lindex', () => { it('should return item list', () => { diff --git a/test/commands/linsert.js b/test/commands/linsert.js index df371b9df..95a8a77ba 100644 --- a/test/commands/linsert.js +++ b/test/commands/linsert.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('linsert', () => { it('should add the value to the list at the correct position', () => { diff --git a/test/commands/llen.js b/test/commands/llen.js index e19208b92..240eaa7b7 100644 --- a/test/commands/llen.js +++ b/test/commands/llen.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('llen', () => { it('should return the number of items in the list', () => { diff --git a/test/commands/lpop.js b/test/commands/lpop.js index de2efe26e..ecd6c0410 100644 --- a/test/commands/lpop.js +++ b/test/commands/lpop.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lpop', () => { it('should remove and return first element of list', () => { diff --git a/test/commands/lpopBuffer.js b/test/commands/lpopBuffer.js index 768bdf869..49615e581 100644 --- a/test/commands/lpopBuffer.js +++ b/test/commands/lpopBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lpopBuffer', () => { it('should remove and return first element of list', () => { diff --git a/test/commands/lpush.js b/test/commands/lpush.js index 1d28ccc3f..83c409d28 100644 --- a/test/commands/lpush.js +++ b/test/commands/lpush.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lpush', () => { it('should add the values to the list in the correct order', () => { diff --git a/test/commands/lpushx.js b/test/commands/lpushx.js index f522b5a15..1321eb756 100644 --- a/test/commands/lpushx.js +++ b/test/commands/lpushx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lpushx', () => { it('should add the values to the list in the correct order', () => { diff --git a/test/commands/lrange.js b/test/commands/lrange.js index aa1270a7b..cf420d8eb 100644 --- a/test/commands/lrange.js +++ b/test/commands/lrange.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lrange', () => { it('should return first 3 items', () => { diff --git a/test/commands/lrem.js b/test/commands/lrem.js index 9f3dbf1c4..2157b96a2 100644 --- a/test/commands/lrem.js +++ b/test/commands/lrem.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lrem', () => { it('should remove the items from the end of the list when count is negative', () => { diff --git a/test/commands/lset.js b/test/commands/lset.js index 74178e941..f99854ae5 100644 --- a/test/commands/lset.js +++ b/test/commands/lset.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('lset', () => { it('should set the list element at index to value', () => { diff --git a/test/commands/ltrim.js b/test/commands/ltrim.js index 188052c0f..7326646cb 100644 --- a/test/commands/ltrim.js +++ b/test/commands/ltrim.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('ltrim', () => { it('should return first 3 items', () => { diff --git a/test/commands/mget.js b/test/commands/mget.js index 85e34b22d..8a04551d6 100644 --- a/test/commands/mget.js +++ b/test/commands/mget.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('mget', () => { it('should return null on keys that do not exist', () => { diff --git a/test/commands/mset.js b/test/commands/mset.js index 141e956fa..09e86c16e 100644 --- a/test/commands/mset.js +++ b/test/commands/mset.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('mset', () => { it('should batch set values', () => { diff --git a/test/commands/msetnx.js b/test/commands/msetnx.js index c2eab8fb3..e27fd0328 100644 --- a/test/commands/msetnx.js +++ b/test/commands/msetnx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('msetnx', () => { it('should batch set values', () => { diff --git a/test/commands/persist.js b/test/commands/persist.js index 7a64c7bdb..380e2dfd6 100644 --- a/test/commands/persist.js +++ b/test/commands/persist.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('persist', () => { it('should remove expire status on key', () => { diff --git a/test/commands/pexpire.js b/test/commands/pexpire.js index e69b669ad..1125c38ac 100644 --- a/test/commands/pexpire.js +++ b/test/commands/pexpire.js @@ -1,6 +1,6 @@ import Promise from 'bluebird'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('pexpire', () => { it('should set expire status on key', () => { diff --git a/test/commands/pexpireat.js b/test/commands/pexpireat.js index d00221066..f834f84b8 100644 --- a/test/commands/pexpireat.js +++ b/test/commands/pexpireat.js @@ -1,6 +1,6 @@ import Promise from 'bluebird'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('pexpireat', () => { it('should set expire status on key', () => { diff --git a/test/commands/ping.js b/test/commands/ping.js index c9f991871..5b39076fc 100644 --- a/test/commands/ping.js +++ b/test/commands/ping.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('ping', () => { it('should return PONG', () => { diff --git a/test/commands/psetex.js b/test/commands/psetex.js index 71a16711f..3a0cf6337 100644 --- a/test/commands/psetex.js +++ b/test/commands/psetex.js @@ -1,6 +1,6 @@ import Promise from 'bluebird'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('psetex', () => { it('should set value and expire', () => { diff --git a/test/commands/psubscribe.js b/test/commands/psubscribe.js index 85cf8045e..f9da89d34 100644 --- a/test/commands/psubscribe.js +++ b/test/commands/psubscribe.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('psubscribe', () => { it('should return number of subscribed channels', () => { diff --git a/test/commands/pttl.js b/test/commands/pttl.js index a6b939ccb..29dd83096 100644 --- a/test/commands/pttl.js +++ b/test/commands/pttl.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('pttl', () => { it('should return -2 if key does not exist', () => { diff --git a/test/commands/publish.js b/test/commands/publish.js index 2c000c06a..f69522217 100644 --- a/test/commands/publish.js +++ b/test/commands/publish.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('publish', () => { it('should return 0 when publishing without subscribers', () => { diff --git a/test/commands/punsubscribe.js b/test/commands/punsubscribe.js index fbedb119f..a1cddb70c 100644 --- a/test/commands/punsubscribe.js +++ b/test/commands/punsubscribe.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('punsubscribe', () => { it('should return 0 when no arguments are given', () => { diff --git a/test/commands/quit.js b/test/commands/quit.js index 702c78c64..0e74cbdd2 100644 --- a/test/commands/quit.js +++ b/test/commands/quit.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('quit', () => { const redis = new MockRedis(); diff --git a/test/commands/randomkey.js b/test/commands/randomkey.js index b1c72d4a2..e95fd38ed 100644 --- a/test/commands/randomkey.js +++ b/test/commands/randomkey.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('randomkey', () => { it('should return a random key', () => { diff --git a/test/commands/rename.js b/test/commands/rename.js index a5b4a9a71..d82eaedb1 100644 --- a/test/commands/rename.js +++ b/test/commands/rename.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rename', () => { it('should rename a key to newkey', () => { diff --git a/test/commands/renamenx.js b/test/commands/renamenx.js index b868a7560..f6739865a 100644 --- a/test/commands/renamenx.js +++ b/test/commands/renamenx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('renamenx', () => { it('should return integer 1 on key rename', () => { diff --git a/test/commands/role.js b/test/commands/role.js index 1159b36fd..82f65ef40 100644 --- a/test/commands/role.js +++ b/test/commands/role.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('role', () => { it('should return role info on the current redis instance', () => { diff --git a/test/commands/rpop.js b/test/commands/rpop.js index 75416fe87..37f647066 100644 --- a/test/commands/rpop.js +++ b/test/commands/rpop.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpop', () => { it('should remove and return last element of list', () => { diff --git a/test/commands/rpopBuffer.js b/test/commands/rpopBuffer.js index 297c445c0..8b55930da 100644 --- a/test/commands/rpopBuffer.js +++ b/test/commands/rpopBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpopBuffer', () => { it('should remove and return last element of list', () => { diff --git a/test/commands/rpoplpush.js b/test/commands/rpoplpush.js index 297d781c7..bbabdc394 100644 --- a/test/commands/rpoplpush.js +++ b/test/commands/rpoplpush.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpoplpush', () => { it('should remove one item from the tail of the source list', () => { diff --git a/test/commands/rpoplpushBuffer.js b/test/commands/rpoplpushBuffer.js index 42ab8e6b4..14401352e 100644 --- a/test/commands/rpoplpushBuffer.js +++ b/test/commands/rpoplpushBuffer.js @@ -1,5 +1,5 @@ import createBuffer from '../../src/buffer'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpoplpushBuffer', () => { it('should remove one item from the tail of the source list', () => { diff --git a/test/commands/rpush.js b/test/commands/rpush.js index 1299927ca..bc01b42b4 100644 --- a/test/commands/rpush.js +++ b/test/commands/rpush.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpush', () => { it('should add the values to the list in the correct order', () => { diff --git a/test/commands/rpushx.js b/test/commands/rpushx.js index b22ecf310..d48afd747 100644 --- a/test/commands/rpushx.js +++ b/test/commands/rpushx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('rpushx', () => { it('should add the values to the list in the correct order', () => { diff --git a/test/commands/sadd.js b/test/commands/sadd.js index 7417a191a..0965b1a0f 100644 --- a/test/commands/sadd.js +++ b/test/commands/sadd.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sadd', () => { it('should add 1 item to set', () => { diff --git a/test/commands/save.js b/test/commands/save.js index d9faf58cd..35078caaa 100644 --- a/test/commands/save.js +++ b/test/commands/save.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('save', () => { it('should return OK', () => { diff --git a/test/commands/scan.js b/test/commands/scan.js index ff2ed8b7d..a6610eee1 100644 --- a/test/commands/scan.js +++ b/test/commands/scan.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('scan', () => { it('should return null array if nothing in db', () => { diff --git a/test/commands/scanStream.js b/test/commands/scanStream.js index 958e344b4..d1ed27dd4 100644 --- a/test/commands/scanStream.js +++ b/test/commands/scanStream.js @@ -1,7 +1,7 @@ import { ObjectWritableMock } from 'stream-mock'; import Chance from 'chance'; import _ from 'lodash'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; const chance = new Chance(); diff --git a/test/commands/scard.js b/test/commands/scard.js index 0a894ca36..f67e2e4ef 100644 --- a/test/commands/scard.js +++ b/test/commands/scard.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('scard', () => { it('should return the number of items in the set', () => { diff --git a/test/commands/sdiff.js b/test/commands/sdiff.js index b0898dfd7..107bbdb23 100644 --- a/test/commands/sdiff.js +++ b/test/commands/sdiff.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sdiff', () => { it('should return the difference between the first set and all the successive sets', () => { diff --git a/test/commands/set.js b/test/commands/set.js index e1a449d69..19838ef80 100644 --- a/test/commands/set.js +++ b/test/commands/set.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('set', () => { it('should return OK when setting a hash key', () => { diff --git a/test/commands/setbit.js b/test/commands/setbit.js index bf384bc8d..d3422d566 100644 --- a/test/commands/setbit.js +++ b/test/commands/setbit.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('getbit', () => { it('should return old bit value of key', () => { diff --git a/test/commands/setex.js b/test/commands/setex.js index 793d470b1..f1463f5ab 100644 --- a/test/commands/setex.js +++ b/test/commands/setex.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('setex', () => { it('should set value and expire', () => { diff --git a/test/commands/setnx.js b/test/commands/setnx.js index d7761c249..fff760f00 100644 --- a/test/commands/setnx.js +++ b/test/commands/setnx.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('setnx', () => { it('should set a key with value if it does not exist already', () => { diff --git a/test/commands/sinter.js b/test/commands/sinter.js index 30680580d..3def7a51c 100644 --- a/test/commands/sinter.js +++ b/test/commands/sinter.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sinter', () => { it('should return the members from the intersection of all the given sets', () => { diff --git a/test/commands/sismember.js b/test/commands/sismember.js index 7e0778046..7c3d6a484 100644 --- a/test/commands/sismember.js +++ b/test/commands/sismember.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sismember', () => { it('should check if item exists in set', () => { diff --git a/test/commands/smembers.js b/test/commands/smembers.js index ebb221e6e..521164315 100644 --- a/test/commands/smembers.js +++ b/test/commands/smembers.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('smembers', () => { it('should returns items in set as array', () => { diff --git a/test/commands/smove.js b/test/commands/smove.js index 9e68c53a6..2c9615c23 100644 --- a/test/commands/smove.js +++ b/test/commands/smove.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('smove', () => { it('should move value from source to destination', () => { diff --git a/test/commands/spop.js b/test/commands/spop.js index d3e5371e1..b5a6a7561 100644 --- a/test/commands/spop.js +++ b/test/commands/spop.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('spop', () => { it('should return a random item', () => { diff --git a/test/commands/srandmember.js b/test/commands/srandmember.js index 137af320e..47d9edc96 100644 --- a/test/commands/srandmember.js +++ b/test/commands/srandmember.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('srandmember', () => { it('should return a random item', () => { diff --git a/test/commands/srem.js b/test/commands/srem.js index 9c266c47b..bc7683dfa 100644 --- a/test/commands/srem.js +++ b/test/commands/srem.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('srem', () => { const redis = new MockRedis({ diff --git a/test/commands/sscan.js b/test/commands/sscan.js index b88e92b2e..c9ef66036 100644 --- a/test/commands/sscan.js +++ b/test/commands/sscan.js @@ -1,5 +1,5 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sscan', () => { it('should return null array if set does not exist', () => { diff --git a/test/commands/sscanStream.js b/test/commands/sscanStream.js index f4ac23240..9e8a73382 100644 --- a/test/commands/sscanStream.js +++ b/test/commands/sscanStream.js @@ -2,7 +2,7 @@ import Set from 'es6-set'; import { ObjectWritableMock } from 'stream-mock'; import Chance from 'chance'; import _ from 'lodash'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; const chance = new Chance(); diff --git a/test/commands/strlen.js b/test/commands/strlen.js index 2d751b62d..48a7d1359 100644 --- a/test/commands/strlen.js +++ b/test/commands/strlen.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('strlen', () => { it('should return 0 on keys that do not exist', () => { diff --git a/test/commands/subscribe.js b/test/commands/subscribe.js index 6bd3e332a..9839481e3 100644 --- a/test/commands/subscribe.js +++ b/test/commands/subscribe.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('subscribe', () => { it('should ignore an empty subscribe call', () => { diff --git a/test/commands/sunion.js b/test/commands/sunion.js index 752564dc5..61ec40d1d 100644 --- a/test/commands/sunion.js +++ b/test/commands/sunion.js @@ -1,6 +1,6 @@ import Set from 'es6-set'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('sunion', () => { it('should return the union between the first set and all the successive sets', () => { diff --git a/test/commands/time.js b/test/commands/time.js index d8ce45467..907c9fba8 100644 --- a/test/commands/time.js +++ b/test/commands/time.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('time', () => { it('should return an array with current time in seconds and microseconds', () => { diff --git a/test/commands/ttl.js b/test/commands/ttl.js index 27eb8bff9..bea0b26e8 100644 --- a/test/commands/ttl.js +++ b/test/commands/ttl.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('ttl', () => { it('should return -2 if key does not exist', () => { diff --git a/test/commands/type.js b/test/commands/type.js index 8140b555b..032f0df10 100644 --- a/test/commands/type.js +++ b/test/commands/type.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('type', () => { const redis = new MockRedis(); diff --git a/test/commands/unlink.js b/test/commands/unlink.js index 90f106b79..064d5fef8 100644 --- a/test/commands/unlink.js +++ b/test/commands/unlink.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('unlink', () => { const redis = new MockRedis({ diff --git a/test/commands/unsubscribe.js b/test/commands/unsubscribe.js index 3802360f6..0ec6841b6 100644 --- a/test/commands/unsubscribe.js +++ b/test/commands/unsubscribe.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('unsubscribe', () => { it('should return 0 when no arguments are given', () => { diff --git a/test/commands/xadd.js b/test/commands/xadd.js index 9983f3b7d..2fe34fe39 100644 --- a/test/commands/xadd.js +++ b/test/commands/xadd.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('xadd', () => { it('should add events to a stream', () => { diff --git a/test/commands/xlen.js b/test/commands/xlen.js index 4d5cdc4a7..ce38368d0 100644 --- a/test/commands/xlen.js +++ b/test/commands/xlen.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('xlen', () => { it('should return the number of events in the stream', () => { diff --git a/test/commands/xrange.js b/test/commands/xrange.js index 13499dd57..22d961a8f 100644 --- a/test/commands/xrange.js +++ b/test/commands/xrange.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('xrange', () => { it('returns an empty list on a non existing stream', () => { diff --git a/test/commands/xread.js b/test/commands/xread.js index a8b352b44..0f316bea0 100644 --- a/test/commands/xread.js +++ b/test/commands/xread.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('xread', () => { it('reads a number of events since an id', () => { diff --git a/test/commands/xrevrange.js b/test/commands/xrevrange.js index 8dff5896d..b3c6142b0 100644 --- a/test/commands/xrevrange.js +++ b/test/commands/xrevrange.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('xrevrange', () => { it('returns an empty list on a non existing stream', () => { diff --git a/test/commands/zadd.js b/test/commands/zadd.js index d2cf1b834..ddfe8cfd8 100644 --- a/test/commands/zadd.js +++ b/test/commands/zadd.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zadd', () => { it('should add 1 item to sorted set', () => { diff --git a/test/commands/zcard.js b/test/commands/zcard.js index cc0fcce15..2c5cef330 100644 --- a/test/commands/zcard.js +++ b/test/commands/zcard.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zcard', () => { it('should return the number of items in the sorted set', () => { diff --git a/test/commands/zcount.js b/test/commands/zcount.js index e6f464206..6d9876488 100644 --- a/test/commands/zcount.js +++ b/test/commands/zcount.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zcount', () => { const data = { diff --git a/test/commands/zincrby.js b/test/commands/zincrby.js index c81a56fdf..9dde9e0c8 100644 --- a/test/commands/zincrby.js +++ b/test/commands/zincrby.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zincrby', () => { const data = { diff --git a/test/commands/zinterstore.js b/test/commands/zinterstore.js index b98696f83..67c78d028 100644 --- a/test/commands/zinterstore.js +++ b/test/commands/zinterstore.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zinterstore', () => { const data = { diff --git a/test/commands/zpopmax.js b/test/commands/zpopmax.js index 4684f6cdd..8e98c3889 100644 --- a/test/commands/zpopmax.js +++ b/test/commands/zpopmax.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zpopmax', () => { const data = { diff --git a/test/commands/zpopmin.js b/test/commands/zpopmin.js index c13edc2b1..63e53e93e 100644 --- a/test/commands/zpopmin.js +++ b/test/commands/zpopmin.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zpopmin', () => { const data = { diff --git a/test/commands/zrange.js b/test/commands/zrange.js index f27ba3a4d..2a97ca9c4 100644 --- a/test/commands/zrange.js +++ b/test/commands/zrange.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrange', () => { const data = { diff --git a/test/commands/zrangebyscore.js b/test/commands/zrangebyscore.js index 29d8fb6d9..087a8738c 100644 --- a/test/commands/zrangebyscore.js +++ b/test/commands/zrangebyscore.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrangebyscore', () => { const data = { diff --git a/test/commands/zrank.js b/test/commands/zrank.js index c8ad08291..d059c3783 100644 --- a/test/commands/zrank.js +++ b/test/commands/zrank.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrank', () => { const data = { diff --git a/test/commands/zrem.js b/test/commands/zrem.js index 82b6cedd5..80f1b3164 100644 --- a/test/commands/zrem.js +++ b/test/commands/zrem.js @@ -1,4 +1,4 @@ -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrem', () => { const data = { diff --git a/test/commands/zremrangebyrank.js b/test/commands/zremrangebyrank.js index 47664608c..310ff8dc3 100644 --- a/test/commands/zremrangebyrank.js +++ b/test/commands/zremrangebyrank.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zremrangebyrank', () => { const data = { diff --git a/test/commands/zremrangebyscore.js b/test/commands/zremrangebyscore.js index c1c935742..573212e76 100644 --- a/test/commands/zremrangebyscore.js +++ b/test/commands/zremrangebyscore.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zremrangebyscore', () => { const data = { diff --git a/test/commands/zrevrange.js b/test/commands/zrevrange.js index 04c30b1de..f2a4dcaeb 100644 --- a/test/commands/zrevrange.js +++ b/test/commands/zrevrange.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrevrange', () => { const data = { diff --git a/test/commands/zrevrangebyscore.js b/test/commands/zrevrangebyscore.js index e1ae2d0a2..ac7a04b4a 100644 --- a/test/commands/zrevrangebyscore.js +++ b/test/commands/zrevrangebyscore.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrevrangebyscore', () => { const data = { diff --git a/test/commands/zrevrank.js b/test/commands/zrevrank.js index 48f82307b..9f333c1fc 100644 --- a/test/commands/zrevrank.js +++ b/test/commands/zrevrank.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zrevrank', () => { const data = { diff --git a/test/commands/zscan.js b/test/commands/zscan.js index 2ec71f176..3b7bf0784 100644 --- a/test/commands/zscan.js +++ b/test/commands/zscan.js @@ -1,5 +1,5 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zscan', () => { function createMap(keys) { diff --git a/test/commands/zscanStream.js b/test/commands/zscanStream.js index f0a0f59c8..b0604cf25 100644 --- a/test/commands/zscanStream.js +++ b/test/commands/zscanStream.js @@ -2,7 +2,7 @@ import Map from 'es6-map'; import { ObjectWritableMock } from 'stream-mock'; import Chance from 'chance'; import _ from 'lodash'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; const chance = new Chance(); diff --git a/test/commands/zscore.js b/test/commands/zscore.js index dded0c185..c2c2cb3ae 100644 --- a/test/commands/zscore.js +++ b/test/commands/zscore.js @@ -1,6 +1,6 @@ import Map from 'es6-map'; -import MockRedis from '../../src'; +import MockRedis from 'ioredis'; describe('zscore', () => { const data = { diff --git a/test/disconnect.js b/test/disconnect.js index bbb06a723..4c30b3b86 100644 --- a/test/disconnect.js +++ b/test/disconnect.js @@ -1,4 +1,4 @@ -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('disconnect', () => { it('should be available, but do nothing', () => { diff --git a/test/events.js b/test/events.js index c3a32de2d..2db6cd97e 100644 --- a/test/events.js +++ b/test/events.js @@ -1,4 +1,4 @@ -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('events', () => { it('should trigger ready and connect events on instantiation', (done) => { diff --git a/test/exec.js b/test/exec.js index 66054f6eb..f70fa4d14 100644 --- a/test/exec.js +++ b/test/exec.js @@ -1,4 +1,4 @@ -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('exec', () => { it('should resolve Promise.all after all operations is done', () => { diff --git a/test/keyprefix.js b/test/keyprefix.js index d03568f86..a38fed0d9 100644 --- a/test/keyprefix.js +++ b/test/keyprefix.js @@ -2,7 +2,7 @@ import Set from 'es6-set'; import { ObjectWritableMock } from 'stream-mock'; import Chance from 'chance'; import _ from 'lodash'; -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('keyprefix', () => { let writable; diff --git a/test/keyspace-notifications.js b/test/keyspace-notifications.js index 7a4312e81..60e05615f 100644 --- a/test/keyspace-notifications.js +++ b/test/keyspace-notifications.js @@ -1,5 +1,5 @@ import parseKeyspaceEvents from '../src/keyspace-notifications'; -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('parseKeyspaceEvents', () => { it('should interpret an empty string as all notifications disabled', () => { diff --git a/test/multi.js b/test/multi.js index 7e6a82ffb..28d459255 100644 --- a/test/multi.js +++ b/test/multi.js @@ -1,4 +1,4 @@ -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('multi', () => { it('should setup a batch queue that can be passed to exec', () => { diff --git a/test/multiple-mocks.js b/test/multiple-mocks.js index 984a828a0..35d5bc398 100644 --- a/test/multiple-mocks.js +++ b/test/multiple-mocks.js @@ -1,4 +1,4 @@ -import MockRedis from '../src'; +import MockRedis from 'ioredis'; describe('multipleMocks', () => { it('should be possible to create a second IORedis client, which is working on shared data with the first client', () => { diff --git a/test/promises.js b/test/promises.js index 0a20fd39b..5e3421bbe 100644 --- a/test/promises.js +++ b/test/promises.js @@ -1,6 +1,6 @@ import bluebird from 'bluebird'; -import MockRedis from '../src'; +import MockRedis from 'ioredis'; const nativePromise = global.Promise; diff --git a/testSetupBabel.js b/testSetupBabel.js new file mode 100644 index 000000000..614448299 --- /dev/null +++ b/testSetupBabel.js @@ -0,0 +1,14 @@ +'use strict'; + +// Redirects 'ioredis' imports to the src files and lets babel-jest transpile them as needed + +jest.mock('ioredis', () => { + const { Command } = jest.requireActual('ioredis'); + const RedisMock = jest.requireActual('./src/index'); + + return { + __esModule: true, + Command, + default: RedisMock, + }; +}); diff --git a/testSetupJest.js b/testSetupJest.js new file mode 100644 index 000000000..517c5fe4b --- /dev/null +++ b/testSetupJest.js @@ -0,0 +1,9 @@ +'use strict'; + +// Redirects 'ioredis' imports to the compiled jest.js file that inlines the Command API from 'ioredis' + +jest.mock('ioredis', () => { + const Redis = jest.requireActual('./jest'); + + return Redis; +}); diff --git a/yarn.lock b/yarn.lock index 23650c548..47aca8ad5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2336,6 +2336,11 @@ es6-symbol@^3.1.1, es6-symbol@~3.1.1, es6-symbol@~3.1.3: d "^1.0.1" ext "^1.1.2" +esbuild@^0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.9.6.tgz#2cae519e7ce2328ecf57ae738090d07ce7245850" + integrity sha512-F6vASxU0wT/Davt9aj2qtDwDNSkQxh9VbyO56M7PDWD+D/Vgq/rmUDGDQo7te76W5auauVojjnQr/wTu3vpaUA== + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"