Skip to content

Commit

Permalink
Another attempt to fix jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Mar 19, 2020
1 parent 5173430 commit c396640
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions superset-frontend/spec/helpers/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ global.sinon.useFakeXMLHttpRequest();

global.window.XMLHttpRequest = global.XMLHttpRequest;
global.window.location = { href: 'about:blank' };

// To bypass "TypeError: Cannot redefine property: assign"
Object.defineProperty(global.window, 'location', {
value: { ...global.window.location, assign: () => {} },
});

global.window.performance = { now: () => new Date().getTime() };
global.$ = require('jquery')(global.window);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,20 @@ describe('SaveModal', () => {

describe('should always reload or redirect', () => {
let wrapper;
let windowLocation;

beforeEach(() => {
wrapper = getWrapper();
windowLocation = window.location;
// To bypass "TypeError: Cannot redefine property: assign"
Object.defineProperty(window, 'location', {
value: { ...windowLocation, assign: () => {} },
});
sinon.stub(window.location, 'assign');
});
afterEach(() => {
window.location.assign.restore();
Object.defineProperty(window, 'location', windowLocation);
});

it('Save & go to dashboard', done => {
Expand Down

0 comments on commit c396640

Please sign in to comment.