Skip to content

Commit

Permalink
fix(domain): parse html entities
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarreras committed Nov 13, 2024
1 parent b76dee0 commit b96faca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Widget.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { replaceEntities } from "./helpers/attributeParser";

abstract class Widget {
/**
* Default colspan
Expand Down Expand Up @@ -153,9 +155,9 @@ abstract class Widget {
}
if (props.domain) {
if (typeof props.domain !== "string") {
this._domain = JSON.stringify(props.domain);
this._domain = replaceEntities(JSON.stringify(props.domain));
} else {
this._domain = props.domain;
this._domain = replaceEntities(props.domain);
}
}
if (props.widget_props) {
Expand Down
18 changes: 18 additions & 0 deletions src/spec/Widget.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ describe("A Widget", () => {

expect(typeof widget.colspan).toBe("number");
});

describe("Parsing domain", () => {
it("should parse domain with html entities when is a string", () => {
const props = {
domain: "[('date_start', '>', '2021-01-01')]",
};
const widget = new WidgetImpl(props);
expect(widget.domain).toBe("[('date_start', '>', '2021-01-01')]");
});
it("should parse domain with html entities when is an object", () => {
const props = {
domain: [["date_start", ">", "2021-01-01"]],
};
const widget = new WidgetImpl(props);
expect(widget.domain).toBe('[["date_start",">","2021-01-01"]]');
});
});

describe("Parsing widget props", () => {
it("should parse widget_props", () => {
const props = {
Expand Down

0 comments on commit b96faca

Please sign in to comment.