Get suggestions for functions

pull/10616/head
Andrew Watkins 2018-03-23 15:50:20 -07:00 committed by Brandon Farmer
parent 457134d217
commit de1b7caa63
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1 @@
export const getSuggestions = jest.fn(() => Promise.resolve({data: []}))

View File

@ -1,7 +1,11 @@
import React, {PureComponent} from 'react'
import TimeMachine from 'src/ifql/components/TimeMachine'
import {connect} from 'react-redux'
import TimeMachine from 'src/ifql/components/TimeMachine'
import {getSuggestions} from 'src/ifql/apis'
interface Links {
self: string
suggestions: string
@ -12,6 +16,24 @@ interface Props {
}
export class IFQLPage extends PureComponent<Props, {}> {
constructor(props) {
super(props)
this.state = {
funcs: [],
}
}
public async componentDidMount() {
const {suggestions} = this.props.links
try {
const {data} = await getSuggestions(suggestions)
this.setState({funcs: data})
} catch (error) {
console.error('Could not get function suggestions: ', error)
}
}
public render() {
return (
<div className="page">

View File

@ -4,6 +4,8 @@ import {shallow} from 'enzyme'
import {IFQLPage} from 'src/ifql/containers/IFQLPage'
import TimeMachine from 'src/ifql/components/TimeMachine'
jest.mock('src/ifql/apis', () => require('mocks/ifql/apis'))
const setup = () => {
const props = {
links: {