本文整理匯總了TypeScript中Sinon.sandbox類的典型用法代碼示例。如果您正苦於以下問題:TypeScript sandbox類的具體用法?TypeScript sandbox怎麽用?TypeScript sandbox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了sandbox類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: expect
const testCase = (belongToSameDrive: boolean) => {
const sandbox = sinon.sandbox.create();
sinon.stub(iconGenerator, 'hasCustomIcon').returns(true);
sandbox.stub(utils, 'belongToSameDrive').returns(belongToSameDrive);
const json = iconGenerator.generateJson(emptyFileCollection, emptyFolderCollection);
expect(json.iconDefinitions._file.iconPath)
.to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
expect(json.iconDefinitions._folder.iconPath)
.to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
expect(json.iconDefinitions._folder_open.iconPath)
.to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
sandbox.restore();
};
示例2: beforeEach
beforeEach(function () {
BSTVirtualAlexa = function () {
this.start = function () {
};
};
mockery.enable({ useCleanCache: true, warnOnReplace: false, warnOnUnregistered: false });
mockery.registerMock("../lib/core/global", globalModule);
mockery.registerMock("../lib/client/bst-virtual-alexa", {
BSTVirtualAlexa: BSTVirtualAlexa
});
sandbox = sinon.sandbox.create();
});
示例3: it
it('should act like the async scheduler if delay > 0', () => {
let actionHappened = false;
const sandbox = sinon.sandbox.create();
const fakeTimer = sandbox.useFakeTimers();
queue.schedule(() => {
actionHappened = true;
}, 50);
expect(actionHappened).to.be.false;
fakeTimer.tick(25);
expect(actionHappened).to.be.false;
fakeTimer.tick(25);
expect(actionHappened).to.be.true;
sandbox.restore();
});
示例4: it
it('should cancel animationFrame actions when unsubscribed', () => {
let actionHappened = false;
const sandbox = sinon.sandbox.create();
const fakeTimer = sandbox.useFakeTimers();
animationFrame.schedule(() => {
actionHappened = true;
}, 50).unsubscribe();
expect(actionHappened).to.be.false;
fakeTimer.tick(25);
expect(actionHappened).to.be.false;
fakeTimer.tick(25);
expect(actionHappened).to.be.false;
sandbox.restore();
});
示例5: beforeEach
beforeEach(() => {
sandbox = sinon.sandbox.create();
mockModule = new MockModule('../../src/allCommands', require);
mockModule.dependencies(['./command', './loadCommands', './config']);
mockCommand = mockModule.getMock('./command');
mockLoadCommands = mockModule.getMock('./loadCommands');
const groupCCommandMap = new Map().set('a', { name: 'a', group: 'c', path: 'as' });
const groupDCommandMap = new Map().set('b', { name: 'b', group: 'd', path: 'asas' });
const groupMap = new Map().set('c', groupCCommandMap).set('d', groupDCommandMap);
mockLoadCommands.loadCommands = sandbox.stub().resolves(groupMap);
moduleUnderTest = mockModule.getModuleUnderTest();
});
示例6: proxyquire
test.beforeEach(t => {
const sandbox = sinon.sandbox.create();
const go = sandbox.stub();
const start = sandbox.stub();
const History = sandbox.stub();
History.prototype.go = go;
History.prototype.start = start;
t.context.go = go;
t.context.start = start;
t.context.History = History;
t.context.init = proxyquire('../src/', {
'./history': { History }
}).init;
});
示例7: it
it('should console.log events when given a string', (done) => {
const sandbox = sinon.sandbox.create()
sandbox.spy(console, 'log')
const stream = debug('Stream', Stream.of(1))
const expected = [1]
stream.subscribe((x) => {
assert(x === expected.shift())
}, done, () => {
sinon.assert.calledTwice(console.log as Sinon.SinonSpy)
sandbox.restore()
done()
})
})
示例8: beforeEach
beforeEach(() => {
instance = Weather();
sandbox = sinon.sandbox.create();
if (typeof window === 'undefined') {
(global as any).window = global;
}
if (window.fetch === undefined) {
window.fetch = function () { } as any;
}
sandbox.stub(window, 'fetch', () => new Promise((resolve, reject) => {
resolveFetch = resolve;
rejectFetch = reject;
}));
return zurvan.interceptTimers().catch(() => { });
});
示例9: beforeEach
beforeEach(() => {
runnerOptions = {
port: 42,
files: [],
strykerOptions: null
};
sinonSandbox = sinon.sandbox.create();
fakeChildProcess = {
kill: sinon.spy(),
send: sinon.spy(),
on: sinon.spy()
}
sinonSandbox.stub(child_process, 'fork', () => fakeChildProcess);
clock = sinon.useFakeTimers();
});
示例10: it
it('should return a dispose function', function() {
let sandbox = sinon.sandbox.create();
const spy = sandbox.spy();
function app(sources: any): any {
return {
other: sources.other.take(1).startWith('a'),
};
}
function driver() {
return Rx.Observable.of('b').do(spy);
}
let dispose = run(app, {other: driver});
assert.strictEqual(typeof dispose, 'function');
sinon.assert.calledOnce(spy);
dispose();
});