Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 05ef49f

Browse files
committed
test(js): update table_widget.test.js to use snake_case ordering properties
1 parent 0cad365 commit 05ef49f

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

tests/js/table_widget.test.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ describe('TableWidget', () => {
8282
if (property === 'orderable_columns') {
8383
return ['col1'];
8484
}
85-
if (property === 'sort_context') {
85+
if (property === 'sort_columns') {
86+
return [];
87+
}
88+
if (property === 'sort_ascending') {
8689
return [];
8790
}
8891
return null;
@@ -99,9 +102,8 @@ describe('TableWidget', () => {
99102
const header = el.querySelector('th');
100103
header.click();
101104

102-
expect(model.set).toHaveBeenCalledWith('sort_context', [
103-
{ column: 'col1', ascending: true },
104-
]);
105+
expect(model.set).toHaveBeenCalledWith('sort_ascending', [true]);
106+
expect(model.set).toHaveBeenCalledWith('sort_columns', ['col1']);
105107
expect(model.save_changes).toHaveBeenCalled();
106108
});
107109

@@ -114,8 +116,11 @@ describe('TableWidget', () => {
114116
if (property === 'orderable_columns') {
115117
return ['col1'];
116118
}
117-
if (property === 'sort_context') {
118-
return [{ column: 'col1', ascending: true }];
119+
if (property === 'sort_columns') {
120+
return ['col1'];
121+
}
122+
if (property === 'sort_ascending') {
123+
return [true];
119124
}
120125
return null;
121126
});
@@ -131,9 +136,8 @@ describe('TableWidget', () => {
131136
const header = el.querySelector('th');
132137
header.click();
133138

134-
expect(model.set).toHaveBeenCalledWith('sort_context', [
135-
{ column: 'col1', ascending: false },
136-
]);
139+
expect(model.set).toHaveBeenCalledWith('sort_ascending', [false]);
140+
expect(model.set).toHaveBeenCalledWith('sort_columns', ['col1']);
137141
expect(model.save_changes).toHaveBeenCalled();
138142
});
139143

@@ -146,8 +150,11 @@ describe('TableWidget', () => {
146150
if (property === 'orderable_columns') {
147151
return ['col1'];
148152
}
149-
if (property === 'sort_context') {
150-
return [{ column: 'col1', ascending: false }];
153+
if (property === 'sort_columns') {
154+
return ['col1'];
155+
}
156+
if (property === 'sort_ascending') {
157+
return [false];
151158
}
152159
return null;
153160
});
@@ -163,7 +170,8 @@ describe('TableWidget', () => {
163170
const header = el.querySelector('th');
164171
header.click();
165172

166-
expect(model.set).toHaveBeenCalledWith('sort_context', []);
173+
expect(model.set).toHaveBeenCalledWith('sort_ascending', []);
174+
expect(model.set).toHaveBeenCalledWith('sort_columns', []);
167175
expect(model.save_changes).toHaveBeenCalled();
168176
});
169177

@@ -176,8 +184,11 @@ describe('TableWidget', () => {
176184
if (property === 'orderable_columns') {
177185
return ['col1', 'col2'];
178186
}
179-
if (property === 'sort_context') {
180-
return [{ column: 'col1', ascending: true }];
187+
if (property === 'sort_columns') {
188+
return ['col1'];
189+
}
190+
if (property === 'sort_ascending') {
191+
return [true];
181192
}
182193
return null;
183194
});
@@ -207,8 +218,11 @@ describe('TableWidget', () => {
207218
if (property === 'orderable_columns') {
208219
return ['col1', 'col2'];
209220
}
210-
if (property === 'sort_context') {
211-
return [{ column: 'col1', ascending: true }];
221+
if (property === 'sort_columns') {
222+
return ['col1'];
223+
}
224+
if (property === 'sort_ascending') {
225+
return [true];
212226
}
213227
return null;
214228
});
@@ -232,10 +246,8 @@ describe('TableWidget', () => {
232246
});
233247
header2.dispatchEvent(clickEvent);
234248

235-
expect(model.set).toHaveBeenCalledWith('sort_context', [
236-
{ column: 'col1', ascending: true },
237-
{ column: 'col2', ascending: true },
238-
]);
249+
expect(model.set).toHaveBeenCalledWith('sort_ascending', [true, true]);
250+
expect(model.set).toHaveBeenCalledWith('sort_columns', ['col1', 'col2']);
239251
expect(model.save_changes).toHaveBeenCalled();
240252
});
241253
});
@@ -418,7 +430,10 @@ describe('TableWidget', () => {
418430
// Only actual columns are orderable
419431
return ['col1', 'col10'];
420432
}
421-
if (property === 'sort_context') {
433+
if (property === 'sort_columns') {
434+
return [];
435+
}
436+
if (property === 'sort_ascending') {
422437
return [];
423438
}
424439
return null;

0 commit comments

Comments
 (0)