Get suggestions for functions
parent
457134d217
commit
de1b7caa63
|
@ -0,0 +1 @@
|
|||
export const getSuggestions = jest.fn(() => Promise.resolve({data: []}))
|
|
@ -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">
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue