@gisce/ooui 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ declare class Action {
2
+ _name: string | null;
3
+ get name(): string | null;
4
+ _parms: string | null;
5
+ get parms(): string | null;
6
+ constructor(attributes: any);
7
+ }
8
+ export default Action;
package/dist/Action.js ADDED
@@ -0,0 +1,29 @@
1
+ var Action = /** @class */ (function () {
2
+ function Action(attributes) {
3
+ this._name = null;
4
+ this._parms = null;
5
+ if (attributes.name) {
6
+ this._name = attributes.name;
7
+ }
8
+ if (attributes.parms) {
9
+ this._parms = attributes.parms;
10
+ }
11
+ }
12
+ Object.defineProperty(Action.prototype, "name", {
13
+ get: function () {
14
+ return this._name;
15
+ },
16
+ enumerable: false,
17
+ configurable: true
18
+ });
19
+ Object.defineProperty(Action.prototype, "parms", {
20
+ get: function () {
21
+ return this._parms;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ return Action;
27
+ }());
28
+ export default Action;
29
+ //# sourceMappingURL=Action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Action.js","sourceRoot":"","sources":["../src/Action.ts"],"names":[],"mappings":"AAAA;IAWE,gBAAY,UAAe;QAV3B,UAAK,GAAkB,IAAI,CAAC;QAK5B,WAAM,GAAkB,IAAI,CAAC;QAM3B,IAAI,UAAU,CAAC,IAAI,EAAE;YACnB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;SAC9B;QAED,IAAI,UAAU,CAAC,KAAK,EAAE;YACpB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;SAChC;IACH,CAAC;IAjBD,sBAAI,wBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,yBAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAWH,aAAC;AAAD,CAAC,AApBD,IAoBC;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ import Action from "./Action";
2
+ declare class Dashboard {
3
+ _string: string | null;
4
+ get string(): string | null;
5
+ _actions: Action[];
6
+ get actions(): Action[];
7
+ constructor(xml: string);
8
+ }
9
+ export default Dashboard;
@@ -0,0 +1,36 @@
1
+ import Action from "./Action";
2
+ import { parseGenericNodes } from "./helpers/nodeParser";
3
+ var Dashboard = /** @class */ (function () {
4
+ function Dashboard(xml) {
5
+ var _this = this;
6
+ this._string = null;
7
+ this._actions = [];
8
+ var parser = new DOMParser();
9
+ var view = parser.parseFromString(xml, "text/xml");
10
+ this._string = view.documentElement.getAttribute("string");
11
+ var documentElement = view.documentElement;
12
+ var actionsParsed = parseGenericNodes(documentElement.childNodes);
13
+ actionsParsed.forEach(function (nodeParsed) {
14
+ if (nodeParsed.tag === "action") {
15
+ _this._actions.push(new Action(nodeParsed.tagAttributes));
16
+ }
17
+ });
18
+ }
19
+ Object.defineProperty(Dashboard.prototype, "string", {
20
+ get: function () {
21
+ return this._string;
22
+ },
23
+ enumerable: false,
24
+ configurable: true
25
+ });
26
+ Object.defineProperty(Dashboard.prototype, "actions", {
27
+ get: function () {
28
+ return this._actions;
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
33
+ return Dashboard;
34
+ }());
35
+ export default Dashboard;
36
+ //# sourceMappingURL=Dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../src/Dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;IAWE,mBAAY,GAAW;QAAvB,iBAaC;QAvBD,YAAO,GAAkB,IAAI,CAAC;QAK9B,aAAQ,GAAa,EAAE,CAAC;QAMtB,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE7C,IAAM,aAAa,GAAG,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAEpE,aAAa,CAAC,OAAO,CAAC,UAAC,UAAU;YAC/B,IAAI,UAAU,CAAC,GAAG,KAAK,QAAQ,EAAE;gBAC/B,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;aAC1D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAtBD,sBAAI,6BAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,8BAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IAgBH,gBAAC;AAAD,CAAC,AAzBD,IAyBC;AAED,eAAe,SAAS,CAAC"}
@@ -1,5 +1,9 @@
1
1
  import Field from "./Field";
2
2
  declare class Indicator extends Field {
3
3
  _nolabel: boolean;
4
+ _card: boolean;
5
+ get card(): boolean;
6
+ set card(value: boolean);
7
+ constructor(props: any);
4
8
  }
5
9
  export default Indicator;
package/dist/Indicator.js CHANGED
@@ -14,11 +14,25 @@ var __extends = (this && this.__extends) || (function () {
14
14
  import Field from "./Field";
15
15
  var Indicator = /** @class */ (function (_super) {
16
16
  __extends(Indicator, _super);
17
- function Indicator() {
18
- var _this = _super !== null && _super.apply(this, arguments) || this;
17
+ function Indicator(props) {
18
+ var _this = _super.call(this, props) || this;
19
19
  _this._nolabel = true;
20
+ _this._card = false;
21
+ if (_this._parsedWidgetProps) {
22
+ _this._card = _this._parsedWidgetProps.card;
23
+ }
20
24
  return _this;
21
25
  }
26
+ Object.defineProperty(Indicator.prototype, "card", {
27
+ get: function () {
28
+ return this._card;
29
+ },
30
+ set: function (value) {
31
+ this._card = value;
32
+ },
33
+ enumerable: false,
34
+ configurable: true
35
+ });
22
36
  return Indicator;
23
37
  }(Field));
24
38
  export default Indicator;
@@ -1 +1 @@
1
- {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAA7B;QAAA,qEAEC;QADC,cAAQ,GAAY,IAAI,CAAC;;IAC3B,CAAC;IAAD,gBAAC;AAAD,CAAC,AAFD,CAAwB,KAAK,GAE5B;AAGD,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Indicator.js","sourceRoot":"","sources":["../src/Indicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;IAAwB,6BAAK;IAW3B,mBAAY,KAAU;QAAtB,YACE,kBAAM,KAAK,CAAC,SAKb;QAhBD,cAAQ,GAAY,IAAI,CAAC;QAYvB,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,KAAI,CAAC,kBAAkB,EAAE;YAC3B,KAAI,CAAC,KAAK,GAAG,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;SAC3C;;IACH,CAAC;IAbD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;aACD,UAAS,KAAc;YACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;;;OAHA;IAYH,gBAAC;AAAD,CAAC,AAlBD,CAAwB,KAAK,GAkB5B;AAGD,eAAe,SAAS,CAAC"}
@@ -4,4 +4,5 @@ declare type ParsedNode = {
4
4
  child: Element;
5
5
  };
6
6
  declare const parseNodes: (nodes: NodeListOf<ChildNode>, fields: any) => ParsedNode[];
7
- export { parseNodes };
7
+ declare const parseGenericNodes: (nodes: NodeListOf<ChildNode>) => ParsedNode[];
8
+ export { parseNodes, parseGenericNodes };
@@ -46,5 +46,19 @@ var parseNodes = function (nodes, fields) {
46
46
  });
47
47
  return parsedNodes;
48
48
  };
49
- export { parseNodes };
49
+ var parseGenericNodes = function (nodes) {
50
+ var parsedNodes = [];
51
+ Array.prototype.forEach.call(nodes, function (child) {
52
+ if (child.nodeType === child.ELEMENT_NODE) {
53
+ var tag = child.nodeName;
54
+ var tagAttributes_2 = {};
55
+ Array.prototype.forEach.call(child.attributes, function (attr) {
56
+ tagAttributes_2[attr.name] = attr.value;
57
+ });
58
+ parsedNodes.push({ tag: tag, tagAttributes: tagAttributes_2, child: child });
59
+ }
60
+ });
61
+ return parsedNodes;
62
+ };
63
+ export { parseNodes, parseGenericNodes };
50
64
  //# sourceMappingURL=nodeParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeParser.js","sourceRoot":"","sources":["../../src/helpers/nodeParser.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,IAAM,UAAU,GAAG,UACjB,KAA4B,EAC5B,MAAW;IAEX,IAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,KAAc;;QACjD,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,YAAY,EAAE;YACzC,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;YAEzB,IAAI,eAAa,GAAQ,EAAE,CAAC;YAC5B,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,IAAU;gBACxD,eAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,IAAM,MAAI,G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,CAAC,CAAC,MAAM,GAAG,CAAC,EAClC;oBACA,OAAO,MAAM,CAAC,MAAK,CAAC,CAAC,MAAM,CAAC;iBAC7B;gBAED,eAAa,kCACR,MAAM,CAAC,MAAK,CAAC,GACb,eAAa,KAChB,gBAAgB,QAAE,MAAM,CAAC,MAAK,CAAC,0CAAE,IAAI,GACtC,CAAC;aACH;YAED,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,KAAA,EAAE,aAAa,iBAAA,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;SACjD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,IAAM,iBAAiB,GAAG,UAAC,KAA4B;IACrD,IAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,KAAc;QACjD,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,YAAY,EAAE;YACzC,IAAI,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;YAEzB,IAAI,eAAa,GAAQ,EAAE,CAAC;YAC5B,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAC,IAAU;gBACxD,eAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,KAAA,EAAE,aAAa,iBAAA,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;SACjD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -31,4 +31,5 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, };
34
+ import Dashboard from "./Dashboard";
35
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, };
package/dist/index.js CHANGED
@@ -31,5 +31,6 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
- export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, };
34
+ import Dashboard from "./Dashboard";
35
+ export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, };
35
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B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C5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EACL,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,eAAe,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,6BAA6B,EAC7B,QAAQ,EACR,SAAS,EACT,SAAS,GACV,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Action.ts ADDED
@@ -0,0 +1,23 @@
1
+ class Action {
2
+ _name: string | null = null;
3
+ get name(): string | null {
4
+ return this._name;
5
+ }
6
+
7
+ _parms: string | null = null;
8
+ get parms(): string | null {
9
+ return this._parms;
10
+ }
11
+
12
+ constructor(attributes: any) {
13
+ if (attributes.name) {
14
+ this._name = attributes.name;
15
+ }
16
+
17
+ if (attributes.parms) {
18
+ this._parms = attributes.parms;
19
+ }
20
+ }
21
+ }
22
+
23
+ export default Action;
@@ -0,0 +1,31 @@
1
+ import Action from "./Action";
2
+ import { parseGenericNodes } from "./helpers/nodeParser";
3
+
4
+ class Dashboard {
5
+ _string: string | null = null;
6
+ get string(): string | null {
7
+ return this._string;
8
+ }
9
+
10
+ _actions: Action[] = [];
11
+ get actions(): Action[] {
12
+ return this._actions;
13
+ }
14
+
15
+ constructor(xml: string) {
16
+ const parser = new DOMParser();
17
+ const view: Document = parser.parseFromString(xml, "text/xml");
18
+ this._string = view.documentElement.getAttribute("string");
19
+ const documentElement = view.documentElement;
20
+
21
+ const actionsParsed = parseGenericNodes(documentElement.childNodes);
22
+
23
+ actionsParsed.forEach((nodeParsed) => {
24
+ if (nodeParsed.tag === "action") {
25
+ this._actions.push(new Action(nodeParsed.tagAttributes));
26
+ }
27
+ });
28
+ }
29
+ }
30
+
31
+ export default Dashboard;
package/src/Indicator.ts CHANGED
@@ -2,6 +2,22 @@ import Field from "./Field";
2
2
 
3
3
  class Indicator extends Field {
4
4
  _nolabel: boolean = true;
5
+
6
+ _card: boolean;
7
+ get card(): boolean {
8
+ return this._card;
9
+ }
10
+ set card(value: boolean) {
11
+ this._card = value;
12
+ }
13
+
14
+ constructor(props: any) {
15
+ super(props);
16
+ this._card = false;
17
+ if (this._parsedWidgetProps) {
18
+ this._card = this._parsedWidgetProps.card;
19
+ }
20
+ }
5
21
  }
6
22
 
7
23
 
@@ -54,4 +54,21 @@ const parseNodes = (
54
54
  return parsedNodes;
55
55
  };
56
56
 
57
- export { parseNodes };
57
+ const parseGenericNodes = (nodes: NodeListOf<ChildNode>): ParsedNode[] => {
58
+ const parsedNodes: ParsedNode[] = [];
59
+ Array.prototype.forEach.call(nodes, (child: Element) => {
60
+ if (child.nodeType === child.ELEMENT_NODE) {
61
+ let tag = child.nodeName;
62
+
63
+ let tagAttributes: any = {};
64
+ Array.prototype.forEach.call(child.attributes, (attr: Attr) => {
65
+ tagAttributes[attr.name] = attr.value;
66
+ });
67
+
68
+ parsedNodes.push({ tag, tagAttributes, child });
69
+ }
70
+ });
71
+ return parsedNodes;
72
+ };
73
+
74
+ export { parseNodes, parseGenericNodes };
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ import { parseContext } from "./helpers/contextParser";
31
31
  import { transformDomainForChildWidget } from "./helpers/domainParser";
32
32
  import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
+ import Dashboard from "./Dashboard";
34
35
 
35
36
  export {
36
37
  Char,
@@ -66,4 +67,5 @@ export {
66
67
  transformDomainForChildWidget,
67
68
  Timeline,
68
69
  Indicator,
70
+ Dashboard,
69
71
  };
@@ -0,0 +1,28 @@
1
+ import Dashboard from "../Dashboard";
2
+
3
+ describe("A Dashboard", () => {
4
+ it("should parse a basic XML with three actions", () => {
5
+ const xml = `<?xml version="1.0"?>
6
+ <dashboard string="My dashboard">
7
+ <action name="1497" parms="{ x: 0, y: 0, w: 1, h: 2, static: true }" />
8
+ <action name="1496" parms="{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }" />
9
+ <action name="1321" parms="{ x: 4, y: 0, w: 1, h: 2 }" />
10
+ </dashboard>
11
+ `;
12
+
13
+ const dashboard = new Dashboard(xml);
14
+
15
+ expect(dashboard.string).toBe("My dashboard");
16
+ expect(dashboard.actions.length).toBe(3);
17
+ expect(dashboard.actions[0].name).toBe("1497");
18
+ expect(dashboard.actions[1].name).toBe("1496");
19
+ expect(dashboard.actions[2].name).toBe("1321");
20
+ expect(dashboard.actions[0].parms).toBe(
21
+ "{ x: 0, y: 0, w: 1, h: 2, static: true }"
22
+ );
23
+ expect(dashboard.actions[1].parms).toBe(
24
+ "{ x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }"
25
+ );
26
+ expect(dashboard.actions[2].parms).toBe("{ x: 4, y: 0, w: 1, h: 2 }");
27
+ });
28
+ });
@@ -0,0 +1,27 @@
1
+ import WidgetFactory from "../WidgetFactory";
2
+ import Indicator from "../Indicator";
3
+
4
+ describe("An Indicator", () => {
5
+ it("should create a Indicator widget from factory", () => {
6
+ const widgetFactory = new WidgetFactory();
7
+
8
+ const widget = widgetFactory.createWidget("indicator", {});
9
+ expect(widget).toBeInstanceOf(Indicator);
10
+
11
+ });
12
+
13
+ it('should have card as false as default', () => {
14
+ const widgetFactory = new WidgetFactory();
15
+ const widget = widgetFactory.createWidget("indicator", {});
16
+ expect(widget.card).toBe(false);
17
+ });
18
+
19
+ it('should parse widget props', () => {
20
+ const widgetFactory = new WidgetFactory();
21
+ const props = {
22
+ widget_props: "{'card': true}"
23
+ };
24
+ const widget = widgetFactory.createWidget("indicator", props);
25
+ expect(widget.card).toBe(true);
26
+ });
27
+ });