Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('forces an associated statement to be re-prepared the first time its called', () => {
const forceReprepare = td.function();
const statement = limiting({ preparable: { forceReprepare } }).limit(1);
expect(td.explain(forceReprepare).callCount).to.equal(1);
statement.offset(2);
expect(td.explain(forceReprepare).callCount).to.equal(1);
});
it('registers a `close` event listener for the provided stream', () => {
const stream = { on };
const handleServerClose = td.function();
td.when(on('close')).thenCallback();
td.when(handleServerClose('foo')).thenReturn();
Client.call({ handleServerClose }, stream);
return expect(td.explain(handleServerClose).callCount).to.equal(1);
});
});
beforeEach('create fakes', () => {
load = td.function();
});
beforeEach('create fakes', () => {
acquire = td.function();
destroy = td.function();
start = td.function();
});
function getDriver () {
const getSession = td.function()
const runQuery = td.function()
const closeSession = td.function()
const subscribeToQuery = td.function()
td.when(runQuery(), { ignoreExtraArgs: true }).thenReturn({
subscribe: subscribeToQuery
})
td.when(getSession()).thenReturn({
run: runQuery,
close: closeSession
})
const driver = {
session: getSession
}
return { driver, getSession, runQuery }
beforeEach('create fakes', () => {
exists = td.function();
remove = td.function();
});
beforeEach('create fakes', () => {
clientProto = Object.assign({}, Client.prototype);
authenticate = td.function();
capabilitiesGet = td.function();
Client.prototype.authenticate = authenticate;
Client.prototype.capabilitiesGet = capabilitiesGet;
td.when(authenticate(), { ignoreExtraArgs: true }).thenResolve();
});
beforeEach('create fakes', () => {
forceRestart = td.function();
});
beforeEach('create fakes', () => {
destroy = td.function();
});
const subscribeSync = (obs: Observable, trigger: Function, n = 1): T => {
let called: T;
let fn = td.function();
let subs = obs.pipe(take(n > 0 ? n : 1)).subscribe(ev => {
fn(ev);
called = ev;
});
trigger();
subs.unsubscribe();
expect().toVerify({ called: fn(td.matchers.isA(Object)), times: n })
return called;
};