Skip to content

Commit

Permalink
Reset 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 14, 2020
1 parent d5204ad commit 88022e5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 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,20 @@ describe('storage manager', function() {

describe('localstorage forbidden access in 3rd-party context', function() {
let errorLogSpy;
const originalLocalStorage = Object.getOwnPropertyDescriptor(window, 'localStorage');
var localStorageMock = {
get: function() {
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 88022e5

Please sign in to comment.