forked from stipsan/ioredis-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add renamenx * update preversion script to auto commit compat table updates * chore(compat): update feature table * 1.9.1 * fix quotes * update script * chore(compat): update feature table * 1.10.0
- Loading branch information
Showing
5 changed files
with
41 additions
and
3 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
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,11 @@ | ||
import { rename } from './rename'; | ||
|
||
export function renamenx(key, newKey) { | ||
if ({}.hasOwnProperty.call(this.data, newKey)) { | ||
return '0'; | ||
} | ||
|
||
rename.call(this, key, newKey); | ||
|
||
return '1'; | ||
} |
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,26 @@ | ||
import expect from 'expect'; | ||
|
||
import MockRedis from '../../src'; | ||
|
||
describe('renamenx', () => { | ||
it('should return integer 1 on key rename', () => { | ||
const redis = new MockRedis({ | ||
data: { | ||
foo: 'baz', | ||
}, | ||
}); | ||
return redis.renamenx('foo', 'bar').then(status => expect(status).toBe('1')) | ||
.then(() => expect(redis.data).toEqual({ bar: 'baz' })); | ||
}); | ||
|
||
it('should return integer 0 if new key already exist', () => { | ||
const redis = new MockRedis({ | ||
data: { | ||
foo: 'baz', | ||
bar: 'foobar', | ||
}, | ||
}); | ||
return redis.renamenx('foo', 'bar').then(status => expect(status).toBe('0')) | ||
.then(() => expect(redis.data).toEqual({ foo: 'baz', bar: 'foobar' })); | ||
}); | ||
}); |