diff options
author | Timotheus Kampik <timotheus.kampik@gmail.com> | 2018-07-28 21:12:05 +0200 |
---|---|---|
committer | Timotheus Kampik <timotheus.kampik@gmail.com> | 2018-07-28 21:12:05 +0200 |
commit | afe46ef74ca43080010c356711193b7dde0df69c (patch) | |
tree | f987c10c41ec8dea09e01ac108fc3d3c66e7cab6 | |
parent | fcd0b78afa01c2bbf6672b463ad78736f9f3681b (diff) | |
download | sphinx-git-afe46ef74ca43080010c356711193b7dde0df69c.tar.gz |
#5186 add tests for `getQueryParameters()`
and fix test description of `urldecode()`
-rw-r--r-- | tests/js/doctools.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/js/doctools.js b/tests/js/doctools.js index 32fd68c10..8533f7148 100644 --- a/tests/js/doctools.js +++ b/tests/js/doctools.js @@ -2,7 +2,7 @@ var DOCUMENTATION_OPTIONS = {}; describe('urldecode', function() { - it('should fail', function() { + it('should correctly decode URLs and replace `+`s with a spaces', function() { var test_encoded_string = '%D1%88%D0%B5%D0%BB%D0%BB%D1%8B+%D1%88%D0%B5%D0%BB%D0%BB%D1%8B'; var test_decoded_string = 'шеллы шеллы'; @@ -10,3 +10,23 @@ describe('urldecode', function() { }); }); + +describe('getQueryParameters', function() { + var paramString = '?q=test+this&check_keywords=yes&area=default'; + var queryParamObject = { + area: ['default'], + check_keywords: ['yes'], + q: ['test this'] + }; + + it('should correctly create query parameter object from string', function() { + expect(jQuery.getQueryParameters(paramString)).toEqual(queryParamObject); + }); + + it('should correctly create query param object from URL params', function() { + history.pushState({}, '_', window.location + paramString); + expect(jQuery.getQueryParameters()).toEqual(queryParamObject); + }); + +}); + |