1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-01 16:46:54 +03:00
Files
node-redis/test/commands/script.spec.js
Ruben Bridgewater 2b4ab10305 chore - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version.
Instead, use the airbnb default with a couple of modifications.

All required changes are included.
2017-11-28 21:38:21 -02:00

44 lines
1.2 KiB
JavaScript

'use strict'
const config = require('../lib/config')
const crypto = require('crypto')
const helper = require('../helper')
const { redis } = config
describe('The \'script\' method', () => {
helper.allTests((ip, args) => {
const command = 'return 99'
const commandSha = crypto.createHash('sha1').update(command).digest('hex')
describe(`using ${ip}`, () => {
let client
beforeEach(() => {
client = redis.createClient.apply(null, args)
return client.flushdb()
})
afterEach(() => {
client.end(true)
})
it('loads script with client.script(\'load\')', () => {
return client.script('load', command).then(helper.isString(commandSha))
})
it('allows a loaded script to be evaluated', () => {
return client.evalsha(commandSha, 0).then(helper.isNumber(99))
})
it('allows a script to be loaded as part of a chained transaction', () => {
return client.multi().script('load', command).exec(helper.isDeepEqual([commandSha]))
})
it('allows a script to be loaded using a transaction\'s array syntax', () => {
return client.multi([['script', 'load', command]]).exec(helper.isDeepEqual([commandSha]))
})
})
})
})