diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 7af7f35d4d8..25c966c2719 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -2,7 +2,7 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils'; import RedisClient, { RedisClientType } from '.'; import { RedisClientMultiCommandType } from './multi-command'; -import { RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisFunctions, RedisScripts } from '../commands'; +import { RedisCommandRawReply, RedisModules, RedisFunctions, RedisScripts } from '../commands'; import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors'; import { defineScript } from '../lua-script'; import { spy } from 'sinon'; @@ -199,6 +199,18 @@ describe('Client', () => { } }); + testUtils.testWithClient('client.v4.{command} should return a promise', async client => { + assert.equal( + await client.v4.ping(), + 'PONG' + ); + }, { + ...GLOBAL.SERVERS.OPEN, + clientOptions: { + legacyMode: true + } + }); + testUtils.testWithClient('client.{command} should accept vardict arguments', async client => { assert.equal( await promisify(client.set).call(client, 'a', 'b'), diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index 6af572edc6a..b4bf49fc7bc 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -352,7 +352,7 @@ export default class RedisClient< for (const [ name, command ] of Object.entries(COMMANDS as RedisCommands)) { this.#defineLegacyCommand(name, command); - (this as any)[name.toLowerCase()] = (this as any)[name]; + (this as any)[name.toLowerCase()] ??= (this as any)[name]; } // hard coded commands diff --git a/packages/client/lib/client/multi-command.ts b/packages/client/lib/client/multi-command.ts index 4a3b668b758..749ab4c4e0f 100644 --- a/packages/client/lib/client/multi-command.ts +++ b/packages/client/lib/client/multi-command.ts @@ -119,7 +119,7 @@ export default class RedisClientMultiCommand { for (const [ name, command ] of Object.entries(COMMANDS as RedisCommands)) { this.#defineLegacyCommand(name, command); - (this as any)[name.toLowerCase()] = (this as any)[name]; + (this as any)[name.toLowerCase()] ??= (this as any)[name]; } }