Skip to content

Commit

Permalink
refactor(test): reverted tests in favor of integration tests for subm…
Browse files Browse the repository at this point in the history
…itQueryButton component
  • Loading branch information
asalem1 committed Jun 10, 2020
1 parent cc4d672 commit df60034
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 104 deletions.
89 changes: 0 additions & 89 deletions ui/src/shared/apis/query.test.ts

This file was deleted.

23 changes: 8 additions & 15 deletions ui/src/shared/apis/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export interface RunQueryErrorResult {
code?: string
}

export const getQueryResult = (
export const runQuery = (
orgID: string,
query: string,
controller: AbortController,
extern?: File
): Promise<Response> => {
extern?: File,
abortController?: AbortController
): CancelBox<RunQueryResult> => {
const url = `${API_BASE_PATH}api/v2/query?${new URLSearchParams({orgID})}`

const headers = {
Expand All @@ -52,23 +52,16 @@ export const getQueryResult = (
dialect: {annotations: ['group', 'datatype', 'default']},
}

return fetch(url, {
const controller = abortController || new AbortController()

const response = fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(body),
signal: controller.signal,
})
}

export const runQuery = (
orgID: string,
query: string,
extern?: File,
abortController?: AbortController
): CancelBox<RunQueryResult> => {
const controller = abortController || new AbortController()

const promise = getQueryResult(orgID, query, controller, extern)
const promise = response
.then(processResponse)
.catch(e =>
e.name === 'AbortError'
Expand Down

0 comments on commit df60034

Please sign in to comment.