-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rule-engine): support allow not involve attributes should be true
- Loading branch information
1 parent
757a0e5
commit 41b647d
Showing
3 changed files
with
126 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,4 +166,59 @@ describe('@zodash/rule-engine', () => { | |
description: true, | ||
}); | ||
}); | ||
|
||
it('if key not in rules, should be always true', () => { | ||
const rules: IRuleNode[] = [ | ||
{ | ||
type: 'Attr', | ||
value: 'method', | ||
children: [ | ||
{ | ||
type: 'Value', | ||
value: 1, | ||
children: [ | ||
{ | ||
type: 'Attr', | ||
value: 'chat_id', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const runner = engine.create.sync(rules); | ||
|
||
expect( | ||
runner.run({ | ||
client: 1, | ||
method: 1, | ||
email: '[email protected]', | ||
chat_id: '666', | ||
is_group: false, | ||
}), | ||
).toEqual({ | ||
client: true, | ||
method: true, | ||
email: true, | ||
chat_id: true, | ||
is_group: true, | ||
}); | ||
|
||
expect( | ||
runner.run({ | ||
client: 1, | ||
method: 2, | ||
email: '[email protected]', | ||
chat_id: '666', | ||
is_group: false, | ||
}), | ||
).toEqual({ | ||
client: true, | ||
method: true, | ||
email: true, | ||
chat_id: false, | ||
is_group: true, | ||
}); | ||
}); | ||
}); |
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