diff --git a/__tests__/HierarchicalSingleEvent.test.ts b/__tests__/HierarchicalSingleEvent.test.ts index 45e7b998..77eb8034 100644 --- a/__tests__/HierarchicalSingleEvent.test.ts +++ b/__tests__/HierarchicalSingleEvent.test.ts @@ -4,7 +4,8 @@ import { Parameter, OutPort, InPort, - TimeValue + TimeValue, + CanConnectResult } from "../src/core/internal"; import {SingleEvent} from "../src/share/SingleEvent"; @@ -93,7 +94,7 @@ describe("HierarchicalSingleEvent", function () { seTest.seContainer.child.o, seTest.logContainer.child.i ) - ).toBe(false); + ).toBe(CanConnectResult.NOT_IN_SCOPE); seTest._start(); }); diff --git a/__tests__/SingleEvent.test.ts b/__tests__/SingleEvent.test.ts index ac89fb1f..ab49c55f 100644 --- a/__tests__/SingleEvent.test.ts +++ b/__tests__/SingleEvent.test.ts @@ -32,12 +32,8 @@ describe("SingleEvent", function () { expect(expect(seTest.singleEvent).toBeInstanceOf(SingleEvent)); expect(expect(seTest.logger).toBeInstanceOf(Logger)); - expect(function () { - seTest.canConnect(seTest.singleEvent.o, seTest.logger.i); - }).toThrow(new Error("Destination port is already occupied.")); - expect(seTest.canConnect(seTest.logger.i, seTest.singleEvent.o)).toBe( - false - ); + expect(seTest.canConnect(seTest.singleEvent.o, seTest.logger.i)).toBeTruthy(); + expect(seTest.canConnect(seTest.logger.i, seTest.singleEvent.o)).toBeTruthy(); seTest._start(); }); diff --git a/__tests__/connection.test.ts b/__tests__/connection.test.ts index 3d8725e3..4798b7bc 100644 --- a/__tests__/connection.test.ts +++ b/__tests__/connection.test.ts @@ -5,7 +5,8 @@ import { OutPort, InPort, TimeUnit, - TimeValue + TimeValue, + CanConnectResult } from "../src/core/internal"; describe("Check canConnect", () => { @@ -30,19 +31,19 @@ describe("Check canConnect", () => { it("canConnect success out->in", () => { expect(this.canConnect(this.source.out, this.destination.in)).toBe( - true + CanConnectResult.SUCCESS ); }); it("canConnect success out->out", () => { expect(this.canConnect(this.source.out, this.destination.out)).toBe( - true + CanConnectResult.SUCCESS ); }); it("canConnect failure", () => { expect(this.canConnect(this.destination.in, this.source.out)).toBe( - false + CanConnectResult.NOT_IN_SCOPE ); }); } diff --git a/__tests__/hierarchy.ts b/__tests__/hierarchy.ts index ec7fda22..0515e861 100644 --- a/__tests__/hierarchy.ts +++ b/__tests__/hierarchy.ts @@ -1,4 +1,4 @@ -import {Reactor, App, InPort, OutPort} from "../src/core/internal"; +import {Reactor, App, InPort, OutPort, CanConnectResult} from "../src/core/internal"; class InOut extends Reactor { a = new InPort(this); @@ -36,65 +36,57 @@ describe("Container to Contained", () => { it("testing canConnect", () => { expect( app.container.canConnect(app.container.a, app.container.contained.a) - ).toBe(true); + ).toBe(CanConnectResult.SUCCESS); expect( app.container.canConnect(app.container.contained.a, app.container.a) - ).toBe(false); + ).toBe(CanConnectResult.NOT_IN_SCOPE); expect( app.container.canConnect( app.container.a, app.container.b ) - ).toBe(true); + ).toBe(CanConnectResult.SUCCESS); expect( app.container.canConnect( app.container.contained.a, app.container.contained.b ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect( app.container.contained.b, app.container.contained.a ) - ).toBe(true); + ).toBeFalsy(); expect( app.container.canConnect(app.container.a, app.container.contained.b) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect(app.container.contained.b, app.container.a) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect(app.container.b, app.container.contained.a) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect(app.container.contained.a, app.container.b) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect(app.container.b, app.container.contained.b) - ).toBe(false); + ).toBeTruthy(); expect( app.container.canConnect(app.container.contained.b, app.container.b) - ).toBe(true); - - expect(app.container.canConnect(app.container.contained.a, app.foo.a)).toBe( - false - ); - expect(app.container.canConnect(app.container.contained.a, app.foo.b)).toBe( - false - ); - expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBe( - false - ); - expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBe( - false - ); - - expect(app.container.canConnect(app.foo.a, app.container.b)).toBe(false); - expect(app.container.canConnect(app.foo.a, app.container.a)).toBe(false); + ).toBeFalsy(); + + expect(app.container.canConnect(app.container.contained.a, app.foo.a)).toBeTruthy(); + expect(app.container.canConnect(app.container.contained.a, app.foo.b)).toBeTruthy(); + expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBeTruthy(); + expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBeTruthy(); + + expect(app.container.canConnect(app.foo.a, app.container.b)).toBeTruthy(); + expect(app.container.canConnect(app.foo.a, app.container.a)).toBeTruthy(); // expect(app.container.contained).toBeDefined(); @@ -104,49 +96,49 @@ describe("Container to Contained", () => { app.container.contained.containedAgain.a, app.container.contained.a ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.b, app.container.contained.b ) - ).toBe(true); + ).toBeFalsy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.a, app.container.a ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.b, app.container.b ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.a, app.foo.a ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.b, app.foo.b ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.a, app.foo.a ) - ).toBe(false); + ).toBeTruthy(); expect( app.container.contained.canConnect( app.container.contained.containedAgain.b, app.foo.b ) - ).toBe(false); + ).toBeTruthy(); // } }); });