Skip to content

Commit

Permalink
add bigint spec for getChartDataRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Oct 25, 2022
1 parent 8dbea45 commit 28ee764
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions superset-frontend/src/components/Chart/chartActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ describe('chart actions', () => {
);
expect(dispatch.args[0][0].type).toBe(actions.CHART_UPDATE_STARTED);
});

it('should handle the bigint without regression', async () => {
getChartDataUriStub.restore();
const mockBigIntUrl = '/mock/chart/data/bigint';
const expectedBigNumber = '9223372036854775807';
fetchMock.post(mockBigIntUrl, `{ "value": ${expectedBigNumber} }`, {
overwriteRoutes: true,
});
getChartDataUriStub = sinon
.stub(exploreUtils, 'getChartDataUri')
.callsFake(() => URI(mockBigIntUrl));

const { json } = await actions.getChartDataRequest({
formData: fakeMetadata,
});

expect(fetchMock.calls(mockBigIntUrl)).toHaveLength(1);
expect(json.value.toString()).toEqual(expectedBigNumber);
});
});

describe('legacy API', () => {
Expand Down Expand Up @@ -194,5 +213,24 @@ describe('chart actions', () => {
setupDefaultFetchMock();
});
});

it('should handle the bigint without regression', async () => {
getExploreUrlStub.restore();
const mockBigIntUrl = '/mock/chart/data/bigint';
const expectedBigNumber = '9223372036854775807';
fetchMock.post(mockBigIntUrl, `{ "value": ${expectedBigNumber} }`, {
overwriteRoutes: true,
});
getExploreUrlStub = sinon
.stub(exploreUtils, 'getExploreUrl')
.callsFake(() => mockBigIntUrl);

const { json } = await actions.getChartDataRequest({
formData: fakeMetadata,
});

expect(fetchMock.calls(mockBigIntUrl)).toHaveLength(1);
expect(json.result[0].value.toString()).toEqual(expectedBigNumber);
});
});
});

0 comments on commit 28ee764

Please sign in to comment.