|
|
@@ -135,6 +135,45 @@ describe('Format value with value mappings', () => {
|
|
|
expect(result.text).toEqual('1-20');
|
|
|
});
|
|
|
|
|
|
+ it('should return if value is null and value to text mapping value is null', () => {
|
|
|
+ const valueMappings: ValueMapping[] = [
|
|
|
+ { id: 0, operator: '', text: '1-20', type: MappingType.RangeToText, from: '1', to: '20' },
|
|
|
+ { id: 1, operator: '', text: '<NULL>', type: MappingType.ValueToText, value: 'null' },
|
|
|
+ ];
|
|
|
+ const value = null;
|
|
|
+ const { instance } = setup({ valueMappings });
|
|
|
+
|
|
|
+ const result = instance.getFirstFormattedValueMapping(valueMappings, value);
|
|
|
+
|
|
|
+ expect(result.text).toEqual('<NULL>');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return if value is null and range to text mapping from is null', () => {
|
|
|
+ const valueMappings: ValueMapping[] = [
|
|
|
+ { id: 0, operator: '', text: '<NULL>', type: MappingType.RangeToText, from: 'null', to: '10' },
|
|
|
+ { id: 1, operator: '', text: 'elva', type: MappingType.ValueToText, value: '11' },
|
|
|
+ ];
|
|
|
+ const value = null;
|
|
|
+ const { instance } = setup({ valueMappings });
|
|
|
+
|
|
|
+ const result = instance.getFirstFormattedValueMapping(valueMappings, value);
|
|
|
+
|
|
|
+ expect(result.text).toEqual('<NULL>');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return if value is null and range to text mapping to is null', () => {
|
|
|
+ const valueMappings: ValueMapping[] = [
|
|
|
+ { id: 0, operator: '', text: '<NULL>', type: MappingType.RangeToText, from: '1', to: 'null' },
|
|
|
+ { id: 1, operator: '', text: 'elva', type: MappingType.ValueToText, value: '11' },
|
|
|
+ ];
|
|
|
+ const value = null;
|
|
|
+ const { instance } = setup({ valueMappings });
|
|
|
+
|
|
|
+ const result = instance.getFirstFormattedValueMapping(valueMappings, value);
|
|
|
+
|
|
|
+ expect(result.text).toEqual('<NULL>');
|
|
|
+ });
|
|
|
+
|
|
|
it('should return rangeToText mapping where value equals to', () => {
|
|
|
const valueMappings: ValueMapping[] = [
|
|
|
{ id: 0, operator: '', text: '1-10', type: MappingType.RangeToText, from: '1', to: '10' },
|