Skip to content

Commit

Permalink
Merge f5df018 into fd3c7fc
Browse files Browse the repository at this point in the history
  • Loading branch information
davimacedo authored Feb 20, 2021
2 parents fd3c7fc + f5df018 commit a7b5e27
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions spec/RedisCacheAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ describe_only(() => {
});

it('should expire after ttl', done => {
const cache = new RedisCacheAdapter(null, 50);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 52))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(null))
.then(done);
});

it('should not store value for ttl=0', done => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE, 0)
Expand All @@ -57,20 +57,20 @@ describe_only(() => {
});

it('should not expire when ttl=Infinity', done => {
const cache = new RedisCacheAdapter(null, 1);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE, Infinity)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 5))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(done);
});

it('should fallback to default ttl', done => {
const cache = new RedisCacheAdapter(null, 1);
const cache = new RedisCacheAdapter(null, 100);
let promise = Promise.resolve();

[-100, null, undefined, 'not number', true].forEach(ttl => {
Expand All @@ -79,7 +79,7 @@ describe_only(() => {
.put(KEY, VALUE, ttl)
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(VALUE))
.then(wait.bind(null, 5))
.then(wait.bind(null, 102))
.then(() => cache.get(KEY))
.then(value => expect(value).toEqual(null))
);
Expand All @@ -89,7 +89,7 @@ describe_only(() => {
});

it('should find un-expired records', done => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

cache
.put(KEY, VALUE)
Expand All @@ -102,7 +102,7 @@ describe_only(() => {
});

it('handleShutdown, close connection', async () => {
const cache = new RedisCacheAdapter(null, 5);
const cache = new RedisCacheAdapter(null, 100);

await cache.handleShutdown();
setTimeout(() => {
Expand Down

0 comments on commit a7b5e27

Please sign in to comment.