Skip to content
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

Fix/ADF-1166/ESlint errors in tests of utils #155

Merged
merged 2 commits into from
Oct 26, 2022

Conversation

jsconan
Copy link
Contributor

@jsconan jsconan commented Oct 17, 2022

Related to: https://oat-sa.atlassian.net/browse/ADF-1166

Summary

Fix the ESLint error in the unit tests for tao-core-utils.

Note: as the changes are pretty heavy, I split them all into several pull requests.

Details

This pull request only targets the test/util/* part of the library.
The full picture can be seen from the main branch which contains all the fixes: https://github.com/oat-sa/tao-core-sdk-fe.git#fix/ADF-1166/eslint-errors

What has been made:

  • fix errors that can be automated using eslint --fix, then adjust the changes in case by case (mostly string literals)
  • fix the wrong annotations (missing/wrong return or param definition)
  • fix the more complex cases with some refactoring (rest operator instead of .apply())
  • replace var by const or let (but not in all places, only in the touched files when it was not adding too much noise)
  • apply object shorthand instead of duplicated function names
  • apply arrow functions here and there when it helped, but not systematically to reduce the noise

How to test

  • checkout and install the source code npm i
  • run the linter: npm run lint:test, errors and warnings coming from the utils folder should have gone.
  • run the unit tests: npm run test utils
  • install with other repositories, using the following scheme: "@oat-sa/tao-core-sdk": "https://github.com/oat-sa/tao-core-sdk-fe.git#fix/ADF-1166/eslint-errors",, then checking the unit tests and playing with TAO

@github-actions
Copy link

github-actions bot commented Oct 17, 2022

Coverage Report

Totals Coverage
Statements: 90.6% ( 2700 / 2980 )
Methods: 95.01% ( 743 / 782 )

Copy link
Contributor

@shaveko shaveko 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 and tests run well after refactoring, but please check my comment, may be you'll want to fix quotes

console.log(err);
return 'Syntax error!';
}
}

function showResult(expression, result) {
var $expr = $('<p class="expression">' + expression + '</p>');
var $res = $('<p class="result">' + result + '</p>');
var $expr = $(`'<p class="expression">${expression}</p>'`);
Copy link
Contributor

@shaveko shaveko Oct 21, 2022

Choose a reason for hiding this comment

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

Despite the fact $expr is not the same – ' are left in place after the refactoring) this test doesn't fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it applies to a visual test. The extraneous quotes were displayed on the example calculator, they are not part of any test. Not a big issue, but better to fix indeed, the result will look neater.

@github-actions
Copy link

Version

Target Version 1.20.2
Last version 1.20.1

There are 0 BREAKING CHANGE, 0 feature, 0 fix

@jsconan jsconan merged commit 6746492 into develop Oct 26, 2022
@jsconan jsconan deleted the fix/ADF-1166/eslint-errors-utils-tests branch October 26, 2022 06:48
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.

2 participants