@yuneta/gobj-ui 7.32.4 → 7.32.6

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.
@@ -13,6 +13,13 @@ import {install_dom_double} from "../test/dom_double.js";
13
13
 
14
14
  install_dom_double();
15
15
 
16
+ import i18next from "i18next";
17
+
18
+ await i18next.init({lng: "es", resources: {
19
+ es: {translation: {rows: "filas", rows_one: "fila"}},
20
+ en: {translation: {rows: "rows", rows_one: "row"}}
21
+ }});
22
+
16
23
  import {
17
24
  YUI_TABLE_FILTER_MIN_WIDTH,
18
25
  yui_table_paging,
@@ -48,7 +55,7 @@ describe("the paging", () => {
48
55
  });
49
56
 
50
57
  describe("the row count", () => {
51
- function page_module(word)
58
+ function page_module()
52
59
  {
53
60
  let bindings = [];
54
61
  return {
@@ -57,8 +64,8 @@ describe("the row count", () => {
57
64
  modules: {
58
65
  localize: {
59
66
  langBind(path, cb) {
60
- bindings.push(path);
61
- cb(word);
67
+ bindings.push({path, cb});
68
+ cb("ignored");
62
69
  }
63
70
  }
64
71
  }
@@ -66,39 +73,50 @@ describe("the row count", () => {
66
73
  };
67
74
  }
68
75
 
69
- test("says every active row, all pages together, in the table's language", () => {
76
+ test("says every active row, all pages together, in the app's plural", () => {
70
77
  let counter = yui_table_paging().paginationCounter;
71
- let page = page_module("filas");
78
+ let page = page_module();
72
79
  let $el = counter.call(page, 25, 26, 2, 113, 5);
73
80
  expect($el.textContent).toBe("113 filas");
74
- expect(page.bindings).toEqual(["pagination|counter|rows"]);
81
+ expect(page.bindings.map((b) => b.path)).toEqual(["pagination|counter|rows"]);
82
+ expect(counter.call(page_module(), 25, 1, 1, 1, 1).textContent).toBe("1 fila");
83
+ });
84
+
85
+ test("a language change asks the word again", async () => {
86
+ let counter = yui_table_paging().paginationCounter;
87
+ let page = page_module();
88
+ let $el = counter.call(page, 25, 1, 1, 1, 1);
89
+ await i18next.changeLanguage("en");
90
+ page.bindings[0].cb("ignored");
91
+ expect($el.textContent).toBe("1 row");
92
+ await i18next.changeLanguage("es");
75
93
  });
76
94
 
77
95
  test("an empty table says 0", () => {
78
96
  let counter = yui_table_paging().paginationCounter;
79
- let $el = counter.call(page_module("rows"), 25, 0, 1, 0, 0);
80
- expect($el.textContent).toBe("0 rows");
97
+ let $el = counter.call(page_module(), 25, 0, 1, 0, 0);
98
+ expect($el.textContent).toBe("0 filas");
81
99
  });
82
100
 
83
101
  test("is a node, never a string Tabulator would put in as html", () => {
84
102
  let counter = yui_table_paging().paginationCounter;
85
- let $el = counter.call(page_module("rows"), 25, 1, 1, 3, 1);
103
+ let $el = counter.call(page_module(), 25, 1, 1, 3, 1);
86
104
  expect(typeof $el).toBe("object");
87
105
  expect($el.className).toBe("YUI_TABLE_COUNT");
88
106
  });
89
107
 
90
108
  test("with a filter on, the rows it leaves of the rows the table holds", () => {
91
109
  let counter = yui_table_paging().paginationCounter;
92
- let page = page_module("rows");
110
+ let page = page_module();
93
111
  page.table.getDataCount = () => 27;
94
- expect(counter.call(page, 25, 1, 1, 12, 1).textContent).toBe("12 / 27 rows");
95
- expect(counter.call(page, 25, 1, 1, 27, 2).textContent).toBe("27 rows");
112
+ expect(counter.call(page, 25, 1, 1, 12, 1).textContent).toBe("12 / 27 filas");
113
+ expect(counter.call(page, 25, 1, 1, 27, 2).textContent).toBe("27 filas");
96
114
  });
97
115
 
98
- test("without a localize module it still counts, in English", () => {
116
+ test("without a localize module it still counts", () => {
99
117
  let counter = yui_table_paging().paginationCounter;
100
118
  let $el = counter.call({}, 25, 1, 1, 3, 1);
101
- expect($el.textContent).toBe("3 rows");
119
+ expect($el.textContent).toBe("3 filas");
102
120
  });
103
121
  });
104
122