Skip to content

Commit

Permalink
Fix boxed reference JSON encoder and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Oct 12, 2024
1 parent a85ab17 commit 632c407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/js/json_encoder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class JsonEncoder {
return JsonEncoder.#encodePort(term, isFullScope);

case "reference":
return JsonEncoder.#encodeReference(term);
return JsonEncoder.#encodeReference(term, isFullScope);

case "tuple":
return JsonEncoder.#encodeTuple(term, isFullScope);
Expand Down
9 changes: 4 additions & 5 deletions test/javascript/json_encoder_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,9 @@ describe("JsonEncoder", () => {
describe("boxed port", () => {
it("originating in client, full scope", () => {
const term = Type.port("0.11", "client");
const expected = '{"type":"port","origin":"client","value":"0.11"}';

assert.throw(
() => JsonEncoder.encode(term, true),
HologramRuntimeError,
"can't encode client terms that are ports originating in client",
);
assert.equal(JsonEncoder.encode(term, true), expected);
});

it("originating in client, not full scope", () => {
Expand Down Expand Up @@ -175,6 +172,7 @@ describe("JsonEncoder", () => {
describe("boxed reference", () => {
it("originating in client, full scope", () => {
const term = Type.reference("0.1.2.3", "client");

const expected =
'{"type":"reference","origin":"client","value":"0.1.2.3"}';

Expand All @@ -193,6 +191,7 @@ describe("JsonEncoder", () => {

it("originating in server, full scope", () => {
const term = Type.reference("0.1.2.3", "server");

const expected =
'{"type":"reference","origin":"server","value":"0.1.2.3"}';

Expand Down

0 comments on commit 632c407

Please sign in to comment.