Skip to content

Commit

Permalink
Restore window.localStorage property descriptor after each test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Duthil committed Sep 15, 2020
1 parent d5204ad commit cf3f014
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/spec/unit/core/storageManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ describe('storage manager', function() {

describe('localstorage forbidden access in 3rd-party context', function() {
let errorLogSpy;
const originalLocalStorage = { get: () => window.localStorage };
const localStorageMock = { get: () => { throw Error } };

beforeEach(function() {
var mock = {
get: function() {
throw Error;
}
};
Object.defineProperty(window, 'localStorage', mock);
Object.defineProperty(window, 'localStorage', localStorageMock);
errorLogSpy = sinon.spy(utils, 'logError');
});

afterEach(function() {
Object.defineProperty(window, 'localStorage', originalLocalStorage);
errorLogSpy.restore();
})

Expand Down

0 comments on commit cf3f014

Please sign in to comment.