lik/test/test.fastmap.both.ts

31 lines
716 B
TypeScript
Raw Permalink Normal View History

2024-04-18 19:55:33 +00:00
import { tap, expect } from '@push.rocks/tapbundle';
2021-09-12 14:08:20 +00:00
2022-05-27 15:53:02 +00:00
import * as lik from '../ts/index.js';
2021-09-12 14:08:20 +00:00
tap.test('should create a valid fastmap', async () => {
const fastmap = new lik.FastMap();
2022-01-24 04:22:49 +00:00
expect(fastmap).toBeInstanceOf(lik.FastMap);
2021-09-12 14:08:20 +00:00
});
tap.test('should find an entry', async () => {
const fastmap = new lik.FastMap<{
value1: string;
value2: string;
}>();
fastmap.addToMap('heythere', {
value1: 'heyho',
2023-01-18 16:45:19 +00:00
value2: 'heyho2',
});
2021-09-12 14:08:20 +00:00
fastmap.addToMap('heythere2', {
value1: 'heyho3',
2023-01-18 16:45:19 +00:00
value2: 'heyho4',
2021-09-12 14:08:20 +00:00
});
2023-01-18 16:45:19 +00:00
const result = await fastmap.find(async (itemArg) => {
return itemArg.value2 === 'heyho4';
});
2022-01-24 04:22:49 +00:00
expect(result.value1).toEqual('heyho3');
2021-09-12 14:08:20 +00:00
});
2024-04-18 19:55:33 +00:00
export default tap.start();