This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(jest): setup jest and add test for lmdbkvstore
- Loading branch information
dtfiedler
committed
Mar 22, 2024
1 parent
90a88a4
commit ceca751
Showing
4 changed files
with
1,679 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"extensionsToTreatAsEsm": [".ts"], | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1" | ||
}, | ||
"transform": { | ||
"^.+\\.m?[tj]sx?$": [ | ||
"ts-jest", | ||
{ | ||
"useESM": true | ||
} | ||
] | ||
}, | ||
"moduleFileExtensions": ["ts", "js", "json", "node"] | ||
} |
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,38 @@ | ||
/** | ||
* AR.IO ArNS Resolver | ||
* Copyright (C) 2023 Permanent Data Solutions, Inc. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { LmdbKVStore } from './lmdb-kv-store.js'; | ||
|
||
describe('LmdbKVStore', () => { | ||
const cache = new LmdbKVStore({ | ||
dbPath: './data/test', | ||
ttlSeconds: 1, | ||
}); | ||
|
||
it('should set and get value', async () => { | ||
await cache.set('test', Buffer.from('hello')); | ||
const value = await cache.get('test'); | ||
expect(value).toEqual(Buffer.from('hello')); | ||
}); | ||
|
||
it('should remove a value once ttl has expired', async () => { | ||
await cache.set('expire', Buffer.from('hello')); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
const value = await cache.get('expire'); | ||
expect(value).toBeUndefined(); | ||
}); | ||
}); |
Oops, something went wrong.