All files / elabox-system.lib.nodejs/tests eboxEvent.test.ts

77.78% Statements 14/18
50% Branches 2/4
66.67% Functions 4/6
77.78% Lines 14/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37  1x   1x   1x 1x 1x     1x 1x   1x           1x 1x 1x 1x     1x         1x            
import { expect, assert } from 'chai'
import EventHandler from '../EboxEvent'
 
describe("Event System", () => {
    let instance :EventHandler
    it ("connection", (done) => {
        instance = new EventHandler('http://localhost')
        Iif (instance.connected)  {
            done()
        } else {
            instance.on('connect', () => {
                done()
            })
            instance.on('connect_error', (err) => {
                //assert.equal(err, null || undefined, err.description.message)
                done(err.description.message)
            })
        }
    })
    it ("broadcasting", (done) => {
        Eif (instance.connected) {
            instance.subscribe("app.testing")
            instance.onAction("testaction", (_arg) => {
                done()
            })
            const data = {
                id: "testaction",
                packageId: "app.testing",
                data: "this is it!"
            }
            instance.broadcast(data)
        }else {
            done("Not connected to broadcast action.")
        }
        
    })
})