1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00
Files
node-redis/test/commands/addCommand.spec.js
Kyle Davis 0437aa4985 enabled adding abritary commands
added test and add_command alias

original and special char commands

tweaked code spacing
2017-08-01 00:10:23 -03:00

37 lines
1.3 KiB
JavaScript

'use strict';
var config = require('../lib/config');
var redis = config.redis;
var assert = require('assert');
describe("The 'addCommand/add_command' method", function () {
var client = redis.createClient();
var testCommands = {
newcommand : 'newcommand',
nonJsSafe : 'really-new.command',
jsSafe : 'really_new_command'
};
it('camel case version exists', function () {
assert.strictEqual(typeof redis.addCommand, 'function');
});
it('snake version exists', function () {
assert.strictEqual(typeof redis.add_command, 'function');
});
it('does not already have the test standard command', function () {
assert.strictEqual(client[testCommands.newcommand], undefined);
});
it('generates a new method for an added command', function () {
redis.addCommand(testCommands.newcommand);
assert.strictEqual(typeof client[testCommands.newcommand], 'function');
});
it('does not already have the test non-JS-safe command', function () {
assert.strictEqual(client[testCommands.nonJsSafe], undefined);
});
it('converts illegal command names to JS-safe functions', function () {
redis.addCommand(testCommands.nonJsSafe);
assert.strictEqual(typeof client[testCommands.jsSafe], 'function');
});
client.quit();
});