2020-12-02 01:20:00 -05:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2022-01-07 20:16:24 -05:00
|
|
|
import { convertFilter } from '@superset-ui/core';
|
2019-05-23 16:05:01 -04:00
|
|
|
|
|
|
|
describe('convertFilter', () => {
|
|
|
|
it('should handle unary filter', () => {
|
|
|
|
expect(
|
|
|
|
convertFilter({
|
|
|
|
expressionType: 'SIMPLE',
|
|
|
|
clause: 'WHERE',
|
|
|
|
subject: 'topping',
|
|
|
|
operator: 'IS NOT NULL',
|
|
|
|
}),
|
|
|
|
).toEqual({
|
|
|
|
col: 'topping',
|
|
|
|
op: 'IS NOT NULL',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should convert binary filter', () => {
|
|
|
|
expect(
|
|
|
|
convertFilter({
|
|
|
|
expressionType: 'SIMPLE',
|
|
|
|
clause: 'WHERE',
|
|
|
|
subject: 'topping',
|
2020-07-24 07:18:45 -04:00
|
|
|
operator: '==',
|
2019-05-23 16:05:01 -04:00
|
|
|
comparator: 'grass jelly',
|
|
|
|
}),
|
|
|
|
).toEqual({
|
|
|
|
col: 'topping',
|
2020-07-24 07:18:45 -04:00
|
|
|
op: '==',
|
2019-05-23 16:05:01 -04:00
|
|
|
val: 'grass jelly',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should convert set filter', () => {
|
|
|
|
expect(
|
|
|
|
convertFilter({
|
|
|
|
expressionType: 'SIMPLE',
|
|
|
|
clause: 'WHERE',
|
|
|
|
subject: 'toppings',
|
2020-04-27 12:45:36 -04:00
|
|
|
operator: 'IN',
|
2019-05-23 16:05:01 -04:00
|
|
|
comparator: ['boba', 'grass jelly'],
|
|
|
|
}),
|
|
|
|
).toEqual({
|
|
|
|
col: 'toppings',
|
2020-04-27 12:45:36 -04:00
|
|
|
op: 'IN',
|
2019-05-23 16:05:01 -04:00
|
|
|
val: ['boba', 'grass jelly'],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|