add basic functionality
This commit is contained in:
19
test/test.ts
19
test/test.ts
@@ -4,6 +4,7 @@ import * as smartipc from '../dist/index'
|
||||
|
||||
let testThreadFunction: smartipc.ThreadFunction
|
||||
let testThread: smartipc.Thread
|
||||
let testPool: smartipc.Pool
|
||||
|
||||
describe('smartipc',function(){
|
||||
it('should create an instance of ThreadFunction',function(){
|
||||
@@ -24,4 +25,22 @@ describe('smartipc',function(){
|
||||
testThread.kill()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not spawn when nothing is sent',function(){
|
||||
smartipc.setWorkerBasePath(__dirname)
|
||||
let testThread = new smartipc.Thread('child.js')
|
||||
})
|
||||
|
||||
it('should run in a Pool', function() {
|
||||
let testPool = new smartipc.Pool()
|
||||
let testThread = new smartipc.Thread('child.js')
|
||||
testThread.assignToPool(testPool)
|
||||
testThread.send('what').then(message => {
|
||||
console.log(message)
|
||||
testThread.send('another').then(message => {
|
||||
console.log(message)
|
||||
testThread.assignedPool.pool.killAll()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user