Skip to content

Commit

Permalink
merge conflicts (#20959)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese authored Jul 19, 2018
1 parent d19079f commit 8ea7af9
Show file tree
Hide file tree
Showing 21 changed files with 1,244 additions and 601 deletions.
601 changes: 387 additions & 214 deletions src/ui/public/field_editor/__snapshots__/field_editor.test.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,26 @@
import { PureComponent } from 'react';
import PropTypes from 'prop-types';

import {
convertSampleInput
} from '../../../../lib';
export const convertSampleInput = (converter, inputs) => {
let error = null;
let samples = [];

try {
samples = inputs.map(input => {
return {
input,
output: converter(input),
};
});
} catch(e) {
error = `An error occurred while trying to use this format configuration: ${e.message}`;
}

return {
error,
samples,
};
};

export class DefaultFormatEditor extends PureComponent {
static propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { DefaultFormatEditor } from './default';
import { DefaultFormatEditor, convertSampleInput } from './default';

const fieldType = 'number';
const format = {
Expand All @@ -31,6 +31,39 @@ const onChange = jest.fn();
const onError = jest.fn();

describe('DefaultFormatEditor', () => {

describe('convertSampleInput', () => {
const converter = (input) => {
if(isNaN(input)) {
throw {
message: 'Input is not a number'
};
} else {
return input * 2;
}
};

it('should convert a set of inputs', () => {
const inputs = [1, 10, 15];
const output = convertSampleInput(converter, inputs);

expect(output.error).toEqual(null);
expect(JSON.stringify(output.samples)).toEqual(JSON.stringify([
{ input: 1, output: 2 },
{ input: 10, output: 20 },
{ input: 15, output: 30 },
]));
});

it('should return error if converter throws one', () => {
const inputs = [1, 10, 15, 'invalid'];
const output = convertSampleInput(converter, inputs);

expect(output.error).toEqual('An error occurred while trying to use this format configuration: Input is not a number');
expect(JSON.stringify(output.samples)).toEqual(JSON.stringify([]));
});
});

it('should render nothing', async () => {
const component = shallow(
<DefaultFormatEditor
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@

export { ScriptingDisabledCallOut } from './disabled_call_out';
export { ScriptingWarningCallOut } from './warning_call_out';
export { ScriptingHelpFlyout } from './help_flyout';
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ScriptingHelpFlyout should render normally 1`] = `
<EuiFlyout
data-test-subj="scriptedFieldsHelpFlyout"
hideCloseButton={false}
onClose={[Function]}
ownFocus={false}
size="m"
>
<EuiFlyoutBody>
<EuiTabbedContent
initialSelectedTab={
Object {
"content": <Unknown />,
"data-test-subj": "syntaxTab",
"id": "syntax",
"name": "Syntax",
}
}
tabs={
Array [
Object {
"content": <Unknown />,
"data-test-subj": "syntaxTab",
"id": "syntax",
"name": "Syntax",
},
Object {
"content": <TestScript
executeScript={[Function]}
indexPattern={Object {}}
lang="painless"
name="myScriptedField"
script={undefined}
/>,
"data-test-subj": "testTab",
"id": "test",
"name": "Preview results",
},
]
}
/>
</EuiFlyoutBody>
</EuiFlyout>
`;

exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = `""`;
Loading

0 comments on commit 8ea7af9

Please sign in to comment.