Skip to content

Commit 77f9e08

Browse files
authored
style: Fix formatting in data viewer tests (#1891)
1 parent f0fc8de commit 77f9e08

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

‎src/test/suite/dataViewer.test.ts‎

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import * as assert from 'assert';
22
import * as vm from 'vm';
3-
import type { ColDef, ColumnState, GridOptions, GridState, IFilterOptionDef, ITextFilterParams } from 'ag-grid-community';
3+
import type {
4+
ColDef,
5+
ColumnState,
6+
GridOptions,
7+
GridState,
8+
IFilterOptionDef,
9+
ITextFilterParams,
10+
} from 'ag-grid-community';
411
import { getDataViewerScript } from '../../dataViewer';
512

613
interface SavedViewer {
@@ -270,34 +277,49 @@ suite('Data viewer', () => {
270277
script.prepareViewerColumns(defs);
271278
const params = defs[0].filterParams as ITextFilterParams;
272279
assert.deepStrictEqual(Array.from(params.buttons ?? []), ['reset', 'apply']);
273-
assert.deepStrictEqual(Array.from(params.filterOptions ?? [], option =>
274-
typeof option === 'string' ? option : option.displayKey
275-
), ['empty', 'true', 'false', 'blank']);
276-
assert.deepStrictEqual(Array.from(params.filterOptions ?? [], option =>
277-
typeof option === 'string' ? option : option.displayName
278-
), ['empty', 'True', 'False', 'blank']);
280+
assert.deepStrictEqual(
281+
Array.from(params.filterOptions ?? [], (option) =>
282+
typeof option === 'string' ? option : option.displayKey,
283+
),
284+
['empty', 'true', 'false', 'blank'],
285+
);
286+
assert.deepStrictEqual(
287+
Array.from(params.filterOptions ?? [], (option) =>
288+
typeof option === 'string' ? option : option.displayName,
289+
),
290+
['empty', 'True', 'False', 'blank'],
291+
);
279292
// Preserve AG Grid's "Choose one" and "Blank" labels.
280293
assert.strictEqual(script.getViewerGridOptions(500).localeText?.empty, undefined);
281294
assert.strictEqual(script.getViewerGridOptions(500).localeText?.blank, undefined);
282295
});
283296

284-
for (const [key, expected] of [['true', true], ['false', false]] as const) {
297+
for (const [key, expected] of [
298+
['true', true],
299+
['false', false],
300+
] as const) {
285301
test(`logical ${key} filter matches only its value, excluding NA`, () => {
286302
const script = viewerScript().script;
287303
const defs: ColDef[] = [{ field: '1', type: 'booleanColumn' }];
288304
script.prepareViewerColumns(defs);
289305
const params = defs[0].filterParams as ITextFilterParams;
290-
const option = params.filterOptions?.find((candidate): candidate is IFilterOptionDef =>
291-
typeof candidate !== 'string' && candidate.displayKey === key
306+
const option = params.filterOptions?.find(
307+
(candidate): candidate is IFilterOptionDef =>
308+
typeof candidate !== 'string' && candidate.displayKey === key,
292309
);
293310
assert.ok(option?.predicate);
294311
assert.strictEqual(option.numberOfInputs, 0);
295312
const predicate = option.predicate;
296313
const rows = script.prepareViewerRows(
297-
[true, false, null, undefined].map(value => ({ '1': value })), []
314+
[true, false, null, undefined].map((value) => ({ '1': value })),
315+
[],
316+
);
317+
assert.deepStrictEqual(
318+
rows
319+
.filter((row) => Reflect.apply(predicate, undefined, [[], row['1']]))
320+
.map((row) => row['1']),
321+
[expected],
298322
);
299-
assert.deepStrictEqual(rows.filter(row => Reflect.apply(predicate, undefined, [[], row['1']]))
300-
.map(row => row['1']), [expected]);
301323
});
302324
}
303325

0 commit comments

Comments
 (0)