-
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.
- 💄 updated README: dropped `2.x`, - set `engines.node`: `>=16.14.0`, and - simplified the description. Signed-off-by: dankeboy36 <[email protected]>
- Loading branch information
1 parent
b42e8ca
commit d792871
Showing
5 changed files
with
68 additions
and
50 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,54 +1,54 @@ | ||
import assert from 'assert'; | ||
import assert from 'node:assert/strict'; | ||
import { InmemoryState } from '../../inmemoryState'; | ||
|
||
describe('inmemoryState', () => { | ||
it('should get a value', async () => { | ||
const state = new InmemoryState(); | ||
await state.update('alma', false); | ||
assert.equal(state.get('alma'), false); | ||
assert.strictEqual(state.get('alma'), false); | ||
}); | ||
|
||
it('should get a value with a default', async () => { | ||
const state = new InmemoryState(); | ||
assert.equal(state.get('alma'), undefined); | ||
assert.equal(state.get('alma', false), false); | ||
assert.strictEqual(state.get('alma'), undefined); | ||
assert.strictEqual(state.get('alma', false), false); | ||
}); | ||
|
||
it('should not modify the state when getting with default and the cache hits a miss', async () => { | ||
const state = new InmemoryState(); | ||
assert.equal(state.get('alma', false), false); | ||
assert.strictEqual(state.get('alma', false), false); | ||
const actual = state.keys(); | ||
assert.equal(actual.length, 0); | ||
assert.strictEqual(actual.length, 0); | ||
}); | ||
|
||
it('should retrieve the keys', async () => { | ||
const state = new InmemoryState(); | ||
await state.update('alma', false); | ||
await state.update('korte', 36); | ||
const actual = state.keys(); | ||
assert.equal(actual.length, 2); | ||
assert.equal(actual.includes('alma'), true); | ||
assert.equal(actual.includes('korte'), true); | ||
assert.strictEqual(actual.length, 2); | ||
assert.strictEqual(actual.includes('alma'), true); | ||
assert.strictEqual(actual.includes('korte'), true); | ||
}); | ||
|
||
it('should update with new value', async () => { | ||
const state = new InmemoryState(); | ||
await state.update('alma', false); | ||
assert.equal(state.get('alma'), false); | ||
assert.strictEqual(state.get('alma'), false); | ||
await state.update('alma', 36); | ||
assert.equal(state.get('alma'), 36); | ||
assert.strictEqual(state.get('alma'), 36); | ||
const actual = state.keys(); | ||
assert.equal(actual.length, 1); | ||
assert.equal(actual.includes('alma'), true); | ||
assert.strictEqual(actual.length, 1); | ||
assert.strictEqual(actual.includes('alma'), true); | ||
}); | ||
|
||
it('should remove when the update value is undefined', async () => { | ||
const state = new InmemoryState(); | ||
await state.update('alma', false); | ||
assert.equal(state.get('alma'), false); | ||
assert.strictEqual(state.get('alma'), false); | ||
await state.update('alma', undefined); | ||
assert.equal(state.get('alma'), undefined); | ||
assert.strictEqual(state.get('alma'), undefined); | ||
const actual = state.keys(); | ||
assert.equal(actual.length, 0); | ||
assert.strictEqual(actual.length, 0); | ||
}); | ||
}); |