Skip to content

[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

Merged

Conversation

esrakartalOpt
Copy link
Contributor

@esrakartalOpt esrakartalOpt commented Jan 28, 2025

Summary

  • Rewrote test case lib/core/condition_tree_evaluator/index.tests.js with Typescript
  • Converted it from mocha + sinon + chai to vitest

PC: Didn't touch the old test case.

Issues

  • FSSDK-11095

@coveralls
Copy link

coveralls commented Jan 28, 2025

Coverage Status

coverage: 81.83%. remained the same
when pulling a607621 on esra/vitest/FSSDK-11095_rewrite_condition_tree_test
into 493b181 on master.

Copy link
Contributor

@raju-opti raju-opti left a 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 @@
/****************************************************************************
Copy link
Contributor

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() {
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor

@raju-opti raju-opti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@esrakartalOpt esrakartalOpt merged commit fd9c9ed into master Jan 29, 2025
16 of 20 checks passed
@esrakartalOpt esrakartalOpt deleted the esra/vitest/FSSDK-11095_rewrite_condition_tree_test branch January 29, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants