Skip to content

Commit

Permalink
[core] fix SupersetClient dashboard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
williaster committed Sep 18, 2018
1 parent 9289ca9 commit e071734
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Provider } from 'react-redux';
import React from 'react';
import { shallow, mount } from 'enzyme';
import { expect } from 'chai';
import sinon from 'sinon';

import ParentSize from '@vx/responsive/build/components/ParentSize';
import { Sticky, StickyContainer } from 'react-sticky';
Expand All @@ -12,6 +13,8 @@ import DashboardBuilder from '../../../../src/dashboard/components/DashboardBuil
import DashboardComponent from '../../../../src/dashboard/containers/DashboardComponent';
import DashboardHeader from '../../../../src/dashboard/containers/DashboardHeader';
import DashboardGrid from '../../../../src/dashboard/containers/DashboardGrid';
import * as dashboardStateActions from '../../../../src/dashboard/actions/dashboardState';

import WithDragDropContext from '../helpers/WithDragDropContext';
import {
dashboardLayout as undoableDashboardLayout,
Expand All @@ -24,6 +27,19 @@ const dashboardLayout = undoableDashboardLayout.present;
const layoutWithTabs = undoableDashboardLayoutWithTabs.present;

describe('DashboardBuilder', () => {
let favStarStub;

before(() => {
// this is invoked on mount, so we stub it instead of making a request
favStarStub = sinon
.stub(dashboardStateActions, 'fetchFaveStar')
.returns({ type: 'mock-action' });
});

after(() => {
favStarStub.restore();
});

const props = {
dashboardLayout,
deleteTopLevelTabs() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('sliceEntities reducer', () => {
it('should set slices', () => {
const result = sliceEntitiesReducer(
{ slices: { a: {} } },
{ type: SET_ALL_SLICES, slices: { 1: {}, 2: {} } },
{ type: SET_ALL_SLICES, payload: { slices: { 1: {}, 2: {} } } },
);

expect(result.slices).to.deep.equal({
Expand All @@ -41,10 +41,10 @@ describe('sliceEntities reducer', () => {
{},
{
type: FETCH_ALL_SLICES_FAILED,
error: { responseJSON: { message: 'errorrr' } },
payload: { error: 'failed' },
},
);
expect(result.isLoading).to.equal(false);
expect(result.errorMessage.indexOf('errorrr')).to.be.above(-1);
expect(result.errorMessage.indexOf('failed')).to.be.above(-1);
});
});

0 comments on commit e071734

Please sign in to comment.