Fix for #6590: Numeric values in columns sometimes returned as quoted strings (#6591)

* Fix: https://github.com/apache/incubator-superset/issues/6590, also depends on https://github.com/apache-superset/superset-ui/pull/71

* Bumped version of superset-ui-connector

* Added @babel/polyfill import

* Reset mock history before each test, not after each test

* Update CONTRIBUTING.md
This commit is contained in:
Christopher Council
2019-01-14 15:35:28 -08:00
committed by Krist Wongsuphasawat
parent f480a52074
commit 207d9529b2
8 changed files with 31 additions and 15 deletions

View File

@@ -6,6 +6,8 @@ import * as actions from '../../../../src/SqlLab/actions/sqlLab';
import { query } from '../fixtures';
describe('async actions', () => {
const mockBigNumber = '9223372036854775807';
let dispatch;
beforeEach(() => {
@@ -42,7 +44,7 @@ describe('async actions', () => {
describe('fetchQueryResults', () => {
const fetchQueryEndpoint = 'glob:*/superset/results/*';
fetchMock.get(fetchQueryEndpoint, '{ "data": "" }');
fetchMock.get(fetchQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
const makeRequest = () => {
const actionThunk = actions.fetchQueryResults(query);
@@ -65,6 +67,13 @@ describe('async actions', () => {
});
});
it('parses large number result without losing precision', () =>
makeRequest().then(() => {
expect(fetchMock.calls(fetchQueryEndpoint)).toHaveLength(1);
expect(dispatch.callCount).toBe(2);
expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
}));
it('calls querySuccess on fetch success', () =>
makeRequest().then(() => {
expect(dispatch.callCount).toBe(2);
@@ -88,7 +97,7 @@ describe('async actions', () => {
describe('runQuery', () => {
const runQueryEndpoint = 'glob:*/superset/sql_json/*';
fetchMock.post(runQueryEndpoint, { data: '' });
fetchMock.post(runQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
const makeRequest = () => {
const request = actions.runQuery(query);
@@ -111,6 +120,13 @@ describe('async actions', () => {
});
});
it('parses large number result without losing precision', () =>
makeRequest().then(() => {
expect(fetchMock.calls(runQueryEndpoint)).toHaveLength(1);
expect(dispatch.callCount).toBe(2);
expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
}));
it('calls querySuccess on fetch success', () => {
expect.assertions(3);

View File

@@ -25,7 +25,7 @@ function setup() {
}
describe('DashboardTable', () => {
afterEach(fetchMock.resetHistory);
beforeEach(fetchMock.resetHistory);
it('renders a Loading initially', () => {
const wrapper = setup();