Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-11-14 18:35:29 +0300
committerPhil Hughes <me@iamphill.com>2017-11-14 18:35:29 +0300
commitbe4abe7719a500852ce4f913d345e9b3e8794dc3 (patch)
tree03cc5bb43e1cd83a4a5ee6263545e4f532a4c6e8 /spec/javascripts/lib/utils/common_utils_spec.js
parent62287fec4f3dcfce99a1c8e083efb799720d97f2 (diff)
Stops page reload when changing tabs or pages - uses API requests instead
Diffstat (limited to 'spec/javascripts/lib/utils/common_utils_spec.js')
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js
index a5298be5669..6dad5d6b6bd 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js
+++ b/spec/javascripts/lib/utils/common_utils_spec.js
@@ -183,6 +183,36 @@ describe('common_utils', () => {
});
});
+ describe('historyPushState', () => {
+ afterEach(() => {
+ window.history.replaceState({}, null, null);
+ });
+
+ it('should call pushState with the correct path', () => {
+ spyOn(window.history, 'pushState');
+
+ commonUtils.historyPushState('newpath?page=2');
+
+ expect(window.history.pushState).toHaveBeenCalled();
+ expect(window.history.pushState.calls.allArgs()[0][2]).toContain('newpath?page=2');
+ });
+ });
+
+ describe('parseQueryStringIntoObject', () => {
+ it('should return object with query parameters', () => {
+ expect(commonUtils.parseQueryStringIntoObject('scope=all&page=2')).toEqual({ scope: 'all', page: '2' });
+ expect(commonUtils.parseQueryStringIntoObject('scope=all')).toEqual({ scope: 'all' });
+ expect(commonUtils.parseQueryStringIntoObject()).toEqual({});
+ });
+ });
+
+ describe('buildUrlWithCurrentLocation', () => {
+ it('should build an url with current location and given parameters', () => {
+ expect(commonUtils.buildUrlWithCurrentLocation()).toEqual(window.location.pathname);
+ expect(commonUtils.buildUrlWithCurrentLocation('?page=2')).toEqual(`${window.location.pathname}?page=2`);
+ });
+ });
+
describe('getParameterByName', () => {
beforeEach(() => {
window.history.pushState({}, null, '?scope=all&p=2');