Skip to content

Commit c656b00

Browse files
fix: issues in core
1 parent 8089283 commit c656b00

2 files changed

Lines changed: 58 additions & 26 deletions

File tree

packages/core/test/client-test.ts

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,14 @@ class WoTClientTest {
358358
this.clientFactory = new TrapClientFactory();
359359
this.servient.addClientFactory(this.clientFactory);
360360
this.servient.addClientFactory(new TDClientFactory());
361-
this.servient.start().then((myWoT) => {
362-
this.WoT = myWoT;
363-
});
361+
this.servient
362+
.start()
363+
.then((myWoT) => {
364+
this.WoT = myWoT;
365+
})
366+
.catch((error) => {
367+
throw error;
368+
});
364369
debug("started test suite");
365370
}
366371

@@ -570,11 +575,17 @@ class WoTClientTest {
570575
expect(thing).to.have.property("title").that.equals("aThing");
571576
expect(thing).to.have.property("events").that.has.property("anEvent");
572577
return new Promise((resolve) => {
573-
thing.subscribeEvent("anEvent", async (x) => {
574-
const value = await x.value();
575-
expect(value).to.equal("triggered");
576-
resolve(true);
577-
});
578+
thing
579+
.subscribeEvent("anEvent", async (x) => {
580+
const value = await x.value();
581+
expect(value).to.equal("triggered");
582+
resolve(true);
583+
})
584+
.catch((error) => {
585+
throw error;
586+
});
587+
}).catch((error) => {
588+
throw error;
578589
});
579590
}
580591

@@ -626,17 +637,25 @@ class WoTClientTest {
626637
expect(thing).to.have.property("title").that.equals("aThing");
627638
expect(thing).to.have.property("events").that.has.property("anEvent");
628639

629-
const subscription = await thing.subscribeEvent("anEvent", () => {
630-
/** */
631-
});
640+
const subscription = await thing
641+
.subscribeEvent("anEvent", () => {
642+
/** */
643+
})
644+
.catch((error) => {
645+
throw error;
646+
});
632647
await subscription.stop();
633648

634649
return new Promise((resolve) => {
635-
thing.subscribeEvent("anEvent", async (x) => {
636-
const value = await x.value();
637-
expect(value).to.equal("triggered");
638-
resolve(true);
639-
});
650+
thing
651+
.subscribeEvent("anEvent", async (x) => {
652+
const value = await x.value();
653+
expect(value).to.equal("triggered");
654+
resolve(true);
655+
})
656+
.catch((error) => {
657+
throw error;
658+
});
640659
});
641660
}
642661

@@ -649,11 +668,15 @@ class WoTClientTest {
649668
expect(thing).to.have.property("title").that.equals("aThing");
650669
expect(thing).to.have.property("properties").that.has.property("aPropertyToObserve");
651670
return new Promise((resolve) => {
652-
thing.observeProperty("aPropertyToObserve", async (data) => {
653-
const value = await data.value();
654-
expect(value).to.equal(12);
655-
resolve(true);
656-
});
671+
thing
672+
.observeProperty("aPropertyToObserve", async (data) => {
673+
const value = await data.value();
674+
expect(value).to.equal(12);
675+
resolve(true);
676+
})
677+
.catch((error) => {
678+
throw error;
679+
});
657680
});
658681
}
659682

packages/core/test/server-test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ class WoTServerTest {
6868
this.servient = new Servient();
6969
this.server = new TestProtocolServer();
7070
this.servient.addServer(this.server);
71-
this.servient.start().then((WoTruntime) => {
72-
this.WoT = WoTruntime;
73-
});
71+
this.servient
72+
.start()
73+
.then((WoTruntime) => {
74+
this.WoT = WoTruntime;
75+
})
76+
.catch((error) => {
77+
throw error;
78+
});
7479
debug("started test suite");
7580
}
7681

@@ -889,7 +894,9 @@ class WoTServerTest {
889894

890895
thing.setPropertyReadHandler("test", callback);
891896

892-
(thing as ExposedThing).handleObserveProperty("test", protocolListener, { formIndex: 0 });
897+
(thing as ExposedThing).handleObserveProperty("test", protocolListener, { formIndex: 0 }).catch((error) => {
898+
throw error;
899+
});
893900

894901
await (<ExposedThing>thing).emitPropertyChange("test");
895902

@@ -964,7 +971,9 @@ class WoTServerTest {
964971
thing.setEventSubscribeHandler("test", handler);
965972
await (<ExposedThing>thing).handleSubscribeEvent("test", callback, { formIndex: 0 });
966973
(<ExposedThing>thing).emitEvent("test", null);
967-
(<ExposedThing>thing).handleUnsubscribeEvent("test", callback, { formIndex: 0 });
974+
(<ExposedThing>thing).handleUnsubscribeEvent("test", callback, { formIndex: 0 }).catch((error) => {
975+
throw error;
976+
});
968977
(<ExposedThing>thing).emitEvent("test", null);
969978

970979
return expect(callback).to.have.been.called.once;

0 commit comments

Comments
 (0)