mirror of https://github.com/calzoneman/sync.git
Add test for typecheckedOn
This commit is contained in:
parent
86e023d233
commit
4cad31d82c
|
@ -24,7 +24,6 @@ describe('UWSServer', () => {
|
|||
if (type === 0) {
|
||||
socket.test.emit(frame, payload);
|
||||
} else if (type === 1) {
|
||||
console.log(message.data);
|
||||
socket.test.emit('ack', ackId, payload);
|
||||
}
|
||||
};
|
||||
|
@ -140,4 +139,30 @@ describe('UWSServer', () => {
|
|||
});
|
||||
};
|
||||
});
|
||||
|
||||
it('typechecks input frames', done => {
|
||||
server.on('connection', s => {
|
||||
s.typecheckedOn('test', { foo: 'string' }, data => {
|
||||
assert.fail('Should not have reached callback');
|
||||
});
|
||||
});
|
||||
|
||||
socket = connect();
|
||||
socket.onopen = () => {
|
||||
socket.send(JSON.stringify({
|
||||
type: 0,
|
||||
frame: 'test',
|
||||
payload: { foo: 123 }
|
||||
}));
|
||||
|
||||
socket.test.on('errorMsg', payload => {
|
||||
assert.equal(
|
||||
payload.msg,
|
||||
'Unexpected error for message test: ' +
|
||||
'Expected key foo to be of type string, instead got number'
|
||||
);
|
||||
done();
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue