Add getSuggestions AJAX call to chronograf FE
parent
00c7d9a6e2
commit
b7cf32873a
|
@ -0,0 +1,12 @@
|
|||
import AJAX from 'src/utils/ajax'
|
||||
|
||||
export const getSuggestions = async (url: string) => {
|
||||
try {
|
||||
return await AJAX({
|
||||
url,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Could not get suggestions', error)
|
||||
throw error
|
||||
}
|
||||
}
|
|
@ -41,7 +41,15 @@ const generateResponseWithLinks = (response, newLinks) => {
|
|||
}
|
||||
|
||||
const AJAX = async (
|
||||
{url, resource, id, method = 'GET', data = {}, params = {}, headers = {}},
|
||||
{
|
||||
url,
|
||||
resource = null,
|
||||
id = null,
|
||||
method = 'GET',
|
||||
data = {},
|
||||
params = {},
|
||||
headers = {},
|
||||
},
|
||||
{excludeBasepath} = {}
|
||||
) => {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import {getSuggestions} from 'src/ifql/apis'
|
||||
import AJAX from 'src/utils/ajax'
|
||||
|
||||
jest.mock('src/utils/ajax', () => require('mocks/utils/ajax'))
|
||||
|
||||
describe('IFQL.Apis', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('getSuggestions', () => {
|
||||
it('is called with the expected body', () => {
|
||||
const url = '/chronograf/v1/suggestions'
|
||||
getSuggestions(url)
|
||||
expect(AJAX).toHaveBeenCalledWith({
|
||||
url,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue