Skip to content

Commit

Permalink
Test .set(key, value, ttl) sets a value that expires
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed Jul 8, 2017
1 parent 8ea4de1 commit 1f73cf0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"devDependencies": {
"ava": "^0.19.1",
"coveralls": "^2.13.1",
"delay": "^2.0.0",
"eslint-config-xo-lukechilds": "^1.0.0",
"nyc": "^10.3.2",
"xo": "^0.19.0"
Expand Down
9 changes: 9 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava';
import delay from 'delay';
import Keyv from '../';

test('Keyv is a class', t => {
Expand All @@ -21,6 +22,14 @@ test('.set(key, value) resolves to value', async t => {
t.is(await store.set('foo', 'bar'), 'bar');
});

test('.set(key, value, ttl) sets a value that expires', async t => {
const store = new Keyv();
t.is(await store.set('foo', 'bar', 100), 'bar');
t.is(await store.get('foo'), 'bar');
await delay(100);
t.is(await store.get('foo'), undefined);
});

test('.get(key) returns a Promise', t => {
const store = new Keyv();
t.true(store.get('foo') instanceof Promise);
Expand Down

0 comments on commit 1f73cf0

Please sign in to comment.