2018-04-25 23:11:24 +02:00
|
|
|
'use strict';
|
2019-07-10 22:48:43 +01:00
|
|
|
const saveAsyncStack = require('../../../lib/util/save-async-stack');
|
2018-10-15 22:29:53 -04:00
|
|
|
const chai = require('chai');
|
2018-04-25 23:11:24 +02:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
describe('saveAsyncStack', function () {
|
|
|
|
it('should store an error stack on passed object', function () {
|
2018-10-15 22:29:53 -04:00
|
|
|
const fakeInstance = {
|
2018-04-25 23:11:24 +02:00
|
|
|
client: {
|
|
|
|
config: {
|
2018-07-09 08:10:34 -04:00
|
|
|
asyncStackTraces: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
saveAsyncStack(fakeInstance, 1);
|
2018-04-25 23:11:24 +02:00
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
chai.expect(fakeInstance._asyncStack[0]).to.match(/at saveAsyncStack /);
|
|
|
|
});
|
2018-04-25 23:11:24 +02:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
it('should not store an error stack when config is disabled', function () {
|
2018-10-15 22:29:53 -04:00
|
|
|
const fakeInstance = {
|
2018-04-25 23:11:24 +02:00
|
|
|
client: {
|
2018-07-09 08:10:34 -04:00
|
|
|
config: {},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
saveAsyncStack(fakeInstance, 1);
|
|
|
|
chai.expect(fakeInstance._asyncStack).to.be.undefined;
|
|
|
|
});
|
|
|
|
});
|