You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by cc...@apache.org on 2018/09/11 22:51:21 UTC
[incubator-superset] 04/04: [core] fix SupersetClient dashboard
tests
This is an automated email from the ASF dual-hosted git repository.
ccwilliams pushed a commit to branch chris--ajax-dashboard
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 1b314b46c7c2680e7f19e986fd56f3f479e5d759
Author: Chris Williams <ch...@airbnb.com>
AuthorDate: Mon Sep 10 22:06:13 2018 -0700
[core] fix SupersetClient dashboard tests
---
.../dashboard/components/DashboardBuilder_spec.jsx | 18 +++++++++++++++++-
.../dashboard/reducers/sliceEntities_spec.js | 6 +++---
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx b/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
index 4c3185f..5033988 100644
--- a/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
+++ b/superset/assets/spec/javascripts/dashboard/components/DashboardBuilder_spec.jsx
@@ -1,8 +1,9 @@
import { Provider } from 'react-redux';
import React from 'react';
import { shallow, mount } from 'enzyme';
-import { describe, it } from 'mocha';
+import { describe, it, before, after } from 'mocha';
import { expect } from 'chai';
+import sinon from 'sinon';
import ParentSize from '@vx/responsive/build/components/ParentSize';
import { Sticky, StickyContainer } from 'react-sticky';
@@ -13,6 +14,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,
@@ -25,6 +28,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() {},
diff --git a/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js b/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
index 7e3bb76..891df61 100644
--- a/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
+++ b/superset/assets/spec/javascripts/dashboard/reducers/sliceEntities_spec.js
@@ -26,7 +26,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({
@@ -42,10 +42,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);
});
});