X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Ffixed.test.js;h=b591c54c64f0a3e7e3664a16898569e66a1328ea;hb=7784f548560f0e8957b73977137532a1372aa5cb;hp=e56e15ff301ea1e6fedcb9081e119bd208f310be;hpb=23d46b3a84f250d3a5f9c20f8f875bedb5ebb871;p=poolifier.git diff --git a/tests/fixed.test.js b/tests/fixed.test.js index e56e15ff..b591c54c 100644 --- a/tests/fixed.test.js +++ b/tests/fixed.test.js @@ -7,6 +7,7 @@ const pool = new FixedThreadPool(numThreads, const emptyPool = new FixedThreadPool(1, './tests/workers/emptyWorker.js') const echoPool = new FixedThreadPool(1, './tests/workers/echoWorker.js') const errorPool = new FixedThreadPool(1, './tests/workers/errorWorker.js', { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') }) +const asyncPool = new FixedThreadPool(1, './tests/workers/asyncWorker.js') describe('Fixed thread pool test suite ', () => { it('Choose worker round robin test', async () => { @@ -54,6 +55,16 @@ describe('Fixed thread pool test suite ', () => { expect(inError.message).toBeTruthy() }) + it('Verify that async function is working properly', async () => { + const data = { f: 10 } + const startTime = new Date().getTime() + const result = await asyncPool.execute(data) + const usedTime = new Date().getTime() - startTime + expect(result).toBeTruthy() + expect(result.f).toBe(data.f) + expect(usedTime).toBeGreaterThan(2000) + }) + it('Shutdown test', async () => { let closedThreads = 0 pool.workers.forEach(w => {