Punkt 2 implementieren GitHub CoPilot
This commit is contained in:
@@ -79,8 +79,73 @@ describe('InfoServer', () => {
|
||||
expect(status.lastCommands).toEqual(['G1 X10 Y10']);
|
||||
expect(status.lastPings).toEqual(['Ping']);
|
||||
expect(status.senders).toEqual([
|
||||
{ name: 'Base', status: 'connected' },
|
||||
{ name: 'Hand', status: 'disconnected' }
|
||||
{
|
||||
name: 'Base',
|
||||
state: 'connected',
|
||||
url: null,
|
||||
isTestMode: false,
|
||||
error: null,
|
||||
reconnectAttempt: 0,
|
||||
reconnectTimer: false,
|
||||
health: 'ok',
|
||||
reason: undefined
|
||||
},
|
||||
{
|
||||
name: 'Hand',
|
||||
state: 'disconnected',
|
||||
url: null,
|
||||
isTestMode: false,
|
||||
error: null,
|
||||
reconnectAttempt: 0,
|
||||
reconnectTimer: false,
|
||||
health: 'disconnected',
|
||||
reason: 'no active socket connection'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test('returns sender health details from instance.getStatus()', async () => {
|
||||
const key = fs.readFileSync('https/localhost.key');
|
||||
const cert = fs.readFileSync('https/localhost.pem');
|
||||
const httpsOptions = { key, cert, passphrase: 'abcd' };
|
||||
|
||||
const sharedState = { connectedClients: [], lastCommands: [], lastPings: [] };
|
||||
const robot = { x: 0, y: 0, z: 0, phi: 0, theta: 0, psi: 0 };
|
||||
const senders = [
|
||||
{
|
||||
name: 'Reconnect',
|
||||
instance: {
|
||||
getStatus: () => ({
|
||||
state: 'reconnecting',
|
||||
url: 'reconnect.test',
|
||||
error: 'timeout',
|
||||
isTestMode: false,
|
||||
reconnectAttempt: 2,
|
||||
reconnectTimer: true
|
||||
})
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
server = createInfoServer(httpsOptions, sharedState, robot, GCode, senders);
|
||||
port = await listen(server);
|
||||
|
||||
const { statusCode, body } = await request(`https://127.0.0.1:${port}/api/status`);
|
||||
expect(statusCode).toBe(200);
|
||||
|
||||
const status = JSON.parse(body);
|
||||
expect(status.senders).toEqual([
|
||||
{
|
||||
name: 'Reconnect',
|
||||
state: 'reconnecting',
|
||||
url: 'reconnect.test',
|
||||
isTestMode: false,
|
||||
error: 'timeout',
|
||||
reconnectAttempt: 2,
|
||||
reconnectTimer: true,
|
||||
health: 'warning',
|
||||
reason: undefined
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user