本文整理汇总了TypeScript中Sinon.SinonFakeTimers.restore方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonFakeTimers.restore方法的具体用法?TypeScript SinonFakeTimers.restore怎么用?TypeScript SinonFakeTimers.restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonFakeTimers
的用法示例。
在下文中一共展示了SinonFakeTimers.restore方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: afterEach
afterEach(async () => {
clock.restore();
await nsp
.delete()
.key('connection')
.exec();
});
示例2: afterEach
afterEach((): void => {
if (scenario.today) {
clock.restore();
}
});
示例3: registerSuite
registerSuite('lib/channels/WebSocket', function() {
class MockWebSocket {
addEventListener(name: string, callback: (event: any) => void) {
if (!eventListeners[name]) {
eventListeners[name] = [];
}
eventListeners[name].push(callback);
}
send(data: string) {
sentData.push(data);
}
}
let removeMocks: () => void;
let eventListeners: { [name: string]: ((event: any) => void)[] };
let sentData: string[];
let clock: SinonFakeTimers;
return {
before() {
return mockRequire(require, 'src/lib/channels/WebSocket', {
'src/lib/browser/util': { parseUrl },
'@theintern/common': { global: { WebSocket: MockWebSocket }, Task }
}).then(handle => {
removeMocks = handle.remove;
WebSocket = handle.module.default;
});
},
after() {
removeMocks();
},
beforeEach() {
eventListeners = {};
sentData = [];
clock = useFakeTimers();
},
afterEach() {
clock.restore();
},
tests: {
'required args'() {
assert.throws(() => {
new WebSocket({ sessionId: 'foo', url: 'bar' });
}, /port is required/);
},
'#sendMessage': {
good() {
const ws = new WebSocket({
sessionId: 'foo',
url: 'bar',
port: 12345
});
assert.lengthOf(eventListeners['message'], 1);
assert.lengthOf(eventListeners['open'], 1);
// There are 2 error handlers, one for the initial
// connection and one for later errors
assert.lengthOf(eventListeners['error'], 2);
// Send an open event to the socket so sendMessage will
// proceed
eventListeners['open'][0]({});
const sent = ws.sendMessage('remoteStatus', 'foo');
let messageId: string;
return Promise.resolve()
.then(() => {
assert.lengthOf(sentData, 1);
const message = JSON.parse(sentData[0]);
messageId = message.id;
// Send a response
eventListeners['message'][0]({
data: JSON.stringify({
id: messageId,
data: 'bar'
})
});
return sent;
})
.then(response => {
assert.deepEqual(response, {
id: messageId,
data: 'bar'
});
});
},
error() {
const ws = new WebSocket({
sessionId: 'foo',
url: 'bar',
port: 12345
//.........这里部分代码省略.........
示例4: afterEach
afterEach((): void => {
swWrapper.remove();
clock.restore();
});
示例5: afterEach
afterEach(() => {
clock.restore();
});
示例6: afterEach
afterEach(() => {
clock.restore();
typewriter.reset();
});