From 61914a643168d60baa330aa7ee52fe04f34eb802 Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Wed, 11 Apr 2018 17:02:18 -0700 Subject: [PATCH] Add test for defaultRP in the UI on SourceForm Co-authored-by Iris Scholten --- ui/src/sources/components/SourceForm.js | 2 +- ui/src/types/sources.ts | 1 + ui/test/resources.ts | 1 + ui/test/sources/components/SourceForm.test.js | 44 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ui/test/sources/components/SourceForm.test.js diff --git a/ui/src/sources/components/SourceForm.js b/ui/src/sources/components/SourceForm.js index 449201915..db5f92a4a 100644 --- a/ui/src/sources/components/SourceForm.js +++ b/ui/src/sources/components/SourceForm.js @@ -8,7 +8,7 @@ import {insecureSkipVerifyText} from 'shared/copy/tooltipText' import {SUPERADMIN_ROLE} from 'src/auth/Authorized' -const SourceForm = ({ +export const SourceForm = ({ source, editMode, onSubmit, diff --git a/ui/src/types/sources.ts b/ui/src/types/sources.ts index 60d5f8583..21ada7cc0 100644 --- a/ui/src/types/sources.ts +++ b/ui/src/types/sources.ts @@ -13,6 +13,7 @@ export interface Source { links: SourceLinks kapacitors?: Kapacitor[] metaUrl?: string + defaultRP: string } interface SourceLinks { diff --git a/ui/test/resources.ts b/ui/test/resources.ts index 0ae73332c..607e9c312 100644 --- a/ui/test/resources.ts +++ b/ui/test/resources.ts @@ -40,6 +40,7 @@ export const source = { telegraf: 'telegraf', organization: '0', role: 'viewer', + defaultRP: '', links, } diff --git a/ui/test/sources/components/SourceForm.test.js b/ui/test/sources/components/SourceForm.test.js new file mode 100644 index 000000000..8375706d6 --- /dev/null +++ b/ui/test/sources/components/SourceForm.test.js @@ -0,0 +1,44 @@ +import React from 'react' +import {shallow} from 'enzyme' + +import {SourceForm} from 'src/sources/components/SourceForm' + +const setup = (override = {}) => { + const noop = () => {} + const props = { + source: { + url: '', + name: '', + username: '', + password: '', + telegraf: '', + insecureSkipVerify: false, + default: false, + metaUrl: '', + }, + editMode: false, + onSubmit: noop, + onInputChange: noop, + onBlurSourceURL: noop, + isUsingAuth: false, + gotoPurgatory: noop, + isInitialSource: false, + me: {}, + ...override, + } + + const wrapper = shallow() + return {wrapper, props} +} + +describe('Sources.Components.SourceForm', () => { + describe('rendering', () => { + it('renders default retention policy field', () => { + const {wrapper} = setup() + const inputs = wrapper.find('input') + const defaultRP = inputs.find({id: 'defaultRP'}) + + expect(defaultRP.exists()).toBe(true) + }) + }) +})