Skip to content

Commit

Permalink
test: push service updates
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Sep 2, 2020
1 parent 36e29f5 commit f682ed2
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion tests/admin-test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import test from "ava";
import { StandaloneServiceProvider } from "@kronos-integration/service";
import {
StandaloneServiceProvider,
Service
} from "@kronos-integration/service";
import { ServiceAdmin } from "@kronos-integration/service-admin";

const config = {
Expand Down Expand Up @@ -78,3 +81,41 @@ test("service-admin service entpoint", async t => {
}
});
});

test("service-admin push from services endpoint", async t => {
const sp = new StandaloneServiceProvider();
await sp.declareServices({
admin: {
type: ServiceAdmin
},
test: {
type: Service,
endpoints: {
test: "service(admin).services"
}
}
});

const admin = sp.services.admin;
const ts = sp.services.test;

const updates = [];
ts.endpoints.test.receive = update => {
update = JSON.parse(JSON.stringify(update));

updates.push(update);
};

t.is(ts.name, "test");

await admin.start();
t.is(admin.state, "running");

await ts.start();

t.is(updates.length, 4);

t.is(updates[2].test.state, "stopped");
t.is(updates[3].test.state, "starting");
//console.log(updates);
});

0 comments on commit f682ed2

Please sign in to comment.