summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2017-02-07 12:09:26 -0600
committerClement Ho <ClemMakesApps@gmail.com>2017-02-07 12:09:26 -0600
commit76b078ceffc2781fc88e80300c526f130ea87fbe (patch)
treecabdf48242813fa672f24092e77221d6e870eb17
parentbc13687c7e374116e4830d004b82e9960d3a55cc (diff)
downloadgitlab-ce-improve-handleLocationHash-tests.tar.gz
Improve gl.utils.handleLocationHash testsimprove-handleLocationHash-tests
-rw-r--r--changelogs/unreleased/improve-handleLocationHash-tests.yml4
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js.es629
2 files changed, 29 insertions, 4 deletions
diff --git a/changelogs/unreleased/improve-handleLocationHash-tests.yml b/changelogs/unreleased/improve-handleLocationHash-tests.yml
new file mode 100644
index 00000000000..8ae3dfe079c
--- /dev/null
+++ b/changelogs/unreleased/improve-handleLocationHash-tests.yml
@@ -0,0 +1,4 @@
+---
+title: Improve gl.utils.handleLocationHash tests
+merge_request:
+author:
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6
index ff70664546d..bf3bc622cdc 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js.es6
+++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6
@@ -43,14 +43,35 @@ require('~/lib/utils/common_utils');
describe('gl.utils.handleLocationHash', () => {
beforeEach(() => {
- window.history.pushState({}, null, '#definição');
+ spyOn(window.document, 'getElementById').and.callThrough();
});
+ function expectGetElementIdToHaveBeenCalledWith(elementId) {
+ expect(window.document.getElementById).toHaveBeenCalledWith(elementId);
+ }
+
it('decodes hash parameter', () => {
- spyOn(window.document, 'getElementById').and.callThrough();
+ window.history.pushState({}, null, '#random-hash');
+ gl.utils.handleLocationHash();
+
+ expectGetElementIdToHaveBeenCalledWith('random-hash');
+ expectGetElementIdToHaveBeenCalledWith('user-content-random-hash');
+ });
+
+ it('decodes cyrillic hash parameter', () => {
+ window.history.pushState({}, null, '#definição');
gl.utils.handleLocationHash();
- expect(window.document.getElementById).toHaveBeenCalledWith('definição');
- expect(window.document.getElementById).toHaveBeenCalledWith('user-content-definição');
+
+ expectGetElementIdToHaveBeenCalledWith('definição');
+ expectGetElementIdToHaveBeenCalledWith('user-content-definição');
+ });
+
+ it('decodes encoded cyrillic hash parameter', () => {
+ window.history.pushState({}, null, '#defini%C3%A7%C3%A3o');
+ gl.utils.handleLocationHash();
+
+ expectGetElementIdToHaveBeenCalledWith('definição');
+ expectGetElementIdToHaveBeenCalledWith('user-content-definição');
});
});