diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-27 21:10:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-27 21:10:29 +0300 |
commit | da50206243972a4cafcaea7539aed7c6986c775e (patch) | |
tree | 4078741032de093f8ae49a13ec984271402f2f35 /spec/frontend/helpers | |
parent | eef9c80f1c3e81fcb50c51d8f419ab095d4747fd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/helpers')
-rw-r--r-- | spec/frontend/helpers/local_storage_helper.js | 2 | ||||
-rw-r--r-- | spec/frontend/helpers/local_storage_helper_spec.js | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/spec/frontend/helpers/local_storage_helper.js b/spec/frontend/helpers/local_storage_helper.js index a66c31d1353..cd39b660bfd 100644 --- a/spec/frontend/helpers/local_storage_helper.js +++ b/spec/frontend/helpers/local_storage_helper.js @@ -10,7 +10,7 @@ */ const useLocalStorage = fn => { const origLocalStorage = window.localStorage; - let currentLocalStorage; + let currentLocalStorage = origLocalStorage; Object.defineProperty(window, 'localStorage', { get: () => currentLocalStorage, diff --git a/spec/frontend/helpers/local_storage_helper_spec.js b/spec/frontend/helpers/local_storage_helper_spec.js index 18aec0f329a..6b44ea3a4c3 100644 --- a/spec/frontend/helpers/local_storage_helper_spec.js +++ b/spec/frontend/helpers/local_storage_helper_spec.js @@ -1,8 +1,15 @@ import { useLocalStorageSpy } from './local_storage_helper'; -useLocalStorageSpy(); +describe('block before helper is installed', () => { + it('should leave original localStorage intact', () => { + expect(localStorage.getItem).toEqual(expect.any(Function)); + expect(jest.isMockFunction(localStorage.getItem)).toBe(false); + }); +}); describe('localStorage helper', () => { + useLocalStorageSpy(); + it('mocks localStorage but works exactly like original localStorage', () => { localStorage.setItem('test', 'testing'); localStorage.setItem('test2', 'testing'); |