Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Need unit and ci test #58

Open
PeterDaveHello opened this issue Aug 9, 2015 · 9 comments
Open

Need unit and ci test #58

PeterDaveHello opened this issue Aug 9, 2015 · 9 comments

Comments

@PeterDaveHello
Copy link
Contributor

PeterDaveHello commented Aug 9, 2015

Bountysource

@sufuf3
Copy link
Contributor

sufuf3 commented Apr 9, 2017

Hi @PeterDaveHello I want to take this.
The testing framework I would use jasmine.
And the coding style will follow airbnb/javascript .

I want to write the unit test of webServer.js by the Decision table testing as the following.

  • if test / , the status code should show 200 OK.

  • if test /request-new-lib, the status code should show 200 OK and expect body can Match 'GitHub'.

  • if test /about , the status code should show 200 OK.

  • if test /api , the status code should show 200 OK.

  • if test /libraries , the status code should show 200 OK.

  • if test /git_stats , the status code should show 200 OK.

  • If test /gitstats , the status code should show 200 OK.

  • If test /cdnjs.cloudflare.com/, the status code should show 200 OK.

  • If test /libraries/:library, The status code always should show 200 OK.

  • If test /libraries/:library/tutorials:

    • If there is any tutorial in the library, such as backbone.js, the status code should show 200 OK.
    • If there is no tutorial in the library, such as jQuery, the status code should show 500 and expect body can Match 'Tutorial not found!'.
    • If there is no library and no tutorial, the status code should show 500 and expect body can Match 'Something broke!'.
  • If test /libraries/:library/tutorials/:tutorial:

    • If there is a tutorial in the library, such as uri: /libraries/backbone.js/tutorials/real-time-backbone-with-pubnub, the status code should show 200 OK.
    • If there are the tutorials in the library, but the name in tutorials not exist, such as /libraries/backbone.js/tutorials/notexist, the status code should show 404 and expect body can Match 'Tutorial not found!'.
    • If the library does not exist, such as /libraries/notexist/tutorials/notexist, the status code should show 404 and expect body can Match 'Tutorial not found!'.
    • If there is no library and no tutorial, the status code should show 500 and expect body can Match 'Something broke!'.
  • If test /libraries/:library/:version:

    • If the version of the library is correct, the status code should show 200 OK.
    • If the version of the library is not correct, the status code should show 404 and expect body can Match 'library version not found!'.
    • If there is no version and no library in the cdnjs, then the status code should show 200 OK. Because it direct to the search page.
  • otherwise, the status code should show 404.

If you have any suggestions, please let me know.

Thank you.

@PeterDaveHello
Copy link
Contributor Author

This is not what we call "unit test", which should test from the small functions, http status is not in this part actually.

@sufuf3
Copy link
Contributor

sufuf3 commented Apr 11, 2017

I was thought that user may try any strange library name which not includes in CDNJS.
So I was thinking that maybe this should be tested.

If this project does not need test status code, how about test functions as the followings?

  • libraryGitRepoList(library)
  • librarylicensesList(library)
  • libraryAssetsList(library, version)
  • GitHubMetaInfo(library)

If this is OK, I will test the library in CDNJS, the library name not in CDNJS, empty string, null, special characters...etc.
And the version will test the version of the library is correct or not correct, and some special cases, such as special characters, empty string...etc.

If you have any suggestions, please let me know.
Thank you.

@PeterDaveHello
Copy link
Contributor Author

@sufuf3 I think you should figure out what a unit test it.

@sufuf3
Copy link
Contributor

sufuf3 commented Apr 16, 2017

@PeterDaveHello I will try to do as the following steps:

  1. write the test cases for libraryGitRepoList(library), librarylicensesList(library), libraryAssetsList(library, version), GitHubMetaInfo(library), libraryResponse(req, res)
  2. Improving the code refactoring, factoring the function code with the route. During factoring the function, I will follow the coding style of airbnb/javascript.
  3. write test cases for other functions.

The test cases for libraryGitRepoList(library), librarylicensesList(library), libraryAssetsList(library, version), GitHubMetaInfo(library), libraryResponse(req, res) as the followings:

  • libraryGitRepoList(library):
    If the library is in the cdnjs, the value of pathname is as expected.
    If the library is not in the cdnjs, the value of pathname is null.
    If the library value is an empty string or null, the value of pathname is null.
  • librarylicensesList(library):
    If the library is in the cdnjs, the value of licenses is as expected.
    If the library is not in the cdnjs, the value of licenses is null.
    If the library value is an empty string or null, the value of licenses is null.
  • GitHubMetaInfo(library):
    If the library is in the cdnjs, the value of url is as expected.
    If the library is not in the cdnjs, the value of url is null.
    If the library value is an empty string or null, the value of url is null.
  • libraryAssetsList(library, version)
    If the version of the library is correct, the value of assets.selected is "selected".
    If the version of the library is not correct, the value of assets.selected is "".
    If there is no version and no library in the cdnjs, the value of assets.selected is "".
    If the library value is an empty string or null and either as version, the value of assets.selected is "".
  • libraryResponse(req, res)
    This part will test whether the generatePage is as expected.

If it's OK above, I will write the above test cases.
And when I write and find that there is no more attention to the above part, I will increase the coverage.

@MattIPv4
Copy link
Member

Going to keep this open as we still need to implement this.

@MattIPv4 MattIPv4 reopened this Feb 23, 2020
@PeterDaveHello
Copy link
Contributor Author

Feel free to open a new issue for it, as I was removed from the organization without any discussion and respect, just like some other members(I know it's not by you and you're not the one who's in charge for that), I'm now closing ancient issues I'm not working on so that I don't need to receive unnecessary notifications, thanks.

@MattIPv4
Copy link
Member

There is an unsubscribe button that you can use on issues to no longer receive notifications. I would appreciate it if you left these open so we have the original history of the issue in the active issue.

@MattIPv4 MattIPv4 reopened this Feb 23, 2020
@PeterDaveHello
Copy link
Contributor Author

You can refer to this issue for the history, anyway I'll left this opened.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants