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

Write unit tests #4

Open
amitguptagwl opened this issue Oct 5, 2018 · 7 comments
Open

Write unit tests #4

amitguptagwl opened this issue Oct 5, 2018 · 7 comments
Labels
first-timers-only This issue is suitable for first timers. However, can be picked by any contributors good first issue Good for newcomers help wanted Extra attention is needed

Comments

@amitguptagwl
Copy link
Member

Following cases are tested manually. Need to write unit tests for auto-testing.

Scenarios
auto-create: on

  • [DONE] Cookies are sent to the client
  • Client can send the session-id to the server either in header or cookies
  • Cookies are not created for all the routes but selected : not implemented yet
  • [DONE] When user makes request without cookies : create new
  • [DONE] When user makes request with expired cookies : create new
  • [DONE] When user makes request with about to expire cookies : renew
  • [DONE] When user makes request with invalid session-id : create new

auto-create: off

  • [DONE] When user makes request with invalid session-id : error
  • [DONE] When user makes request for secure page without cookies : redirect to login page
  • [DONE] When user makes request for secure page with cookies : do nothing
  • [DONE] When user makes request for secure page with expired cookies : redirect to login page
  • [DONE] When user makes request for secure page with about to expire cookies : renew cookies

check session_test.js for more detail.

@amitguptagwl amitguptagwl added help wanted Extra attention is needed good first issue Good for newcomers first-timers-only This issue is suitable for first timers. However, can be picked by any contributors labels Oct 5, 2018
@msarfrazanwar
Copy link

Can you link any resource from where I can learn how to do this ?

@amitguptagwl
Copy link
Member Author

You can probably use mocha or jasmine framework to write unit tests. You'll need some library to make HTTP calls. You may use chai & chai-http for this purpose. You may find other good alternatives too but please discuss your tech stack before starting.

Have a look at session_test.js for the sample test. It sets up the server and starts it. Then there is some commented code written for jasmine to test the application. There is some code in chai and chai-http which is used to make a call to the server.

Instead of running the server, you can just test all the files in src folder for their functionality (pure unit tests).

Here are some tutorials which I found using google;

All the best

@l0n3star
Copy link

l0n3star commented Jul 7, 2019

@amitguptagwl do you still need help with this? If so I'd like to take this one.

@amitguptagwl
Copy link
Member Author

@l0n3star yes, plz. check the coverage and go ahead.

@l0n3star
Copy link

l0n3star commented Jul 9, 2019 via email

@amitguptagwl
Copy link
Member Author

sure. jest is good.

@l0n3star
Copy link

l0n3star commented Jul 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only This issue is suitable for first timers. However, can be picked by any contributors good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants