-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(merge-conditions): no redundant parentheses
- Loading branch information
Showing
10 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
src/dynamo/expression/logical-operator/merge-conditions.function.spec.ts
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { attribute } from './attribute.function' | ||
import { mergeConditions } from './merge-conditions.function' | ||
|
||
describe('mergeCondition statements', () => { | ||
test('no redundant parentheses for single condition', () => { | ||
const conditionDefinitionFns = [attribute('name').beginsWith('sample')] | ||
|
||
const conditions = mergeConditions('OR', conditionDefinitionFns) | ||
const expression = conditions(undefined, undefined) | ||
expect(expression.statement).toEqual('begins_with (#name, :name)') | ||
}) | ||
|
||
test('no redundant parentheses for multiple condition', () => { | ||
const conditionDefinitionFns = [attribute('name').beginsWith('sample'), attribute('fullName').beginsWith('sample')] | ||
|
||
const conditions = mergeConditions('OR', conditionDefinitionFns) | ||
const expression = conditions(undefined, undefined) | ||
|
||
expect(expression.statement).toEqual('(begins_with (#name, :name) OR begins_with (#fullName, :fullName))') | ||
}) | ||
|
||
test('no redundant parentheses for single condition combined', () => { | ||
const conditionDefinitionFns = [attribute('name').beginsWith('sample'), attribute('fullName').beginsWith('sample')] | ||
|
||
const conditions = mergeConditions('OR', conditionDefinitionFns) | ||
const andConditions = mergeConditions('AND', [conditions]) | ||
const expression = andConditions(undefined, undefined) | ||
expect(expression.statement).toEqual('(begins_with (#name, :name) OR begins_with (#fullName, :fullName))') | ||
}) | ||
}) |
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
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
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
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
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
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
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
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