UNPKG

spur-common

Version:

A Node.JS library of common modules used as a base to most Node.JS applications.

22 lines (17 loc) 603 B
describe "UncaughtHandler", -> beforeEach -> @mockProcess = on:(@event, @errorFn)=> exit:(@exitCode)=> ioc = injector() ioc.addDependency("nodeProcess", @mockProcess, true) ioc.inject (@UncaughtHandler, @Logger)=> @Logger.useRecorder() it "should exist", -> expect(@UncaughtHandler).to.exist it "should listen and process uncaughtException", -> @UncaughtHandler.listen() expect(@event).to.equal "uncaughtException" @errorFn(new Error("Oops!")) expect(@Logger.recorded.error[0][0].message).to.equal "Oops!" expect(@exitCode).to.equal 0