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.
feat: add unlink command (stipsan#747)
- Loading branch information
1 parent
3b36191
commit 6ef180a
Showing
4 changed files
with
28 additions
and
0 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,6 @@ | ||
import { del } from './del'; | ||
|
||
export function unlink(...keys) { | ||
const removeKeys = del.bind(this); | ||
return removeKeys(...keys); | ||
} |
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,20 @@ | ||
import expect from 'expect'; | ||
|
||
import MockRedis from '../../src'; | ||
|
||
describe('unlink', () => { | ||
const redis = new MockRedis({ | ||
data: { | ||
unlinkme: 'please', | ||
metoo: 'pretty please', | ||
}, | ||
}); | ||
it('should unlink/delete passed in keys', () => | ||
redis | ||
.unlink('unlinkme', 'metoo') | ||
.then(status => expect(status).toBe(2)) | ||
.then(() => expect(redis.data.has('unlinkme')).toBe(false)) | ||
.then(() => expect(redis.data.has('metoo')).toBe(false))); | ||
it('should return the number of keys unlinked', () => | ||
redis.unlink('deleteme', 'metoo').then(status => expect(status).toBe(0))); | ||
}); |