File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,20 @@ describe('Engine', () => {
102102 expect ( rule2 . conditions . all . length ) . to . equal ( 2 )
103103 } )
104104
105+ it ( 'updates rule incorrectly' , async ( ) => {
106+ const rule1 = new Rule ( factories . rule ( { name : 'rule1' } ) )
107+ engine . addRule ( rule1 )
108+
109+ rule1 . conditions = { all : [ ] } // Rule.conditions should not be set to a value that is not an instance of Condition
110+ engine . updateRule ( rule1 )
111+
112+ const successSpy = sandbox . spy ( )
113+ rule1 . on ( 'success' , successSpy )
114+ await engine . run ( )
115+ const ruleResult = successSpy . getCall ( 0 ) . args [ 2 ]
116+ expect ( ( ) => JSON . stringify ( ruleResult ) ) . to . throw ( / t o J S O N i s n o t a f u n c t i o n / )
117+ } )
118+
105119 it ( 'should throw error if rule not found' , ( ) => {
106120 const rule1 = new Rule ( factories . rule ( { name : 'rule1' } ) )
107121 engine . addRule ( rule1 )
You can’t perform that action at this time.
0 commit comments