@yuneta/gobj-ui 7.25.18 → 7.25.20
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.
- package/README.md +87 -8
- package/dist/gobj-ui.cjs.js +151 -43
- package/dist/gobj-ui.es.js +151 -43
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +52 -4
- package/src/c_yui_json.js +28 -5
- package/src/c_yui_json_pad.js +3 -2
- package/src/c_yui_node.js +71 -0
- package/src/c_yui_schema_editor.js +34 -11
- package/src/c_yui_treedb_graph.js +24 -10
- package/src/c_yui_treedb_topic_with_form.js +24 -0
- package/src/c_yui_treedb_topics.js +22 -9
- package/src/c_yui_uplot.js +10 -5
- package/src/form_json_expand.wiring.test.js +204 -0
- package/src/g6_graphs_write_owed.wiring.test.js +114 -0
- package/src/node_nav_events.wiring.test.js +150 -0
- package/src/schema_editor_reload.wiring.test.js +37 -0
- package/src/schema_editor_transport.wiring.test.js +89 -5
- package/src/treedb_graph_writes.wiring.test.js +38 -4
- package/src/treedb_topics_transport.wiring.test.js +89 -0
- package/src/uplot_add_serie.test.js +92 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* uplot_add_serie.test.js
|
|
3
|
+
*
|
|
4
|
+
* C_YUI_UPLOT's EV_ADD_SERIE gives a series the palette's stroke
|
|
5
|
+
* and fill only when the host gave none. It did it through
|
|
6
|
+
* kw_get_str(KW_CREATE), which reads a stroke that is a FUNCTION
|
|
7
|
+
* (uPlot takes one, and a gradient) as a value of the wrong type:
|
|
8
|
+
* since gobj-js 7.25.5, which logs that as C does, every series
|
|
9
|
+
* added with one logged an error.
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2026, ArtGins.
|
|
12
|
+
* All Rights Reserved.
|
|
13
|
+
***********************************************************************/
|
|
14
|
+
import {describe, test, expect, beforeAll, beforeEach, vi} from "vitest";
|
|
15
|
+
import {install_dom_double} from "../test/dom_double.js";
|
|
16
|
+
|
|
17
|
+
install_dom_double();
|
|
18
|
+
|
|
19
|
+
/* uPlot draws on a canvas the document double does not have: the
|
|
20
|
+
* chart gets a stand-in, and the test writes its own over it. */
|
|
21
|
+
vi.mock("uplot", () => ({
|
|
22
|
+
default: class {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.series = [{}];
|
|
25
|
+
}
|
|
26
|
+
setSize() {}
|
|
27
|
+
addSeries() {}
|
|
28
|
+
destroy() {}
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
gobj_start_up, gobj_create_yuno, gobj_create_pure_child, gclass_create,
|
|
34
|
+
gobj_send_event, gobj_write_attr, set_log_callback, SDATA_END,
|
|
35
|
+
} = await import("@yuneta/gobj-js");
|
|
36
|
+
const {register_c_yui_uplot} = await import("./c_yui_uplot.js");
|
|
37
|
+
|
|
38
|
+
const logged = [];
|
|
39
|
+
let yuno = null;
|
|
40
|
+
|
|
41
|
+
beforeAll(() => {
|
|
42
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
43
|
+
set_log_callback((level, msg) => {
|
|
44
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
45
|
+
});
|
|
46
|
+
gclass_create("C_TEST_UPLOT_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
47
|
+
register_c_yui_uplot();
|
|
48
|
+
yuno = gobj_create_yuno("uplot_yuno", "C_TEST_UPLOT_HOST", {});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
logged.length = 0;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let seq = 0;
|
|
56
|
+
|
|
57
|
+
/* The chart, with uPlot replaced by what EV_ADD_SERIE asks of it. */
|
|
58
|
+
function build()
|
|
59
|
+
{
|
|
60
|
+
const chart = gobj_create_pure_child(`chart_${++seq}`, "C_YUI_UPLOT", {}, yuno);
|
|
61
|
+
const added = [];
|
|
62
|
+
gobj_write_attr(chart, "uplot", {
|
|
63
|
+
series: [{}],
|
|
64
|
+
addSeries: (kw) => {
|
|
65
|
+
added.push(kw);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
logged.length = 0;
|
|
69
|
+
return {chart, added};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe("EV_ADD_SERIE", () => {
|
|
73
|
+
|
|
74
|
+
test("a series with no colours takes the palette's", () => {
|
|
75
|
+
const {chart, added} = build();
|
|
76
|
+
gobj_send_event(chart, "EV_ADD_SERIE", {id: "a", label: "A"}, chart);
|
|
77
|
+
expect(added.length).toBe(1);
|
|
78
|
+
expect(typeof added[0].stroke).toBe("string");
|
|
79
|
+
expect(added[0].stroke.length).toBeGreaterThan(0);
|
|
80
|
+
expect(logged.filter((l) => l.level === "error")).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("a stroke and a fill that are functions are kept, and nothing is logged", () => {
|
|
84
|
+
const {chart, added} = build();
|
|
85
|
+
const stroke = () => "red";
|
|
86
|
+
const fill = () => "pink";
|
|
87
|
+
gobj_send_event(chart, "EV_ADD_SERIE", {id: "b", stroke, fill}, chart);
|
|
88
|
+
expect(added[0].stroke).toBe(stroke);
|
|
89
|
+
expect(added[0].fill).toBe(fill);
|
|
90
|
+
expect(logged.filter((l) => l.level === "error")).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
});
|