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

Add more unit tests for built-in middleware and ExpressReceiver #357

Merged
merged 5 commits into from
Jan 3, 2020

Conversation

seratch
Copy link
Member

@seratch seratch commented Dec 23, 2019

Summary

This pull request adds more unit tests for ExpressReceiver and built-in middleware. It improves the code coverage by 5.44% 5.8% (from 73.00% to 78.80%).
https://codecov.io/gh/seratch/bolt/tree/702ca613900a36ca09147cf086c67cc58522c4c7

The only changes introduced to the main code is allowing users to access the following functions.

  • respondToSslCheck
  • respondToUrlVerification

I believe there is no issue with it. But, if there is a plan to change the internals of ExpressReceiver a lot, I can put it on hold until then. I myself don't have such plans.

Requirements (place an x in each [ ])

@seratch seratch added the tests M-T: Testing work only label Dec 23, 2019
@seratch seratch self-assigned this Dec 23, 2019
@codecov
Copy link

codecov bot commented Dec 23, 2019

Codecov Report

Merging #357 into master will increase coverage by 10.2%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #357       +/-   ##
==========================================
+ Coverage      73%   83.2%   +10.19%     
==========================================
  Files           7       7               
  Lines         500     500               
  Branches      146     146               
==========================================
+ Hits          365     416       +51     
+ Misses        103      55       -48     
+ Partials       32      29        -3
Impacted Files Coverage Δ
src/ExpressReceiver.ts 69.23% <100%> (+18.26%) ⬆️
src/App.ts 86.47% <0%> (+8.23%) ⬆️
src/middleware/builtin.ts 82.4% <0%> (+14.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ff92ed...4e5084e. Read the comment docs.

}

it('should verify requests', async () => {
let errorResult: any;
runWithValidRequest(buildExpressRequest(), errorResult);
const state: any = {};
Copy link
Member Author

Choose a reason for hiding this comment

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

The tests I added before failed to detect failures while parsing the body. This pull request also fixes it.

@@ -29,8 +29,9 @@
"build": "tsc",
"build:clean": "shx rm -rf ./dist ./coverage ./.nyc_output",
"lint": "tslint --project .",
"test-lint": "tslint \"src/**/*.spec.ts\" && tslint \"src/test-helpers.ts\"",
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed tslint has not been enabled for unit tests. I've enabled it and fixed all the warnings.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine to run linting on our tests as it encourages we use the same code style.

Question, why don't we just include linting the tests as part of the lint command instead of creating a test-lint command. I think we would just need to update https://github.com/slackapi/bolt/blob/master/tsconfig.json#L66-L67

Copy link
Member Author

Choose a reason for hiding this comment

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

@stevengill In my understanding, the reason why they're excluded is to avoid including spec files in npm package. Do you have some ideas to simplify the configuration without breaking anything?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I didn't know that. Thanks for the explanation.

@seratch
Copy link
Member Author

seratch commented Dec 24, 2019

  • Coverage 73% 83.2% +10.19%

10.2 % coverage increased 🎉

Copy link
Member

@stevengill stevengill left a comment

Choose a reason for hiding this comment

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

Looks Great! Left one minor note

@@ -29,8 +29,9 @@
"build": "tsc",
"build:clean": "shx rm -rf ./dist ./coverage ./.nyc_output",
"lint": "tslint --project .",
"test-lint": "tslint \"src/**/*.spec.ts\" && tslint \"src/test-helpers.ts\"",
Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine to run linting on our tests as it encourages we use the same code style.

Question, why don't we just include linting the tests as part of the lint command instead of creating a test-lint command. I think we would just need to update https://github.com/slackapi/bolt/blob/master/tsconfig.json#L66-L67

@seratch
Copy link
Member Author

seratch commented Jan 3, 2020

@stevengill Thanks for your review. Can you approve this PR?

@seratch seratch merged commit 3d59cf7 into slackapi:master Jan 3, 2020
@seratch seratch deleted the more-tests branch January 3, 2020 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests M-T: Testing work only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants