我正在尝试使用Bootstrap 4将我的Container放在页面中间.
我正在扩展net.Socket。这样做时,我将按如下方式覆盖连接方法。
class ENIP extends Socket {
constructor() {
super();
this.state = {
session: { id: null, establishing: false, established: false },
error: { code: null, msg: null }
};
}
connect(IP_ADDR) {
const { registerSession } = encapsulation; //returns a buffer to send
this.state.session.establishing = true;
return new Promise(resolve => {
super.connect(EIP_PORT, IP_ADDR, () => { // This is what i want to mock -> super.connect
this.state.session.establishing = false;
this.write(registerSession());
resolve();
});
});
}
}
Run Code Online (Sandbox Code Playgroud)
我想模拟底层的Socket类,以便我可以模拟 …
我需要测试是否以特定顺序调用了一系列异步函数。是否有捷径可寻?
下面是我要实现的示例:
describe("Test ASYNC order", () => {
it("Calls in a particular order", () => {
const p1 = new Promise(resolve => setTimeout(resolve, 500));
const p2 = new Promise(resolve => setTimeout(resolve, 600));
const p3 = new Promise(resolve => setTimeout(resolve, 200));
/* How would I test that the order of the promises resolving is p3 then p1 then p2 ????? */
})
})
Run Code Online (Sandbox Code Playgroud) 我的 vscode 编辑器设置为自动添加右括号/圆括号但不添加它们。这是一个最近才开始的新问题。有没有其他人在全局 vscode 设置中遇到过这个问题?
json typescript visual-studio-code vscode-settings github-copilot
node.js ×2
bootstrap-4 ×1
css ×1
flexbox ×1
html ×1
javascript ×1
jest ×1
jestjs ×1
json ×1
mocking ×1
promise ×1
sockets ×1
testing ×1
typescript ×1
unit-testing ×1