From 475ee04ca13fb40792aa5b49373e1e47b3658771 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Wed, 18 Apr 2018 12:32:19 -0700 Subject: [PATCH] Add test for from component --- ui/mocks/ifql/apis/index.ts | 3 +++ ui/test/ifql/components/From.test.tsx | 29 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 ui/test/ifql/components/From.test.tsx diff --git a/ui/mocks/ifql/apis/index.ts b/ui/mocks/ifql/apis/index.ts index 2fd7bba2ef..7e1b404d82 100644 --- a/ui/mocks/ifql/apis/index.ts +++ b/ui/mocks/ifql/apis/index.ts @@ -2,3 +2,6 @@ jest.mock('src/utils/ajax', () => require('mocks/utils/ajax')) export const getSuggestions = jest.fn(() => Promise.resolve([])) export const getAST = jest.fn(() => Promise.resolve({})) +export const getDatabases = jest.fn(() => + Promise.resolve(['db1', 'db2', 'db3']) +) diff --git a/ui/test/ifql/components/From.test.tsx b/ui/test/ifql/components/From.test.tsx new file mode 100644 index 0000000000..6c4a2d09da --- /dev/null +++ b/ui/test/ifql/components/From.test.tsx @@ -0,0 +1,29 @@ +import React from 'react' +import {shallow} from 'enzyme' +import From from 'src/ifql/components/From' + +jest.mock('src/ifql/apis', () => require('mocks/ifql/apis')) + +const setup = () => { + const props = { + funcID: '1', + argKey: 'db', + value: 'db1', + onChangeArg: () => {}, + } + + const wrapper = shallow() + + return { + wrapper, + } +} + +describe('IFQL.Components.From', () => { + describe('rendering', () => { + it('renders without errors', () => { + const {wrapper} = setup() + expect(wrapper.exists()).toBe(true) + }) + }) +})