MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / expectRejected

Function expectRejected

packages/server/test/auth-wiring.e2e.test.ts:138–163  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

136}
137
138function expectRejected(url: string): Promise<void> {
139 return new Promise((resolve, reject) => {
140 const ws = new WebSocket(url);
141 const t = setTimeout(
142 () => done(new Error('connection was not rejected within timeout')),
143 1500,
144 );
145 const done = (err?: Error): void => {
146 clearTimeout(t);
147 ws.removeAllListeners();
148 try {
149 ws.terminate();
150 } catch {
151 // ignore
152 }
153 if (err === undefined) {
154 resolve();
155 } else {
156 reject(err);
157 }
158 };
159 ws.once('open', () => done(new Error('connection unexpectedly opened')));
160 ws.once('error', () => done());
161 ws.once('close', () => done());
162 });
163}
164
165describe('production auth wiring (M5.1)', () => {
166 it.skipIf(process.platform === 'win32')('writes a 0600 token file at boot and keeps it on close (persistent)', async () => {

Callers 1

Calls 2

doneFunction · 0.70
onceMethod · 0.65

Tested by

no test coverage detected