Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2019-12-09 14:50:22 -0500
committerAustin Schaffer <austin.schaffer@ryansg.com>2019-12-12 10:27:09 -0500
commit84c2601f1c8a0ac97ce6c35b05c913521ba47a89 (patch)
treedf6101973095fc5f6a6024c0cf8868852b8c446f /test
parente885026e0a1ecf1e21e821fb50fe5d1a46537664 (diff)
downloadliza-84c2601f1c8a0ac97ce6c35b05c913521ba47a89.tar.gz
liza-84c2601f1c8a0ac97ce6c35b05c913521ba47a89.tar.bz2
liza-84c2601f1c8a0ac97ce6c35b05c913521ba47a89.zip
EventMediator: Log error stack under context
Diffstat (limited to 'test')
-rw-r--r--test/system/EventMediatorTest.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/system/EventMediatorTest.ts b/test/system/EventMediatorTest.ts
index 581437c..caab191 100644
--- a/test/system/EventMediatorTest.ts
+++ b/test/system/EventMediatorTest.ts
@@ -96,27 +96,33 @@ describe( 'system.EventLogger captures and logs events', () =>
expect( method_called ).to.be.true;
} );
- it( 'context is retrieved from error', () =>
+ it( 'context and stack are retrieved from error', () =>
{
let method_called = false;
const event_id = 'error';
const err_msg = 'Foo';
+ const stub_err = new Error( err_msg );
const emitter = new EventEmitter();
const log = createMockLogger();
const err_context = { bar: 'baz' };
+ const expected_context = {
+ bar: err_context.bar,
+ stack: stub_err.stack,
+ };
+
log.error = ( str: string, context: any ) =>
{
- method_called = true;
-
expect( str ).to.equal( err_msg );
- expect( context ).to.equal( err_context );
+ expect( context ).to.deep.equal( expected_context );
+
+ method_called = true;
};
new Sut( log, emitter );
- emitter.emit( event_id, context( new Error( err_msg ), err_context ) );
+ emitter.emit( event_id, context( stub_err, err_context ) );
expect( method_called ).to.be.true;
} );
@@ -136,4 +142,4 @@ function createMockLogger(): PsrLogger
emergency( _msg: string | object, _context: object ){},
log( _level: any, _msg: string | object, _context: object ){},
};
-} \ No newline at end of file
+}