-
Notifications
You must be signed in to change notification settings - Fork 83
[FSSDK-11095] rewrite condition_tree_evaluator tests in Typescript #994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FSSDK-11095] rewrite condition_tree_evaluator tests in Typescript #994
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Few minor change suggestions
@@ -0,0 +1,230 @@ | |||
/**************************************************************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use this copyright
/**
- Copyright 2025, Optimizely
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- https://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
*/
value: 'CA', | ||
}; | ||
|
||
describe('lib/core/condition_tree_evaluator', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's get rid of this and the next describe blocks, these are not necessary.
|
||
it('should return the result of negating the first condition, and ignore any additional conditions', function() { | ||
let result = conditionTreeEvaluator.evaluate(['not', '1', '2', '1'], function(id) { | ||
return String(id) === '1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of converting id to string here, maybe we can add (id: string) in the function signature?
}); | ||
expect(result).toBe(false); | ||
result = conditionTreeEvaluator.evaluate(['not', '1', '2', '1'], function(id) { | ||
return String(id) === '2'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here
}); | ||
expect(result).toBe(true); | ||
result = conditionTreeEvaluator.evaluate(['not', '1', '2', '3'], function(id) { | ||
return String(id) === '1' ? null : String(id) === '3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
lib/core/condition_tree_evaluator/index.tests.js
with Typescriptmocha + sinon + chai
tovitest
PC: Didn't touch the old test case.
Issues