test: fix topics test and ServiceManager

This commit is contained in:
KernelDeimos 2024-10-18 16:33:14 -04:00
parent 598a08ec45
commit 94e15dbfa8
3 changed files with 7 additions and 2 deletions

View File

@ -16,6 +16,10 @@ module.exports = {
instance.mixin(TTopics, {
pub: (k, v) => {
if ( k.includes('!') ) {
throw new Error(
'"!" in event name reserved for future use');
}
const topic = instance._.topics[k];
if ( ! topic ) {
console.warn('missing topic: ' + topic);

View File

@ -66,7 +66,7 @@ class ServiceManager extends AdvancedBase {
async maybe_init_ (name) {
const entry = this.services_m_[name];
const depends = entry.instance.get_depends();
const depends = entry.instance.as(TService).get_depends();
const waiting_for = [];
for ( const depend of depends ) {
const depend_entry = this.services_m_[depend];

View File

@ -1,3 +1,4 @@
const { expect } = require('chai');
const { AdvancedBase } = require("../src/AdvancedBase");
const { TTopics, TDetachable } = require("../src/traits/traits");
@ -14,7 +15,7 @@ describe('topics', () => {
static IMPLEMENTS = {
[TPunchable]: {
punch () {
this.as(TTopics).pub('punched!', {
this.as(TTopics).pub('punched', {
information: 'about the punch',
in_whatever: 'format you desire',
});