knex/test/unit/util/save-async-stack.js

30 lines
751 B
JavaScript
Raw Normal View History

2018-04-25 23:11:24 +02:00
'use strict';
/*global expect, describe, it*/
var saveAsyncStack = require('../../../lib/util/save-async-stack');
var chai = require('chai');
2018-04-25 23:11:24 +02:00
describe('saveAsyncStack', function() {
it('should store an error stack on passed object', function() {
2018-04-25 23:11:24 +02:00
var fakeInstance = {
client: {
config: {
asyncStackTraces: true,
},
},
};
saveAsyncStack(fakeInstance, 1);
2018-04-25 23:11:24 +02:00
chai.expect(fakeInstance._asyncStack[0]).to.match(/at saveAsyncStack /);
});
2018-04-25 23:11:24 +02:00
it('should not store an error stack when config is disabled', function() {
2018-04-25 23:11:24 +02:00
var fakeInstance = {
client: {
config: {},
},
};
saveAsyncStack(fakeInstance, 1);
chai.expect(fakeInstance._asyncStack).to.be.undefined;
});
});