fix(core): update
This commit is contained in:
29
test/test.asyncexecutionstack.both.ts
Normal file
29
test/test.asyncexecutionstack.both.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
import * as lik from '../ts/index.js';
|
||||
|
||||
let testAsyncExecutionStack: lik.AsyncExecutionStack;
|
||||
|
||||
tap.test('should create a valid instance of AsyncExectionStack', async () => {
|
||||
testAsyncExecutionStack = new lik.AsyncExecutionStack();
|
||||
expect(testAsyncExecutionStack).toBeInstanceOf(lik.AsyncExecutionStack);
|
||||
});
|
||||
|
||||
tap.test('should run in parallel', async (toolsArg) => {
|
||||
await testAsyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(2000);
|
||||
console.log('should run first');
|
||||
}, 2500);
|
||||
testAsyncExecutionStack.getNonExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(2000);
|
||||
console.log('should run third');
|
||||
}, 2500);
|
||||
testAsyncExecutionStack.getNonExclusiveExecutionSlot(async () => {
|
||||
await toolsArg.delayFor(1000);
|
||||
console.log('should run second');
|
||||
}, 2500);
|
||||
await testAsyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||
console.log('should run fourth');
|
||||
}, 0);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -14,15 +14,17 @@ tap.test('should find an entry', async () => {
|
||||
}>();
|
||||
fastmap.addToMap('heythere', {
|
||||
value1: 'heyho',
|
||||
value2: 'heyho2'
|
||||
})
|
||||
value2: 'heyho2',
|
||||
});
|
||||
fastmap.addToMap('heythere2', {
|
||||
value1: 'heyho3',
|
||||
value2: 'heyho4'
|
||||
value2: 'heyho4',
|
||||
});
|
||||
|
||||
const result = await fastmap.find(async (itemArg)=> {return itemArg.value2 === 'heyho4'});
|
||||
const result = await fastmap.find(async (itemArg) => {
|
||||
return itemArg.value2 === 'heyho4';
|
||||
});
|
||||
expect(result.value1).toEqual('heyho3');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user