fix(core): update

This commit is contained in:
2020-09-24 18:17:52 +00:00
parent 5d8c2064e0
commit 820ce76fe3
19 changed files with 140 additions and 104 deletions

View File

@ -10,17 +10,17 @@ let testClientUniverse2: smartuniverse.ClientUniverse;
let testClientChannel: smartuniverse.ClientUniverseChannel;
const testServerData = {
serverAddress: 'http://localhost:8765'
serverAddress: 'http://localhost:8765',
};
const testChannelData = {
channelName: 'awesomeTestChannel',
channelPass: 'awesomeChannelPass'
channelPass: 'awesomeChannelPass',
};
tap.test('first test', async () => {
testUniverse = new smartuniverse.Universe({
messageExpiryInMilliseconds: 1000
messageExpiryInMilliseconds: 1000,
});
});
@ -32,7 +32,7 @@ tap.test('add a message to the SmartUniverse', async () => {
tap.test('create smartuniverse client', async () => {
testClientUniverse = new smartuniverse.ClientUniverse({
serverAddress: testServerData.serverAddress,
autoReconnect: true
autoReconnect: true,
});
expect(testClientUniverse).to.be.instanceof(smartuniverse.ClientUniverse);
});
@ -56,7 +56,7 @@ tap.test('should get a observable correctly', async () => {
tap.test('should send a message correctly', async () => {
await testClientUniverse.getChannel(testChannelData.channelName).sendMessage({
messageText: 'hello'
messageText: 'hello',
});
});
@ -67,25 +67,25 @@ tap.test('universe should contain the sent message', async () => {
tap.test('a second client should be able to subscibe', async () => {
testClientUniverse2 = new smartuniverse.ClientUniverse({
serverAddress: testServerData.serverAddress,
autoReconnect: true
autoReconnect: true,
});
testClientUniverse2.addChannel(testChannelData.channelName, testChannelData.channelPass);
await testClientUniverse2.start();
});
tap.test('should receive a message correctly', async tools => {
tap.test('should receive a message correctly', async (tools) => {
const done = tools.defer();
const testChannel = testClientUniverse.getChannel(testChannelData.channelName);
const testChannel2 = testClientUniverse2.getChannel(testChannelData.channelName);
const subscription = testChannel2.subscribe(messageArg => {
const subscription = testChannel2.subscribe((messageArg) => {
if (messageArg.messageText === 'hellothere') {
console.log('Yay##########');
done.resolve();
}
});
await testChannel.sendMessage({
messageText: 'hellothere'
messageText: 'hellothere',
});
await done.promise;
});
@ -103,33 +103,33 @@ interface IDemoReqRes {
tap.test('ReactionRequest and ReactionResponse should work', async () => {
const reactionResponse = new smartuniverse.ReactionResponse<IDemoReqRes>({
channels: [testUniverse.getChannel(testChannelData.channelName)],
funcDef: async reqData => {
funcDef: async (reqData) => {
console.log(reqData);
return {
hereso: 'Hello there'
hereso: 'Hello there',
};
},
method: 'demo'
method: 'demo',
});
const reactionRequest = new smartuniverse.ReactionRequest<IDemoReqRes>({
method: 'demo'
method: 'demo',
});
const reactionResult = await reactionRequest.fire(
[testClientUniverse2.getChannel(testChannelData.channelName)],
{
wowso: 'wowza'
wowso: 'wowza',
}
);
const result = await reactionResult.getFirstResult();
console.log(result);
});
tap.test('should disconnect the client correctly', async tools => {
tap.test('should disconnect the client correctly', async (tools) => {
await testClientUniverse.stop();
await testClientUniverse2.stop();
});
tap.test('should end the server correctly', async tools => {
tap.test('should end the server correctly', async (tools) => {
await testUniverse.stopServer();
});