Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test and add_command alias original and special char commands tweaked code spacing
- Loading branch information
1 parent
4f7f1ad
commit 0437aa4
Showing
3 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'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(); | ||
}); |