diff options
| author | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
| commit | f9159ea2d994e14180fb02ab562f0119513e67cf (patch) | |
| tree | 09d14cdf05456567156738b681379d4bccd64e5c /node_modules/node-file-cache/tests | |
| parent | 2020/04/03, 02:42, V1.2.1 (diff) | |
| download | s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.tar.xz s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.zip | |
2020/04/03, 02:47, V1.2.2
Diffstat (limited to 'node_modules/node-file-cache/tests')
| -rw-r--r-- | node_modules/node-file-cache/tests/basic-test.js | 69 | ||||
| -rw-r--r-- | node_modules/node-file-cache/tests/db-test.js | 18 | ||||
| -rw-r--r-- | node_modules/node-file-cache/tests/expire-test.js | 70 |
3 files changed, 0 insertions, 157 deletions
diff --git a/node_modules/node-file-cache/tests/basic-test.js b/node_modules/node-file-cache/tests/basic-test.js deleted file mode 100644 index ea690ef..0000000 --- a/node_modules/node-file-cache/tests/basic-test.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const cache = require('../lib/index').create(); - -// cleanup -cache.clear(); -assert.equal(cache.size(), 0); - -// add record -const item1 = { yo: 'dawg' }; -const key1 = 'mittenz'; -cache.set(key1, item1); - -const result1 = cache.get(key1); -assert.deepEqual(item1, result1); -assert.equal(cache.size(), 1); - -// add same record -cache.set(key1, item1); -assert.deepEqual(item1, result1); -assert.equal(cache.size(), 1); - -// add next record -const item2 = { - foo: 'bar' -}; -const key2 = 'kittenz'; -cache.set(key2, item2); - -const result2 = cache.get(key2); -assert.deepEqual(item2, result2); -assert.equal(cache.size(), 2); - -// add record with tags -const item3 = { - bar: 'baz' -}; -const key3 = 'bat'; -const tags3 = ['bat-3']; -cache.set(key3, item3, { - tags: tags3 -}); - -const result3 = cache.get(key3); -assert.deepEqual(item3, result3); -assert.equal(cache.size(), 3); - -// expire by tags -cache.expire(tags3); -assert.equal(cache.size(), 2); - -// add record with lifespan -const item4 = { - bar: 'baziliero' -}; -const key4 = 'batbaz'; -const span = 1; -cache.set(key4, item4, { - life: span -}); - -setTimeout(() => { - const result4 = cache.get(key4); - assert.equal(result4, null); - assert.equal(cache.size(), 2); -}, 3000); - - diff --git a/node_modules/node-file-cache/tests/db-test.js b/node_modules/node-file-cache/tests/db-test.js deleted file mode 100644 index 8ff01a1..0000000 --- a/node_modules/node-file-cache/tests/db-test.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const cache = require('../lib/index.js').create({ - file: __dirname + '/ga-api-cache.json' -}); - -cache.clear(); -assert.equal(cache.size(), 0); - -cache.set('key', 1, { - life: 3 -}); - -assert.equal(cache.size(), 1); - -assert.equal(cache.get('key'), 1); -setTimeout(() => assert.equal(cache.get('key'), null), 5000);
\ No newline at end of file diff --git a/node_modules/node-file-cache/tests/expire-test.js b/node_modules/node-file-cache/tests/expire-test.js deleted file mode 100644 index 9f39529..0000000 --- a/node_modules/node-file-cache/tests/expire-test.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const cache = require('../lib/index').create(); - -cache.clear(); -assert.equal(cache.size(), 0); - -const items = [ - { - key: 'one', - item: { - name: 'one' - }, - options: {} - }, - { - key: 'two', - item: { - name: 'two' - }, - options: { - tags: [ 'two' ] - } - }, - { - key: 'three', - item: { - name: 'three' - }, - options: { - life: 60 - } - }, - { - key: 'four', - item: { - name: 'four' - }, - options: { - tags: [ 'four' ], - life: -1 - } - } -]; - -items.forEach((item) => { - cache.set(item.key, item.item, item.options); -}); - -assert.equal(cache.size(), items.length); - -// expire by key -cache.expire('one'); -assert.equal(cache.get('one'), null); -assert.equal(cache.size(), items.length - 1); - -// expire by tags -cache.expire(['two']); -assert.equal(cache.get('two'), null); -assert.equal(cache.size(), items.length - 2); - -// expire by callback -cache.expire((record) => record.key === 'three'); -assert.equal(cache.get('three'), null); -assert.equal(cache.size(), items.length - 3); - -// expire by lifespan -assert.equal(cache.get('four'), null); -assert.equal(cache.size(), items.length - 4);
\ No newline at end of file |