|
|
@ -6,7 +6,7 @@ import UITypes from './UITypes'; |
|
|
|
|
|
|
|
|
|
|
|
describe('Formula parsing and type validation', () => { |
|
|
|
describe('Formula parsing and type validation', () => { |
|
|
|
it('Simple formula', async () => { |
|
|
|
it('Simple formula', async () => { |
|
|
|
const result = validateFormulaAndExtractTreeWithType({ |
|
|
|
const result = await validateFormulaAndExtractTreeWithType({ |
|
|
|
formula: '1 + 2', |
|
|
|
formula: '1 + 2', |
|
|
|
columns: [], |
|
|
|
columns: [], |
|
|
|
clientOrSqlUi: 'mysql2', |
|
|
|
clientOrSqlUi: 'mysql2', |
|
|
@ -16,7 +16,7 @@ describe('Formula parsing and type validation', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Formula with IF condition', async () => { |
|
|
|
it('Formula with IF condition', async () => { |
|
|
|
const result = validateFormulaAndExtractTreeWithType({ |
|
|
|
const result = await validateFormulaAndExtractTreeWithType({ |
|
|
|
formula: 'IF({column}, "Found", BLANK())', |
|
|
|
formula: 'IF({column}, "Found", BLANK())', |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -31,7 +31,7 @@ describe('Formula parsing and type validation', () => { |
|
|
|
expect(result.dataType).toEqual(FormulaDataTypes.STRING); |
|
|
|
expect(result.dataType).toEqual(FormulaDataTypes.STRING); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('Complex formula', async () => { |
|
|
|
it('Complex formula', async () => { |
|
|
|
const result = validateFormulaAndExtractTreeWithType({ |
|
|
|
const result = await validateFormulaAndExtractTreeWithType({ |
|
|
|
formula: |
|
|
|
formula: |
|
|
|
'SWITCH({column2},"value1",IF({column1}, "Found", BLANK()),"value2", 2)', |
|
|
|
'SWITCH({column2},"value1",IF({column1}, "Found", BLANK()),"value2", 2)', |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -51,7 +51,7 @@ describe('Formula parsing and type validation', () => { |
|
|
|
|
|
|
|
|
|
|
|
expect(result.dataType).toEqual(FormulaDataTypes.STRING); |
|
|
|
expect(result.dataType).toEqual(FormulaDataTypes.STRING); |
|
|
|
|
|
|
|
|
|
|
|
const result1 = validateFormulaAndExtractTreeWithType({ |
|
|
|
const result1 = await validateFormulaAndExtractTreeWithType({ |
|
|
|
formula: 'SWITCH({column2},"value1",IF({column1}, 1, 2),"value2", 2)', |
|
|
|
formula: 'SWITCH({column2},"value1",IF({column1}, 1, 2),"value2", 2)', |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|