summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorFilipa Lacerda <lacerda.filipa@gmail.com>2017-02-07 20:26:58 +0000
committerFilipa Lacerda <lacerda.filipa@gmail.com>2017-02-07 20:26:58 +0000
commit9aafb2a6d3c1b2588ef0689d6919014150123e64 (patch)
tree7cacce9be6b41b382c028a75a68e648552fb8ad4 /spec/javascripts
parent3848856a5704da1846860acedabbefa5739fdba2 (diff)
parent76b078ceffc2781fc88e80300c526f130ea87fbe (diff)
downloadgitlab-ce-9aafb2a6d3c1b2588ef0689d6919014150123e64.tar.gz
Merge branch 'improve-handleLocationHash-tests' into 'master'
Improve gl.utils.handleLocationHash tests See merge request !9040
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js.es629
1 files changed, 25 insertions, 4 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6
index 61e83d73afb..006ede21093 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');
});
});