druid/web-console/src/react-table/react-table-utils.spec.ts
Vadim Ogievetsky 6fd28fc185
Web console: split the Ingestion view into two views: Supervisors and Tasks (#14395)
* init split

* don't crash if unable to get running tasks

* update snapshots

* push down state into call

* googies

* simplify

* update e2e tests

* feedback fixes

* update e2e tests

* better icons

* fix test

* adjust colors
2023-06-14 10:42:30 -07:00

80 lines
2.3 KiB
TypeScript

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
sqlQueryCustomTableFilter,
stringToTableFilters,
tableFiltersToString,
} from './react-table-utils';
describe('react-table-utils', () => {
describe('sqlQueryCustomTableFilter', () => {
it('works with contains', () => {
expect(
String(
sqlQueryCustomTableFilter({
id: 'datasource',
value: `Hello`,
}),
),
).toEqual(`LOWER("datasource") LIKE '%hello%'`);
});
it('works with exact', () => {
expect(
String(
sqlQueryCustomTableFilter({
id: 'datasource',
value: `=Hello`,
}),
),
).toEqual(`"datasource" = 'Hello'`);
});
it('works with less than or equal', () => {
expect(
String(
sqlQueryCustomTableFilter({
id: 'datasource',
value: `<=Hello`,
}),
),
).toEqual(`"datasource" <= 'Hello'`);
});
});
it('tableFiltersToString', () => {
expect(
tableFiltersToString([
{ id: 'x', value: '~y' },
{ id: 'z', value: '=w&' },
]),
).toEqual('x~y&z=w%26');
});
it('stringToTableFilters', () => {
expect(stringToTableFilters(undefined)).toEqual([]);
expect(stringToTableFilters('')).toEqual([]);
expect(stringToTableFilters('x~y')).toEqual([{ id: 'x', value: '~y' }]);
expect(stringToTableFilters('x~y&z=w%26')).toEqual([
{ id: 'x', value: '~y' },
{ id: 'z', value: '=w&' },
]);
});
});