本文整理汇总了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();
});