Commit 513db2cc authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Fix #108, added spec

Showing with 43 additions and 1 deletion
+43 -1
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; // import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { ParamValueMode, Session } from "../../src/index";
import { CloisonAval } from "../../src/pab/cloison_aval"; import { CloisonAval } from "../../src/pab/cloison_aval";
import { Cloisons, CloisonsParams } from "../../src/pab/cloisons"; import { Cloisons, CloisonsParams } from "../../src/pab/cloisons";
import { Pab, PabParams } from "../../src/pab/pab"; import { Pab, PabParams } from "../../src/pab/pab";
...@@ -223,4 +224,45 @@ describe("Class Pab: ", () => { ...@@ -223,4 +224,45 @@ describe("Class Pab: ", () => {
}); });
}); });
fdescribe("calculated parameter should always be Q or Z1 - ", () => {
it("try setting Q and Z1 to SINGLE", () => {
pab.calculatedParam = pab.prms.Q;
pab.prms.Z1.valueMode = ParamValueMode.SINGLE;
expect(pab.calculatedParam.symbol).toBe("Q");
pab.prms.Q.valueMode = ParamValueMode.SINGLE;
expect(pab.calculatedParam.symbol).toBe("Z1");
});
it("try setting Q and Z1 to MINMAX", () => {
pab.calculatedParam = pab.prms.Q;
pab.prms.Z1.valueMode = ParamValueMode.MINMAX;
expect(pab.calculatedParam.symbol).toBe("Q");
pab.prms.Q.valueMode = ParamValueMode.MINMAX;
expect(pab.calculatedParam.symbol).toBe("Z1");
});
it("try setting Q and Z1 to MINMAX", () => {
pab.calculatedParam = pab.prms.Q;
pab.prms.Z1.valueMode = ParamValueMode.LISTE;
expect(pab.calculatedParam.symbol).toBe("Q");
pab.prms.Q.valueMode = ParamValueMode.LISTE;
expect(pab.calculatedParam.symbol).toBe("Z1");
});
it("try setting Q and Z1 to LINK", () => {
// clone PAB
const pab2 = createPabTest();
Session.getInstance().clear();
Session.getInstance().registerNub(pab);
Session.getInstance().registerNub(pab2);
// link
pab.prms.Z1.defineReference(pab2, "Z1");
expect(pab.calculatedParam.symbol).toBe("Q");
expect(pab.prms.Z1.valueMode).toBe(ParamValueMode.LINK);
pab.prms.Q.defineReference(pab2, "Q");
expect(pab.calculatedParam.symbol).toBe("Z1");
expect(pab.prms.Q.valueMode).toBe(ParamValueMode.LINK);
});
});
}); });
...@@ -513,7 +513,7 @@ export abstract class Nub extends ComputeNode implements IObservable { ...@@ -513,7 +513,7 @@ export abstract class Nub extends ComputeNode implements IObservable {
) )
&& (p.valueMode === ParamValueMode.CALCUL) && (p.valueMode === ParamValueMode.CALCUL)
) { ) {
// trick to expose p a a result of the parent Nub // trick to expose p as a result of the parent Nub
res.push(new LinkedValue(this.parent, p, p.symbol)); res.push(new LinkedValue(this.parent, p, p.symbol));
} else { } else {
// do not suggest parameters that are already linked to another one // do not suggest parameters that are already linked to another one
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment