You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.7 KiB

4 years ago
  1. ## Issues
  2. - Report issues or feature requests on [GitHub Issues](https://github.com/js-cookie/js-cookie/issues).
  3. - If reporting a bug, please add a [simplified example](http://sscce.org/).
  4. ## Pull requests
  5. - Create a new topic branch for every separate change you make.
  6. - Create a test case if you are fixing a bug or implementing an important feature.
  7. - Make sure the build runs successfully.
  8. ## Development
  9. ### Tools
  10. We use the following tools for development:
  11. - [Qunit](http://qunitjs.com/) for tests.
  12. - [NodeJS](http://nodejs.org/download/) required to run grunt.
  13. - [Grunt](http://gruntjs.com/getting-started) for task management.
  14. ### Getting started
  15. Install [NodeJS](http://nodejs.org/).
  16. Install globally grunt-cli using the following command:
  17. $ npm install -g grunt-cli
  18. Browse to the project root directory and install the dev dependencies:
  19. $ npm install -d
  20. To execute the build and tests run the following command in the root of the project:
  21. $ grunt
  22. You should see a green message in the console:
  23. Done, without errors.
  24. ### Tests
  25. You can also run the tests in the browser.
  26. Start a test server from the project root:
  27. $ grunt connect:tests
  28. This will automatically open the test suite at http://127.0.0.1:10000 in the default browser, with livereload enabled.
  29. _Note: we recommend cleaning all the browser cookies before running the tests, that can avoid false positive failures._
  30. ### Automatic build
  31. You can build automatically after a file change using the following command:
  32. $ grunt watch
  33. ## Integration with server-side
  34. js-cookie allows integrating the encoding test suite with solutions written in other server-side languages. To integrate successfully, the server-side solution need to execute the `test/encoding.html` file in it's integration testing routine with a web automation tool, like [Selenium](http://www.seleniumhq.org/). js-cookie test suite exposes an API to make this happen.
  35. ### ?integration_baseurl
  36. Specify the base url to pass the cookies into the server through a query string. If `integration_baseurl` query is not present, then js-cookie will assume there's no server.
  37. ### window.global_test_results
  38. After the test suite has finished, js-cookie exposes the global `window.global_test_results` property containing an Object Literal that represents the [QUnit's details](http://api.qunitjs.com/QUnit.done/). js-cookie also adds an additional property representing an Array containing the tests data.
  39. ### Handling requests
  40. When js-cookie encoding tests are executed, it will request a url in the server through an iframe representing each test being run. js-cookie expects the server to handle the input and return the proper `Set-Cookie` headers in the response. js-cookie will then read the response and verify if the encoding is consistent with js-cookie default encoding mechanism
  41. js-cookie will send some requests to the server from the baseurl in the format `/encoding?name=<cookie>`, where `<cookie>` represents the cookie-name to be read from the request.
  42. The server should handle those requests, internally parsing the cookie from the request and writing it again. It must set an `application/json` content type containing an object literal in the content body with `name` and `value` keys, each representing the cookie-name and cookie-value decoded by the server-side implementation.
  43. If the server fails to respond with this specification in any request, the related QUnit test will fail. This is to make sure the server-side implementation will always be in sync with js-cookie encoding tests for maximum compatibility.
  44. ### Projects using it
  45. This hook is being used in the following projects:
  46. * [Java Cookie](https://github.com/js-cookie/java-cookie).