-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
30 deletions.
There are no files selected for viewing
74 changes: 44 additions & 30 deletions
74
src/pages/Appearance/Programs/__tests__/getExpressionDescription.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,73 @@ | ||
import {getExpressionDescription} from "../expressionHelper"; | ||
import { getExpressionDescription } from '../expressionHelper' | ||
|
||
const attributes = [ | ||
{ | ||
id: "w75KJ2mc4zz", | ||
name: "First name", | ||
valueType: "TEXT" | ||
id: 'w75KJ2mc4zz', | ||
name: 'First name', | ||
valueType: 'TEXT', | ||
}, | ||
{ | ||
id: "zDhUuAYrxNC", | ||
name: "Last name", | ||
valueType: "TEXT" | ||
id: 'zDhUuAYrxNC', | ||
name: 'Last name', | ||
valueType: 'TEXT', | ||
}, | ||
{ | ||
id: "cejWyOfXge6", | ||
name: "Gender", | ||
valueType: "TEXT" | ||
id: 'cejWyOfXge6', | ||
name: 'Gender', | ||
valueType: 'TEXT', | ||
}, | ||
{ | ||
id: "lZGmxYbs97q", | ||
name: "Unique ID", | ||
valueType: "TEXT" | ||
id: 'lZGmxYbs97q', | ||
name: 'Unique ID', | ||
valueType: 'TEXT', | ||
}, | ||
{ | ||
id: "iESIqZ0R0R0", | ||
name: "Date of birth", | ||
valueType: "DATE" | ||
} | ||
id: 'iESIqZ0R0R0', | ||
name: 'Date of birth', | ||
valueType: 'DATE', | ||
}, | ||
] | ||
|
||
test('From a list of attributes you can get this expression', () => { | ||
const expression = "A{w75KJ2mc4zz} A{zDhUuAYrxNC}, if(A{cejWyOfXge6} == 'Male', 'M', 'F')" | ||
const resultExpression = "First name Last name, if(Gender == 'Male', 'M', 'F')" | ||
expect(getExpressionDescription(expression, attributes)).toMatch(resultExpression) | ||
const expression = | ||
"A{w75KJ2mc4zz} A{zDhUuAYrxNC}, if(A{cejWyOfXge6} == 'Male', 'M', 'F')" | ||
const resultExpression = | ||
"First name Last name, if(Gender == 'Male', 'M', 'F')" | ||
expect(getExpressionDescription(expression, attributes)).toMatch( | ||
resultExpression | ||
) | ||
}) | ||
|
||
test('From a list of attributes you can get this expression', () => { | ||
const expression = "A{w75KJ2mc4zz} + A{zDhUuAYrxNC}" | ||
const resultExpression = "First name + Last name" | ||
expect(getExpressionDescription(expression, attributes)).toMatch(resultExpression) | ||
const expression = 'A{w75KJ2mc4zz} + A{zDhUuAYrxNC}' | ||
const resultExpression = 'First name + Last name' | ||
expect(getExpressionDescription(expression, attributes)).toMatch( | ||
resultExpression | ||
) | ||
}) | ||
|
||
test('From a list of attributes you can get this expression', () => { | ||
const expression = "A{w75KJ2mc4zz} + A{cejWyOfXge6}" | ||
const resultExpression = "First name + Gender" | ||
expect(getExpressionDescription(expression, attributes)).toMatch(resultExpression) | ||
const expression = 'A{w75KJ2mc4zz} + A{cejWyOfXge6}' | ||
const resultExpression = 'First name + Gender' | ||
expect(getExpressionDescription(expression, attributes)).toMatch( | ||
resultExpression | ||
) | ||
}) | ||
|
||
test('From a list of attributes you can get this expression', () => { | ||
const expression = "d2:concatenate(A{w75KJ2mc4zz}, ' ', A{zDhUuAYrxNC})" | ||
const resultExpression = "d2:concatenate(First name, ' ', Last name)" | ||
expect(getExpressionDescription(expression, attributes)).toMatch(resultExpression) | ||
expect(getExpressionDescription(expression, attributes)).toMatch( | ||
resultExpression | ||
) | ||
}) | ||
|
||
test('From a list of attributes you can get this expression', () => { | ||
const expression = "d2:concatenate(A{w75KJ2mc4zz}, ' ', A{zDhUuAYrxNC}, ', ', A{iESIqZ0R0R0})" | ||
const resultExpression = "d2:concatenate(First name, ' ', Last name, ', ', Date of birth)" | ||
expect(getExpressionDescription(expression, attributes)).toMatch(resultExpression) | ||
const expression = | ||
"d2:concatenate(A{w75KJ2mc4zz}, ' ', A{zDhUuAYrxNC}, ', ', A{iESIqZ0R0R0})" | ||
const resultExpression = | ||
"d2:concatenate(First name, ' ', Last name, ', ', Date of birth)" | ||
expect(getExpressionDescription(expression, attributes)).toMatch( | ||
resultExpression | ||
) | ||
}) |