Skip to content

Commit

Permalink
test cases passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Devkant21 committed Apr 15, 2024
0 parents commit 7ab0db7
Show file tree
Hide file tree
Showing 8 changed files with 4,182 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
39 changes: 39 additions & 0 deletions __test__/cache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { BSTCache } from "../src/cache"
// import { BSTCache } from 'keyache';


describe('BSTCache', () => {
let cache: BSTCache;

beforeEach(() => {
cache = new BSTCache();
});

it('should set and get values correctly', () => {
cache.set('key1', 'value1');
cache.set('key2', 'value2');

expect(cache.get('key1')).toBe('value1');
expect(cache.get('key2')).toBe('value2');
});

it('should return undefined for non-existent keys', () => {
expect(cache.get('nonexistent')).toBeUndefined();
});

it('should delete values correctly', () => {
cache.set('key1', 'value1');
cache.delete('key1');

expect(cache.get('key1')).toBeUndefined();
});

it('should clear the cache correctly', () => {
cache.set('key1', 'value1');
cache.set('key2', 'value2');
cache.clear();

expect(cache.get('key1')).toBeUndefined();
expect(cache.get('key2')).toBeUndefined();
});
});
8 changes: 8 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^keyache$': '<rootDir>/dist/index.js',
'^keyache/(.*)$': '<rootDir>/dist/$1',
},
};
Loading

0 comments on commit 7ab0db7

Please sign in to comment.