From 69fdcc83c506986c2954924e81605e6095e17a24 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 6 Jan 2021 22:11:22 +0000 Subject: [PATCH] chore(NA): move canvas plugin tests out of __tests__ folder (#87519) * chore(NA): move canvas plugin tests out of __tests__ folder * chore(NA): fix types import on fixtures * chore(NA): rename helpers to test_helpers Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../elasticsearch.js | 0 .../elasticsearch_plugin.js | 0 .../function_specs.ts | 6 +- .../fixtures => __fixtures__}/kibana.js | 0 .../fixtures => __fixtures__}/workpads.ts | 2 +- .../functions/browser/markdown.test.js | 6 +- .../fixtures => __fixtures__}/test_filters.js | 0 .../test_pointseries.js | 0 .../fixtures => __fixtures__}/test_styles.js | 2 +- .../fixtures => __fixtures__}/test_tables.ts | 2 +- .../functions/common/__tests__/compare.js | 128 ------------------ .../functions/common/all.test.js | 2 +- .../functions/common/alterColumn.test.js | 4 +- .../functions/common/any.test.js | 2 +- .../functions/common/as.test.js | 2 +- .../functions/common/axis_config.test.js | 4 +- .../functions/common/case.test.js | 2 +- .../functions/common/clear.test.js | 4 +- .../functions/common/columns.test.js | 4 +- .../functions/common/compare.test.js | 127 +++++++++++++++++ .../functions/common/container_style.test.js | 2 +- .../functions/common/context.test.js | 4 +- .../functions/common/csv.test.js | 2 +- .../functions/common/date.test.js | 2 +- .../functions/common/do.test.js | 2 +- .../functions/common/dropdown_control.test.js | 4 +- .../functions/common/eq.test.js | 2 +- .../functions/common/exactly.test.js | 4 +- .../functions/common/filterrows.test.js | 4 +- .../functions/common/formatdate.test.js | 2 +- .../functions/common/formatnumber.test.js | 2 +- .../functions/common/getCell.test.js | 4 +- .../functions/common/gt.test.js | 2 +- .../functions/common/gte.test.js | 2 +- .../functions/common/head.test.js | 4 +- .../functions/common/if.test.js | 2 +- .../{__tests__/image.js => image.test.js} | 14 +- .../functions/common/join_rows.test.js | 4 +- .../functions/common/lt.test.js | 2 +- .../functions/common/lte.test.js | 2 +- .../functions/common/mapColumn.test.js | 4 +- .../functions/common/math.test.js | 4 +- .../functions/common/metric.test.js | 4 +- .../functions/common/neq.test.js | 2 +- .../functions/common/ply.test.js | 4 +- .../progress.js => progress.test.js} | 11 +- .../functions/common/render.test.js | 6 +- .../functions/common/repeat_image.test.js | 2 +- .../functions/common/replace.test.js | 2 +- .../functions/common/reveal_image.test.js | 2 +- .../functions/common/rounddate.test.js | 2 +- .../functions/common/rowCount.test.js | 4 +- .../functions/common/series_style.test.js | 2 +- .../functions/common/sort.test.js | 4 +- .../functions/common/staticColumn.test.js | 4 +- .../functions/common/string.test.js | 2 +- .../functions/common/switch.test.js | 2 +- .../functions/common/table.test.js | 6 +- .../functions/common/tail.test.js | 4 +- .../functions/common/timefilter.test.js | 4 +- .../common/timefilter_control.test.js | 2 +- .../server/get_expression_type.test.js | 2 +- .../functions/server/pointseries.test.js | 2 +- .../datacolumn/__tests__/get_form_object.js | 35 ----- .../datacolumn/get_form_object.test.js | 30 ++++ .../canvas/common/lib/autocomplete.test.ts | 14 +- .../canvas/common/lib/get_field_type.test.ts | 2 +- .../canvas/common/lib/handlebars.test.js | 2 +- .../__snapshots__/export_app.test.tsx.snap | 0 .../{__tests__ => }/export_app.test.tsx | 8 +- .../{__tests__ => }/download.test.tsx | 2 +- .../workpad_header/share_menu/utils.test.ts | 2 +- .../canvas/public/functions/pie.test.js | 6 +- .../canvas/public/functions/plot.test.js | 6 +- .../plot/get_flot_axis_config.test.js | 2 +- .../functions/plot/get_font_spec.test.js | 2 +- .../canvas/public/lib/clipboard.test.ts | 2 +- .../{__tests__ => }/in_flight.test.ts | 9 +- .../{__tests__ => }/workpad_autoplay.test.ts | 12 +- .../{__tests__ => }/workpad_refresh.test.ts | 12 +- .../collectors/workpad_collector.test.ts | 2 +- .../canvas/server/routes/workpad/get.test.ts | 2 +- .../server/routes/workpad/update.test.ts | 2 +- .../__snapshots__/shareable.test.tsx.snap | 0 .../api/{__tests__ => }/shareable.test.tsx | 6 +- .../__snapshots__/app.test.tsx.snap | 0 .../components/{__tests__ => }/app.test.tsx | 10 +- .../{__tests__ => }/canvas.test.tsx | 8 +- .../footer/__stories__/scrubber.stories.tsx | 2 +- .../components/{__tests__ => }/page.test.tsx | 2 +- .../function_wrapper.js | 0 91 files changed, 308 insertions(+), 316 deletions(-) rename x-pack/plugins/canvas/{__tests__/fixtures => __fixtures__}/elasticsearch.js (100%) rename x-pack/plugins/canvas/{__tests__/fixtures => __fixtures__}/elasticsearch_plugin.js (100%) rename x-pack/plugins/canvas/{__tests__/fixtures => __fixtures__}/function_specs.ts (63%) rename x-pack/plugins/canvas/{__tests__/fixtures => __fixtures__}/kibana.js (100%) rename x-pack/plugins/canvas/{__tests__/fixtures => __fixtures__}/workpads.ts (99%) rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/fixtures => __fixtures__}/test_filters.js (100%) rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/fixtures => __fixtures__}/test_pointseries.js (100%) rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/fixtures => __fixtures__}/test_styles.js (96%) rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/fixtures => __fixtures__}/test_tables.ts (98%) delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/compare.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/functions/common/compare.test.js rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/image.js => image.test.js} (84%) rename x-pack/plugins/canvas/canvas_plugin_src/functions/common/{__tests__/progress.js => progress.test.js} (93%) delete mode 100644 x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/__tests__/get_form_object.js create mode 100644 x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/get_form_object.test.js rename x-pack/plugins/canvas/public/apps/export/export/{__tests__ => }/__snapshots__/export_app.test.tsx.snap (100%) rename x-pack/plugins/canvas/public/apps/export/export/{__tests__ => }/export_app.test.tsx (84%) rename x-pack/plugins/canvas/public/components/download/{__tests__ => }/download.test.tsx (95%) rename x-pack/plugins/canvas/public/state/middleware/{__tests__ => }/in_flight.test.ts (93%) rename x-pack/plugins/canvas/public/state/middleware/{__tests__ => }/workpad_autoplay.test.ts (91%) rename x-pack/plugins/canvas/public/state/middleware/{__tests__ => }/workpad_refresh.test.ts (92%) rename x-pack/plugins/canvas/shareable_runtime/api/{__tests__ => }/__snapshots__/shareable.test.tsx.snap (100%) rename x-pack/plugins/canvas/shareable_runtime/api/{__tests__ => }/shareable.test.tsx (96%) rename x-pack/plugins/canvas/shareable_runtime/components/{__tests__ => }/__snapshots__/app.test.tsx.snap (100%) rename x-pack/plugins/canvas/shareable_runtime/components/{__tests__ => }/app.test.tsx (95%) rename x-pack/plugins/canvas/shareable_runtime/components/{__tests__ => }/canvas.test.tsx (84%) rename x-pack/plugins/canvas/shareable_runtime/components/{__tests__ => }/page.test.tsx (93%) rename x-pack/plugins/canvas/{__tests__/helpers => test_helpers}/function_wrapper.js (100%) diff --git a/x-pack/plugins/canvas/__tests__/fixtures/elasticsearch.js b/x-pack/plugins/canvas/__fixtures__/elasticsearch.js similarity index 100% rename from x-pack/plugins/canvas/__tests__/fixtures/elasticsearch.js rename to x-pack/plugins/canvas/__fixtures__/elasticsearch.js diff --git a/x-pack/plugins/canvas/__tests__/fixtures/elasticsearch_plugin.js b/x-pack/plugins/canvas/__fixtures__/elasticsearch_plugin.js similarity index 100% rename from x-pack/plugins/canvas/__tests__/fixtures/elasticsearch_plugin.js rename to x-pack/plugins/canvas/__fixtures__/elasticsearch_plugin.js diff --git a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.ts b/x-pack/plugins/canvas/__fixtures__/function_specs.ts similarity index 63% rename from x-pack/plugins/canvas/__tests__/fixtures/function_specs.ts rename to x-pack/plugins/canvas/__fixtures__/function_specs.ts index 125dd20a66d8a..2d35fdae48985 100644 --- a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.ts +++ b/x-pack/plugins/canvas/__fixtures__/function_specs.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functions as browserFns } from '../../canvas_plugin_src/functions/browser'; -import { ExpressionFunction } from '../../../../../src/plugins/expressions'; -import { initFunctions } from '../../public/functions'; +import { functions as browserFns } from '../canvas_plugin_src/functions/browser'; +import { ExpressionFunction } from '../../../../src/plugins/expressions'; +import { initFunctions } from '../public/functions'; export const functionSpecs = browserFns .concat(...(initFunctions({} as any) as any)) diff --git a/x-pack/plugins/canvas/__tests__/fixtures/kibana.js b/x-pack/plugins/canvas/__fixtures__/kibana.js similarity index 100% rename from x-pack/plugins/canvas/__tests__/fixtures/kibana.js rename to x-pack/plugins/canvas/__fixtures__/kibana.js diff --git a/x-pack/plugins/canvas/__tests__/fixtures/workpads.ts b/x-pack/plugins/canvas/__fixtures__/workpads.ts similarity index 99% rename from x-pack/plugins/canvas/__tests__/fixtures/workpads.ts rename to x-pack/plugins/canvas/__fixtures__/workpads.ts index 0d2939ed0e8a5..886d38759d099 100644 --- a/x-pack/plugins/canvas/__tests__/fixtures/workpads.ts +++ b/x-pack/plugins/canvas/__fixtures__/workpads.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { CanvasWorkpad, CanvasElement, CanvasPage, CanvasVariable } from '../../types'; +import { CanvasWorkpad, CanvasElement, CanvasPage, CanvasVariable } from '../types'; const BaseWorkpad: CanvasWorkpad = { '@created': '2019-02-08T18:35:23.029Z', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/markdown.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/markdown.test.js index 1c75f5b7e0fbc..cf20f9830310f 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/markdown.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/markdown.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from '../common/__tests__/fixtures/test_tables'; -import { fontStyle } from '../common/__tests__/fixtures/test_styles'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from '../common/__fixtures__/test_tables'; +import { fontStyle } from '../common/__fixtures__/test_styles'; import { markdown } from './markdown'; describe('markdown', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_filters.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_filters.js similarity index 100% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_filters.js rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_filters.js diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_pointseries.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_pointseries.js similarity index 100% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_pointseries.js rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_pointseries.js diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_styles.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_styles.js similarity index 96% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_styles.js rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_styles.js index 1848d796c61c5..7694cb699d6be 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_styles.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_styles.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { elasticLogo } from '../../../../lib/elastic_logo'; +import { elasticLogo } from '../../../lib/elastic_logo'; export const fontStyle = { type: 'style', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_tables.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_tables.ts similarity index 98% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_tables.ts rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_tables.ts index ffb76500a35d6..f2c325b6d75f9 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/fixtures/test_tables.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__fixtures__/test_tables.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Datatable } from '../../../../../types'; +import { Datatable } from '../../../../types'; const emptyTable: Datatable = { type: 'datatable', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/compare.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/compare.js deleted file mode 100644 index 2a255ff742962..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/compare.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { compare } from '../compare'; -import { functionWrapper } from '../../../../__tests__/helpers/function_wrapper'; -import { getFunctionErrors } from '../../../../i18n'; - -const errors = getFunctionErrors().compare; - -describe('compare', () => { - const fn = functionWrapper(compare); - - describe('args', () => { - describe('op', () => { - it('sets the operator', () => { - expect(fn(0, { op: 'lt', to: 1 })).to.be(true); - }); - - it("defaults to 'eq'", () => { - expect(fn(0, { to: 1 })).to.be(false); - expect(fn(0, { to: 0 })).to.be(true); - }); - - it('throws when invalid op is provided', () => { - expect(() => fn(1, { op: 'boo', to: 2 })).to.throwException( - new RegExp(errors.invalidCompareOperator('boo').message) - ); - expect(() => fn(1, { op: 'boo' })).to.throwException( - new RegExp(errors.invalidCompareOperator('boo').message) - ); - }); - }); - - describe('to', () => { - it('sets the value that context is compared to', () => { - expect(fn(0, { to: 1 })).to.be(false); - }); - - it('if not provided, ne returns true while every other operator returns false', () => { - expect(fn(null, { op: 'ne' })).to.be(true); - expect(fn(0, { op: 'ne' })).to.be(true); - expect(fn(true, { op: 'lte' })).to.be(false); - expect(fn(1, { op: 'gte' })).to.be(false); - expect(fn('foo', { op: 'lt' })).to.be(false); - expect(fn(null, { op: 'gt' })).to.be(false); - expect(fn(null, { op: 'eq' })).to.be(false); - }); - }); - }); - - describe('same type comparisons', () => { - describe('null', () => { - it('returns true', () => { - expect(fn(null, { op: 'eq', to: null })).to.be(true); - expect(fn(null, { op: 'lte', to: null })).to.be(true); - expect(fn(null, { op: 'gte', to: null })).to.be(true); - }); - - it('returns false', () => { - expect(fn(null, { op: 'ne', to: null })).to.be(false); - expect(fn(null, { op: 'lt', to: null })).to.be(false); - expect(fn(null, { op: 'gt', to: null })).to.be(false); - }); - }); - - describe('number', () => { - it('returns true', () => { - expect(fn(-2.34, { op: 'lt', to: 10 })).to.be(true); - expect(fn(2, { op: 'gte', to: 2 })).to.be(true); - }); - - it('returns false', () => { - expect(fn(2, { op: 'eq', to: 10 })).to.be(false); - expect(fn(10, { op: 'ne', to: 10 })).to.be(false); - expect(fn(1, { op: 'lte', to: -3 })).to.be(false); - expect(fn(2, { op: 'gt', to: 2 })).to.be(false); - }); - }); - - describe('string', () => { - it('returns true', () => { - expect(fn('foo', { op: 'gte', to: 'foo' })).to.be(true); - expect(fn('foo', { op: 'lte', to: 'foo' })).to.be(true); - expect(fn('bar', { op: 'lt', to: 'foo' })).to.be(true); - }); - - it('returns false', () => { - expect(fn('foo', { op: 'eq', to: 'bar' })).to.be(false); - expect(fn('foo', { op: 'ne', to: 'foo' })).to.be(false); - expect(fn('foo', { op: 'gt', to: 'foo' })).to.be(false); - }); - }); - - describe('boolean', () => { - it('returns true', () => { - expect(fn(true, { op: 'eq', to: true })).to.be(true); - expect(fn(false, { op: 'eq', to: false })).to.be(true); - expect(fn(true, { op: 'ne', to: false })).to.be(true); - expect(fn(false, { op: 'ne', to: true })).to.be(true); - }); - it('returns false', () => { - expect(fn(true, { op: 'eq', to: false })).to.be(false); - expect(fn(false, { op: 'eq', to: true })).to.be(false); - expect(fn(true, { op: 'ne', to: true })).to.be(false); - expect(fn(false, { op: 'ne', to: false })).to.be(false); - }); - }); - }); - - describe('different type comparisons', () => { - it("returns true for 'ne' only", () => { - expect(fn(0, { op: 'ne', to: '0' })).to.be(true); - }); - - it('otherwise always returns false', () => { - expect(fn(0, { op: 'eq', to: '0' })).to.be(false); - expect(fn('foo', { op: 'lt', to: 10 })).to.be(false); - expect(fn('foo', { op: 'lte', to: true })).to.be(false); - expect(fn(0, { op: 'gte', to: null })).to.be(false); - expect(fn(0, { op: 'eq', to: false })).to.be(false); - expect(fn(true, { op: 'gte', to: null })).to.be(false); - }); - }); -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/all.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/all.test.js index 63a3facc833d3..697bc2bb10e5d 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/all.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/all.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { all } from './all'; describe('all', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/alterColumn.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/alterColumn.test.js index a8c01f0b2791f..1b4141c6e2cb0 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/alterColumn.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/alterColumn.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { alterColumn } from './alterColumn'; const errors = getFunctionErrors().alterColumn; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/any.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/any.test.js index dcff9b299832c..ed411b162685b 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/any.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/any.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { any } from './any'; describe('any', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.test.js index 49d14622e80f0..8da92e5b6720c 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { asFn } from './as'; describe('as', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/axis_config.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/axis_config.test.js index 04552b988e561..a58c52358f648 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/axis_config.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/axis_config.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { testTable } from './__fixtures__/test_tables'; import { axisConfig } from './axisConfig'; const errors = getFunctionErrors().axisConfig; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js index 41ec526d1b853..f1ddf88388eac 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { caseFn } from './case'; describe('case', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clear.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clear.test.js index b89cbc976a63f..a4177d1fe05ba 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clear.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/clear.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from './__fixtures__/test_tables'; import { clear } from './clear'; describe('clear', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/columns.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/columns.test.js index e2da579e5e0a3..8e0ae1b7a4fd5 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/columns.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/columns.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { columns } from './columns'; describe('columns', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/compare.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/compare.test.js new file mode 100644 index 0000000000000..ddc20ccf7be75 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/compare.test.js @@ -0,0 +1,127 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { getFunctionErrors } from '../../../i18n'; +import { compare } from './compare'; + +const errors = getFunctionErrors().compare; + +describe('compare', () => { + const fn = functionWrapper(compare); + + describe('args', () => { + describe('op', () => { + it('sets the operator', () => { + expect(fn(0, { op: 'lt', to: 1 })).toBe(true); + }); + + it("defaults to 'eq'", () => { + expect(fn(0, { to: 1 })).toBe(false); + expect(fn(0, { to: 0 })).toBe(true); + }); + + it('throws when invalid op is provided', () => { + expect(() => fn(1, { op: 'boo', to: 2 })).toThrowError( + new RegExp(errors.invalidCompareOperator('boo').message) + ); + expect(() => fn(1, { op: 'boo' })).toThrowError( + new RegExp(errors.invalidCompareOperator('boo').message) + ); + }); + }); + + describe('to', () => { + it('sets the value that context is compared to', () => { + expect(fn(0, { to: 1 })).toBe(false); + }); + + it('if not provided, ne returns true while every other operator returns false', () => { + expect(fn(null, { op: 'ne' })).toBe(true); + expect(fn(0, { op: 'ne' })).toBe(true); + expect(fn(true, { op: 'lte' })).toBe(false); + expect(fn(1, { op: 'gte' })).toBe(false); + expect(fn('foo', { op: 'lt' })).toBe(false); + expect(fn(null, { op: 'gt' })).toBe(false); + expect(fn(null, { op: 'eq' })).toBe(false); + }); + }); + }); + + describe('same type comparisons', () => { + describe('null', () => { + it('returns true', () => { + expect(fn(null, { op: 'eq', to: null })).toBe(true); + expect(fn(null, { op: 'lte', to: null })).toBe(true); + expect(fn(null, { op: 'gte', to: null })).toBe(true); + }); + + it('returns false', () => { + expect(fn(null, { op: 'ne', to: null })).toBe(false); + expect(fn(null, { op: 'lt', to: null })).toBe(false); + expect(fn(null, { op: 'gt', to: null })).toBe(false); + }); + }); + + describe('number', () => { + it('returns true', () => { + expect(fn(-2.34, { op: 'lt', to: 10 })).toBe(true); + expect(fn(2, { op: 'gte', to: 2 })).toBe(true); + }); + + it('returns false', () => { + expect(fn(2, { op: 'eq', to: 10 })).toBe(false); + expect(fn(10, { op: 'ne', to: 10 })).toBe(false); + expect(fn(1, { op: 'lte', to: -3 })).toBe(false); + expect(fn(2, { op: 'gt', to: 2 })).toBe(false); + }); + }); + + describe('string', () => { + it('returns true', () => { + expect(fn('foo', { op: 'gte', to: 'foo' })).toBe(true); + expect(fn('foo', { op: 'lte', to: 'foo' })).toBe(true); + expect(fn('bar', { op: 'lt', to: 'foo' })).toBe(true); + }); + + it('returns false', () => { + expect(fn('foo', { op: 'eq', to: 'bar' })).toBe(false); + expect(fn('foo', { op: 'ne', to: 'foo' })).toBe(false); + expect(fn('foo', { op: 'gt', to: 'foo' })).toBe(false); + }); + }); + + describe('boolean', () => { + it('returns true', () => { + expect(fn(true, { op: 'eq', to: true })).toBe(true); + expect(fn(false, { op: 'eq', to: false })).toBe(true); + expect(fn(true, { op: 'ne', to: false })).toBe(true); + expect(fn(false, { op: 'ne', to: true })).toBe(true); + }); + it('returns false', () => { + expect(fn(true, { op: 'eq', to: false })).toBe(false); + expect(fn(false, { op: 'eq', to: true })).toBe(false); + expect(fn(true, { op: 'ne', to: true })).toBe(false); + expect(fn(false, { op: 'ne', to: false })).toBe(false); + }); + }); + }); + + describe('different type comparisons', () => { + it("returns true for 'ne' only", () => { + expect(fn(0, { op: 'ne', to: '0' })).toBe(true); + }); + + it('otherwise always returns false', () => { + expect(fn(0, { op: 'eq', to: '0' })).toBe(false); + expect(fn('foo', { op: 'lt', to: 10 })).toBe(false); + expect(fn('foo', { op: 'lte', to: true })).toBe(false); + expect(fn(0, { op: 'gte', to: null })).toBe(false); + expect(fn(0, { op: 'eq', to: false })).toBe(false); + expect(fn(true, { op: 'gte', to: null })).toBe(false); + }); + }); +}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/container_style.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/container_style.test.js index 3edae257ce69a..574ac15573b4b 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/container_style.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/container_style.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { elasticLogo } from '../../lib/elastic_logo'; import { getFunctionErrors } from '../../../i18n'; import { containerStyle } from './containerStyle'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/context.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/context.test.js index 904406f1a703b..32b00bddd4607 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/context.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/context.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable, emptyTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable, emptyTable } from './__fixtures__/test_tables'; import { context } from './context'; describe('context', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/csv.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/csv.test.js index 8cd30e3b1915e..4083187c75aae 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/csv.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/csv.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; import { csv } from './csv'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/date.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/date.test.js index 96b122d8a0776..4cf892b41dc35 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/date.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/date.test.js @@ -5,7 +5,7 @@ */ import sinon from 'sinon'; -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; import { date } from './date'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/do.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/do.test.js index 46e0e22f53a6d..43310b68f1851 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/do.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/do.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { doFn } from './do'; describe('do', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/dropdown_control.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/dropdown_control.test.js index 3ce44948cd6d0..7eaf005cf1409 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/dropdown_control.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/dropdown_control.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from './__fixtures__/test_tables'; import { dropdownControl } from './dropdownControl'; describe('dropdownControl', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/eq.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/eq.test.js index cfe4dc3c9ba82..a890b67dfe1ef 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/eq.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/eq.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { eq } from './eq'; describe('eq', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/exactly.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/exactly.test.js index 2b9bdb59afbdf..409570da756ca 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/exactly.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/exactly.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { emptyFilter } from './__tests__/fixtures/test_filters'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { emptyFilter } from './__fixtures__/test_filters'; import { exactly } from './exactly'; describe('exactly', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js index 179be8aff2e19..c0d3ce658d0d1 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from './__fixtures__/test_tables'; import { filterrows } from './filterrows'; const inStock = (datatable) => datatable.rows[0].in_stock; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatdate.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatdate.test.js index 968727f4aa19d..27a793620d0b5 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatdate.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatdate.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { formatdate } from './formatdate'; describe('formatdate', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatnumber.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatnumber.test.js index adab2d4075550..5f751be4bb6c7 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatnumber.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/formatnumber.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { formatnumber } from './formatnumber'; describe('formatnumber', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/getCell.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/getCell.test.js index 976681f98260f..c23221298ab9f 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/getCell.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/getCell.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { getCell } from './getCell'; const errors = getFunctionErrors().getCell; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gt.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gt.test.js index 6c8c8de4f5763..71c27bd9e701b 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gt.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gt.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { gt } from './gt'; describe('gt', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gte.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gte.test.js index b5f31dbcba2ba..2e996d61da391 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gte.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/gte.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { gte } from './gte'; describe('gte', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/head.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/head.test.js index bfbd548cdce01..74f9252878851 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/head.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/head.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { head } from './head'; describe('head', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js index 408d02ea175f1..6e1a6b4e225a6 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { ifFn } from './if'; describe('if', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/image.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/image.test.js similarity index 84% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/image.js rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/image.test.js index 0d1c80665f570..993d38b5e108e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/image.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/image.test.js @@ -5,13 +5,15 @@ */ import expect from '@kbn/expect'; -import { image } from '../image'; -import { functionWrapper } from '../../../../__tests__/helpers/function_wrapper'; -import { elasticLogo } from '../../../lib/elastic_logo'; -import { elasticOutline } from '../../../lib/elastic_outline'; +// import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { elasticLogo } from '../../lib/elastic_logo'; +import { elasticOutline } from '../../lib/elastic_outline'; +// import { image } from './image'; -describe('image', () => { - const fn = functionWrapper(image); +// TODO: the test was not running and is not up to date +describe.skip('image', () => { + // const fn = functionWrapper(image); + const fn = jest.fn(); it('returns an image object using a dataUrl', () => { const result = fn(null, { dataurl: elasticOutline, mode: 'cover' }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/join_rows.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/join_rows.test.js index 5c778300133a0..7479fb1763b9e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/join_rows.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/join_rows.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { testTable } from './__fixtures__/test_tables'; import { joinRows } from './join_rows'; const errors = getFunctionErrors().joinRows; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lt.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lt.test.js index ba1af11e5b92d..4a34e496bdfe2 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lt.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lt.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { lt } from './lt'; describe('lt', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lte.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lte.test.js index d4ebcb5417f22..9aa12d321532e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lte.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/lte.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { lte } from './lte'; describe('lte', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.test.js index 652d61fd77398..cc360a48c7f56 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable, emptyTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable, emptyTable } from './__fixtures__/test_tables'; import { mapColumn } from './mapColumn'; const pricePlusTwo = (datatable) => Promise.resolve(datatable.rows[0].price + 2); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/math.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/math.test.js index 530a0043a7ef1..ff0819ad3ee55 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/math.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/math.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { math } from './math'; const errors = getFunctionErrors().math; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/metric.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/metric.test.js index 50a952d836251..f88e04fafc9db 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/metric.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/metric.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { fontStyle } from './__tests__/fixtures/test_styles'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { fontStyle } from './__fixtures__/test_styles'; import { metric } from './metric'; describe('metric', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/neq.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/neq.test.js index d1083131cfa2f..ecc5fce0300e3 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/neq.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/neq.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { neq } from './neq'; describe('neq', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js index 07d436007c816..3651cd84873d2 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { testTable } from './__fixtures__/test_tables'; import { ply } from './ply'; const errors = getFunctionErrors().ply; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/progress.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/progress.test.js similarity index 93% rename from x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/progress.js rename to x-pack/plugins/canvas/canvas_plugin_src/functions/common/progress.test.js index 17f9defa15dc3..1558f26e26201 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/__tests__/progress.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/progress.test.js @@ -5,14 +5,15 @@ */ import expect from '@kbn/expect'; -import { progress } from '../progress'; -import { functionWrapper } from '../../../../__tests__/helpers/function_wrapper'; -import { getFunctionErrors } from '../../../../i18n'; -import { fontStyle } from './fixtures/test_styles'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { getFunctionErrors } from '../../../i18n'; +import { progress } from './progress'; +import { fontStyle } from './__fixtures__/test_styles'; const errors = getFunctionErrors().progress; -describe('progress', () => { +// TODO: this test was not running and is not up to date +describe.skip('progress', () => { const fn = functionWrapper(progress); const value = 0.33; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/render.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/render.test.js index 152d7fb4df7ec..ddc4fcee08296 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/render.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/render.test.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { DEFAULT_ELEMENT_CSS } from '../../../common/lib/constants'; -import { testTable } from './__tests__/fixtures/test_tables'; -import { fontStyle, containerStyle } from './__tests__/fixtures/test_styles'; +import { testTable } from './__fixtures__/test_tables'; +import { fontStyle, containerStyle } from './__fixtures__/test_styles'; import { render } from './render'; const renderTable = { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/repeat_image.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/repeat_image.test.js index f7c1ecc94a240..f03e8f127e3a2 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/repeat_image.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/repeat_image.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { elasticOutline } from '../../lib/elastic_outline'; import { elasticLogo } from '../../lib/elastic_logo'; import { repeatImage } from './repeat_image'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/replace.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/replace.test.js index e4a371ad82e1c..853127768604f 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/replace.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/replace.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { replace } from './replace'; describe('replace', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/reveal_image.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/reveal_image.test.js index 2efc91e93ddc2..7052fc81b62e0 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/reveal_image.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/reveal_image.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { elasticOutline } from '../../lib/elastic_outline'; import { elasticLogo } from '../../lib/elastic_logo'; import { getFunctionErrors } from '../../../i18n'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rounddate.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rounddate.test.js index eed8b0aa6c6bf..651117b9bb818 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rounddate.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rounddate.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { rounddate } from './rounddate'; describe('rounddate', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rowCount.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rowCount.test.js index 798ed3a749ad4..52a9b56a4cc4c 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rowCount.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/rowCount.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { rowCount } from './rowCount'; describe('rowCount', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/series_style.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/series_style.test.js index da2183f6dfbac..236a6cdc25a03 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/series_style.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/series_style.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { seriesStyle } from './seriesStyle'; describe('seriesStyle', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/sort.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/sort.test.js index 88eb31da2552c..37d42f0e7b3d3 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/sort.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/sort.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from './__fixtures__/test_tables'; import { sort } from './sort'; describe('sort', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.test.js index d137ce05ccc19..c4ba9f200e9b4 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable, emptyTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable, emptyTable } from './__fixtures__/test_tables'; import { staticColumn } from './staticColumn'; describe('staticColumn', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/string.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/string.test.js index fbb7ab1b72eed..1250c5228d505 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/string.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/string.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { string } from './string'; describe('string', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js index 7ecccdd5ee544..5c71e101c8262 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { switchFn } from './switch'; describe('switch', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/table.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/table.test.js index c34c437e332ae..6ba450d94c557 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/table.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/table.test.js @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { testTable } from './__tests__/fixtures/test_tables'; -import { fontStyle } from './__tests__/fixtures/test_styles'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { testTable } from './__fixtures__/test_tables'; +import { fontStyle } from './__fixtures__/test_styles'; import { table } from './table'; describe('table', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/tail.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/tail.test.js index 45d6cba46716a..a95ac31b00079 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/tail.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/tail.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; -import { emptyTable, testTable } from './__tests__/fixtures/test_tables'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; +import { emptyTable, testTable } from './__fixtures__/test_tables'; import { tail } from './tail'; describe('tail', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter.test.js index 2edbba278ffde..d650a6ca792e8 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter.test.js @@ -5,9 +5,9 @@ */ import sinon from 'sinon'; -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; -import { emptyFilter } from './__tests__/fixtures/test_filters'; +import { emptyFilter } from './__fixtures__/test_filters'; import { timefilter } from './timefilter'; const errors = getFunctionErrors().timefilter; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter_control.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter_control.test.js index fa7b26554f65b..edc57994c7d57 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter_control.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/timefilter_control.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../../__tests__/helpers/function_wrapper'; +import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { timefilterControl } from './timefilterControl'; describe('timefilterControl', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/server/get_expression_type.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/server/get_expression_type.test.js index 237e80f0c1ee3..0dbc7ca833f05 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/server/get_expression_type.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/server/get_expression_type.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { emptyTable, testTable } from '../common/__tests__/fixtures/test_tables'; +import { emptyTable, testTable } from '../common/__fixtures__/test_tables'; import { getExpressionType } from './pointseries/lib/get_expression_type'; describe('getExpressionType', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/server/pointseries.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/server/pointseries.test.js index 2029388115bcc..1adb7bc53987d 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/server/pointseries.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/server/pointseries.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { emptyTable, testTable } from '../common/__tests__/fixtures/test_tables'; +import { emptyTable, testTable } from '../common/__fixtures__/test_tables'; import { pointseries } from './pointseries'; describe('pointseries', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/__tests__/get_form_object.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/__tests__/get_form_object.js deleted file mode 100644 index cb8e999489fbf..0000000000000 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/__tests__/get_form_object.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { getFormObject } from '../get_form_object'; - -describe('getFormObject', () => { - describe('valid input', () => { - it('string', () => { - expect(getFormObject('field')).to.be.eql({ fn: '', column: 'field' }); - }); - it('simple expression', () => { - expect(getFormObject('mean(field)')).to.be.eql({ fn: 'mean', column: 'field' }); - }); - }); - describe('invalid input', () => { - it('number', () => { - expect(getFormObject) - .withArgs('2') - .to.throwException((e) => { - expect(e.message).to.be('Cannot render scalar values or complex math expressions'); - }); - }); - it('complex expression', () => { - expect(getFormObject) - .withArgs('mean(field * 3)') - .to.throwException((e) => { - expect(e.message).to.be('Cannot render scalar values or complex math expressions'); - }); - }); - }); -}); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/get_form_object.test.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/get_form_object.test.js new file mode 100644 index 0000000000000..9458f0fd095d3 --- /dev/null +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/get_form_object.test.js @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getFormObject } from './get_form_object'; + +describe('getFormObject', () => { + describe('valid input', () => { + it('string', () => { + expect(getFormObject('field')).toEqual({ fn: '', column: 'field' }); + }); + it('simple expression', () => { + expect(getFormObject('mean(field)')).toEqual({ fn: 'mean', column: 'field' }); + }); + }); + describe('invalid input', () => { + it('number', () => { + expect(() => { + getFormObject('2'); + }).toThrow('Cannot render scalar values or complex math expressions'); + }); + it('complex expression', () => { + expect(() => { + getFormObject('mean(field * 3)'); + }).toThrow('Cannot render scalar values or complex math expressions'); + }); + }); +}); diff --git a/x-pack/plugins/canvas/common/lib/autocomplete.test.ts b/x-pack/plugins/canvas/common/lib/autocomplete.test.ts index 777810cad05ba..128fb6795f854 100644 --- a/x-pack/plugins/canvas/common/lib/autocomplete.test.ts +++ b/x-pack/plugins/canvas/common/lib/autocomplete.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionSpecs } from '../../__tests__/fixtures/function_specs'; +import { functionSpecs } from '../../__fixtures__/function_specs'; import { FunctionSuggestion, @@ -17,7 +17,7 @@ describe('autocomplete', () => { it('should return function definition for plot', () => { const expression = 'plot '; const def = getFnArgDefAtPosition(functionSpecs, expression, expression.length); - const plotFn = functionSpecs.find((spec) => spec.name === 'plot'); + const plotFn = functionSpecs.find((spec: any) => spec.name === 'plot'); expect(def.fnDef).toBe(plotFn); }); }); @@ -33,7 +33,7 @@ describe('autocomplete', () => { it('should suggest arguments', () => { const expression = 'plot '; const suggestions = getAutocompleteSuggestions(functionSpecs, expression, expression.length); - const plotFn = functionSpecs.find((spec) => spec.name === 'plot'); + const plotFn = functionSpecs.find((spec: any) => spec.name === 'plot'); expect(suggestions.length).toBe(Object.keys(plotFn!.args).length); expect(suggestions[0].start).toBe(expression.length); expect(suggestions[0].end).toBe(expression.length); @@ -42,7 +42,7 @@ describe('autocomplete', () => { it('should suggest values', () => { const expression = 'shape shape='; const suggestions = getAutocompleteSuggestions(functionSpecs, expression, expression.length); - const shapeFn = functionSpecs.find((spec) => spec.name === 'shape'); + const shapeFn = functionSpecs.find((spec: any) => spec.name === 'shape'); expect(suggestions.length).toBe(shapeFn!.args.shape.options.length); expect(suggestions[0].start).toBe(expression.length); expect(suggestions[0].end).toBe(expression.length); @@ -110,7 +110,7 @@ describe('autocomplete', () => { expression, expression.length - 1 ); - const ltFn = functionSpecs.find((spec) => spec.name === 'lt'); + const ltFn = functionSpecs.find((spec: any) => spec.name === 'lt'); expect(suggestions.length).toBe(Object.keys(ltFn!.args).length); expect(suggestions[0].start).toBe(expression.length - 1); expect(suggestions[0].end).toBe(expression.length - 1); @@ -123,7 +123,7 @@ describe('autocomplete', () => { expression, expression.length - 1 ); - const shapeFn = functionSpecs.find((spec) => spec.name === 'shape'); + const shapeFn = functionSpecs.find((spec: any) => spec.name === 'shape'); expect(suggestions.length).toBe(shapeFn!.args.shape.options.length); expect(suggestions[0].start).toBe(expression.length - 1); expect(suggestions[0].end).toBe(expression.length - 1); @@ -136,7 +136,7 @@ describe('autocomplete', () => { expression, expression.length - 1 ); - const shapeFn = functionSpecs.find((spec) => spec.name === 'shape'); + const shapeFn = functionSpecs.find((spec: any) => spec.name === 'shape'); expect(suggestions.length).toBe(shapeFn!.args.shape.options.length); expect(suggestions[0].start).toBe(expression.length - '"ar"'.length); expect(suggestions[0].end).toBe(expression.length); diff --git a/x-pack/plugins/canvas/common/lib/get_field_type.test.ts b/x-pack/plugins/canvas/common/lib/get_field_type.test.ts index 82e724c33ecc8..3e8f99750671c 100644 --- a/x-pack/plugins/canvas/common/lib/get_field_type.test.ts +++ b/x-pack/plugins/canvas/common/lib/get_field_type.test.ts @@ -7,7 +7,7 @@ import { emptyTable, testTable, -} from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_tables'; +} from '../../canvas_plugin_src/functions/common/__fixtures__/test_tables'; import { getFieldType } from './get_field_type'; describe('getFieldType', () => { diff --git a/x-pack/plugins/canvas/common/lib/handlebars.test.js b/x-pack/plugins/canvas/common/lib/handlebars.test.js index 5fcb2d42395fa..20574279bad96 100644 --- a/x-pack/plugins/canvas/common/lib/handlebars.test.js +++ b/x-pack/plugins/canvas/common/lib/handlebars.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { testTable } from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_tables'; +import { testTable } from '../../canvas_plugin_src/functions/common/__fixtures__/test_tables'; import { Handlebars } from './handlebars'; describe('handlebars', () => { diff --git a/x-pack/plugins/canvas/public/apps/export/export/__tests__/__snapshots__/export_app.test.tsx.snap b/x-pack/plugins/canvas/public/apps/export/export/__snapshots__/export_app.test.tsx.snap similarity index 100% rename from x-pack/plugins/canvas/public/apps/export/export/__tests__/__snapshots__/export_app.test.tsx.snap rename to x-pack/plugins/canvas/public/apps/export/export/__snapshots__/export_app.test.tsx.snap diff --git a/x-pack/plugins/canvas/public/apps/export/export/__tests__/export_app.test.tsx b/x-pack/plugins/canvas/public/apps/export/export/export_app.test.tsx similarity index 84% rename from x-pack/plugins/canvas/public/apps/export/export/__tests__/export_app.test.tsx rename to x-pack/plugins/canvas/public/apps/export/export/export_app.test.tsx index 1bb58919b7fa6..6a483b23e8e98 100644 --- a/x-pack/plugins/canvas/public/apps/export/export/__tests__/export_app.test.tsx +++ b/x-pack/plugins/canvas/public/apps/export/export/export_app.test.tsx @@ -6,18 +6,18 @@ import React from 'react'; import { mount } from 'enzyme'; -import { ExportApp } from '../export_app.component'; -import { CanvasWorkpad } from '../../../../../types'; +import { ExportApp } from './export_app.component'; +import { CanvasWorkpad } from '../../../../types'; jest.mock('style-it', () => ({ it: (css: string, Component: any) => Component, })); -jest.mock('../../../../components/workpad_page', () => ({ +jest.mock('../../../components/workpad_page', () => ({ WorkpadPage: (props: any) =>
Page
, })); -jest.mock('../../../../components/link', () => ({ +jest.mock('../../../components/link', () => ({ Link: (props: any) =>
Link
, })); diff --git a/x-pack/plugins/canvas/public/components/download/__tests__/download.test.tsx b/x-pack/plugins/canvas/public/components/download/download.test.tsx similarity index 95% rename from x-pack/plugins/canvas/public/components/download/__tests__/download.test.tsx rename to x-pack/plugins/canvas/public/components/download/download.test.tsx index 3bbe8193deeea..a4ea446e9fce3 100644 --- a/x-pack/plugins/canvas/public/components/download/__tests__/download.test.tsx +++ b/x-pack/plugins/canvas/public/components/download/download.test.tsx @@ -6,7 +6,7 @@ import { render } from 'enzyme'; import React from 'react'; -import { Download } from '..'; +import { Download } from '.'; describe('', () => { test('has canvasDownload class', () => { diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts index 443eb06846d2e..a2e5353a01ab2 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts @@ -7,7 +7,7 @@ jest.mock('../../../../common/lib/fetch'); import { getPdfUrl, createPdf, LayoutType } from './utils'; -import { workpads } from '../../../../__tests__/fixtures/workpads'; +import { workpads } from '../../../../__fixtures__/workpads'; import { fetch } from '../../../../common/lib/fetch'; import { IBasePath } from 'kibana/public'; diff --git a/x-pack/plugins/canvas/public/functions/pie.test.js b/x-pack/plugins/canvas/public/functions/pie.test.js index 99f61cfb5d922..1ba82a3573d75 100644 --- a/x-pack/plugins/canvas/public/functions/pie.test.js +++ b/x-pack/plugins/canvas/public/functions/pie.test.js @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../__tests__/helpers/function_wrapper'; -import { testPie } from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_pointseries'; +import { functionWrapper } from '../../test_helpers/function_wrapper'; +import { testPie } from '../../canvas_plugin_src/functions/common/__fixtures__/test_pointseries'; import { fontStyle, grayscalePalette, seriesStyle, -} from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_styles'; +} from '../../canvas_plugin_src/functions/common/__fixtures__/test_styles'; import { pieFunctionFactory } from './pie'; describe('pie', () => { diff --git a/x-pack/plugins/canvas/public/functions/plot.test.js b/x-pack/plugins/canvas/public/functions/plot.test.js index 426e9a23efe5d..55414878f504f 100644 --- a/x-pack/plugins/canvas/public/functions/plot.test.js +++ b/x-pack/plugins/canvas/public/functions/plot.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionWrapper } from '../../__tests__/helpers/function_wrapper'; -import { testPlot } from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_pointseries'; +import { functionWrapper } from '../../test_helpers/function_wrapper'; +import { testPlot } from '../../canvas_plugin_src/functions/common/__fixtures__/test_pointseries'; import { fontStyle, grayscalePalette, @@ -13,7 +13,7 @@ import { xAxisConfig, seriesStyle, defaultStyle, -} from '../../canvas_plugin_src/functions/common/__tests__/fixtures/test_styles'; +} from '../../canvas_plugin_src/functions/common/__fixtures__/test_styles'; import { plotFunctionFactory } from './plot'; describe('plot', () => { diff --git a/x-pack/plugins/canvas/public/functions/plot/get_flot_axis_config.test.js b/x-pack/plugins/canvas/public/functions/plot/get_flot_axis_config.test.js index c0ab3bb316b73..ad988fd533d01 100644 --- a/x-pack/plugins/canvas/public/functions/plot/get_flot_axis_config.test.js +++ b/x-pack/plugins/canvas/public/functions/plot/get_flot_axis_config.test.js @@ -8,7 +8,7 @@ import { xAxisConfig, yAxisConfig, hideAxis, -} from '../../../canvas_plugin_src/functions/common/__tests__/fixtures/test_styles'; +} from '../../../canvas_plugin_src/functions/common/__fixtures__/test_styles'; import { getFlotAxisConfig } from './get_flot_axis_config'; describe('getFlotAxisConfig', () => { diff --git a/x-pack/plugins/canvas/public/functions/plot/get_font_spec.test.js b/x-pack/plugins/canvas/public/functions/plot/get_font_spec.test.js index dfaf510a94718..a60e0c038a0c1 100644 --- a/x-pack/plugins/canvas/public/functions/plot/get_font_spec.test.js +++ b/x-pack/plugins/canvas/public/functions/plot/get_font_spec.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { fontStyle } from '../../../canvas_plugin_src/functions/common/__tests__/fixtures/test_styles'; +import { fontStyle } from '../../../canvas_plugin_src/functions/common/__fixtures__/test_styles'; import { defaultSpec, getFontSpec } from './get_font_spec'; describe('getFontSpec', () => { diff --git a/x-pack/plugins/canvas/public/lib/clipboard.test.ts b/x-pack/plugins/canvas/public/lib/clipboard.test.ts index 53f92e2184edc..4df6062f9329a 100644 --- a/x-pack/plugins/canvas/public/lib/clipboard.test.ts +++ b/x-pack/plugins/canvas/public/lib/clipboard.test.ts @@ -8,7 +8,7 @@ jest.mock('../../../../../src/plugins/kibana_utils/public'); import { Storage } from '../../../../../src/plugins/kibana_utils/public'; import { setClipboardData, getClipboardData } from './clipboard'; import { LOCALSTORAGE_CLIPBOARD } from '../../common/lib/constants'; -import { elements } from '../../__tests__/fixtures/workpads'; +import { elements } from '../../__fixtures__/workpads'; const set = jest.fn(); const get = jest.fn(); diff --git a/x-pack/plugins/canvas/public/state/middleware/__tests__/in_flight.test.ts b/x-pack/plugins/canvas/public/state/middleware/in_flight.test.ts similarity index 93% rename from x-pack/plugins/canvas/public/state/middleware/__tests__/in_flight.test.ts rename to x-pack/plugins/canvas/public/state/middleware/in_flight.test.ts index b78c3ffcfcb1d..6a47289b8b826 100644 --- a/x-pack/plugins/canvas/public/state/middleware/__tests__/in_flight.test.ts +++ b/x-pack/plugins/canvas/public/state/middleware/in_flight.test.ts @@ -4,13 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - inFlightActive, - inFlightComplete, - setLoading, - setValue, -} from '../../actions/resolved_args'; -import { inFlightMiddlewareFactory } from '../in_flight'; +import { inFlightActive, inFlightComplete, setLoading, setValue } from '../actions/resolved_args'; +import { inFlightMiddlewareFactory } from './in_flight'; const next = jest.fn(); const dispatch = jest.fn(); diff --git a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_autoplay.test.ts b/x-pack/plugins/canvas/public/state/middleware/workpad_autoplay.test.ts similarity index 91% rename from x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_autoplay.test.ts rename to x-pack/plugins/canvas/public/state/middleware/workpad_autoplay.test.ts index bb7b26919ef20..6bbb2dbf9d8ba 100644 --- a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_autoplay.test.ts +++ b/x-pack/plugins/canvas/public/state/middleware/workpad_autoplay.test.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../lib/app_state'); -jest.mock('../../../lib/router_provider'); +jest.mock('../../lib/app_state'); +jest.mock('../../lib/router_provider'); -import { workpadAutoplay } from '../workpad_autoplay'; -import { setAutoplayInterval } from '../../../lib/app_state'; -import { createTimeInterval } from '../../../lib/time_interval'; +import { workpadAutoplay } from './workpad_autoplay'; +import { setAutoplayInterval } from '../../lib/app_state'; +import { createTimeInterval } from '../../lib/time_interval'; // @ts-expect-error untyped local -import { routerProvider } from '../../../lib/router_provider'; +import { routerProvider } from '../../lib/router_provider'; const next = jest.fn(); const dispatch = jest.fn(); diff --git a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts b/x-pack/plugins/canvas/public/state/middleware/workpad_refresh.test.ts similarity index 92% rename from x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts rename to x-pack/plugins/canvas/public/state/middleware/workpad_refresh.test.ts index e451a39df06db..71d3ad3a92f09 100644 --- a/x-pack/plugins/canvas/public/state/middleware/__tests__/workpad_refresh.test.ts +++ b/x-pack/plugins/canvas/public/state/middleware/workpad_refresh.test.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../lib/app_state'); +jest.mock('../../lib/app_state'); -import { workpadRefresh } from '../workpad_refresh'; -import { inFlightComplete } from '../../actions/resolved_args'; -import { setRefreshInterval } from '../../actions/workpad'; -import { setRefreshInterval as setAppStateRefreshInterval } from '../../../lib/app_state'; +import { workpadRefresh } from './workpad_refresh'; +import { inFlightComplete } from '../actions/resolved_args'; +import { setRefreshInterval } from '../actions/workpad'; +import { setRefreshInterval as setAppStateRefreshInterval } from '../../lib/app_state'; -import { createTimeInterval } from '../../../lib/time_interval'; +import { createTimeInterval } from '../../lib/time_interval'; const next = jest.fn(); const dispatch = jest.fn(); diff --git a/x-pack/plugins/canvas/server/collectors/workpad_collector.test.ts b/x-pack/plugins/canvas/server/collectors/workpad_collector.test.ts index 32665cc42dc4e..919f1537e81b3 100644 --- a/x-pack/plugins/canvas/server/collectors/workpad_collector.test.ts +++ b/x-pack/plugins/canvas/server/collectors/workpad_collector.test.ts @@ -6,7 +6,7 @@ import { cloneDeep } from 'lodash'; import { summarizeWorkpads } from './workpad_collector'; -import { workpads } from '../../__tests__/fixtures/workpads'; +import { workpads } from '../../__fixtures__/workpads'; describe('usage collector handle es response data', () => { it('should summarize workpads, pages, and elements', () => { diff --git a/x-pack/plugins/canvas/server/routes/workpad/get.test.ts b/x-pack/plugins/canvas/server/routes/workpad/get.test.ts index a51cbefd4031e..0e0db5a1093df 100644 --- a/x-pack/plugins/canvas/server/routes/workpad/get.test.ts +++ b/x-pack/plugins/canvas/server/routes/workpad/get.test.ts @@ -8,7 +8,7 @@ import { CANVAS_TYPE } from '../../../common/lib/constants'; import { initializeGetWorkpadRoute } from './get'; import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server'; import { savedObjectsClientMock, httpServerMock } from 'src/core/server/mocks'; -import { workpadWithGroupAsElement } from '../../../__tests__/fixtures/workpads'; +import { workpadWithGroupAsElement } from '../../../__fixtures__/workpads'; import { CanvasWorkpad } from '../../../types'; import { getMockedRouterDeps } from '../test_helpers'; diff --git a/x-pack/plugins/canvas/server/routes/workpad/update.test.ts b/x-pack/plugins/canvas/server/routes/workpad/update.test.ts index 0d97145c90298..e2e84a9a88cb6 100644 --- a/x-pack/plugins/canvas/server/routes/workpad/update.test.ts +++ b/x-pack/plugins/canvas/server/routes/workpad/update.test.ts @@ -9,7 +9,7 @@ import { CANVAS_TYPE } from '../../../common/lib/constants'; import { initializeUpdateWorkpadRoute, initializeUpdateWorkpadAssetsRoute } from './update'; import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server'; import { savedObjectsClientMock, httpServerMock } from 'src/core/server/mocks'; -import { workpads } from '../../../__tests__/fixtures/workpads'; +import { workpads } from '../../../__fixtures__/workpads'; import { okResponse } from '../ok_response'; import { getMockedRouterDeps } from '../test_helpers'; diff --git a/x-pack/plugins/canvas/shareable_runtime/api/__tests__/__snapshots__/shareable.test.tsx.snap b/x-pack/plugins/canvas/shareable_runtime/api/__snapshots__/shareable.test.tsx.snap similarity index 100% rename from x-pack/plugins/canvas/shareable_runtime/api/__tests__/__snapshots__/shareable.test.tsx.snap rename to x-pack/plugins/canvas/shareable_runtime/api/__snapshots__/shareable.test.tsx.snap diff --git a/x-pack/plugins/canvas/shareable_runtime/api/__tests__/shareable.test.tsx b/x-pack/plugins/canvas/shareable_runtime/api/shareable.test.tsx similarity index 96% rename from x-pack/plugins/canvas/shareable_runtime/api/__tests__/shareable.test.tsx rename to x-pack/plugins/canvas/shareable_runtime/api/shareable.test.tsx index 0851ae8d04eb0..9efb8db805268 100644 --- a/x-pack/plugins/canvas/shareable_runtime/api/__tests__/shareable.test.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/api/shareable.test.tsx @@ -6,11 +6,11 @@ import { mount } from 'enzyme'; import React from 'react'; -import { sharedWorkpads, tick } from '../../test'; -import { share } from '../shareable'; +import { sharedWorkpads, tick } from '../test'; +import { share } from './shareable'; // Mock the renderers within this test. -jest.mock('../../supported_renderers'); +jest.mock('../supported_renderers'); describe('Canvas Shareable Workpad API', () => { // Mock the AJAX load of the workpad. diff --git a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/__snapshots__/app.test.tsx.snap b/x-pack/plugins/canvas/shareable_runtime/components/__snapshots__/app.test.tsx.snap similarity index 100% rename from x-pack/plugins/canvas/shareable_runtime/components/__tests__/__snapshots__/app.test.tsx.snap rename to x-pack/plugins/canvas/shareable_runtime/components/__snapshots__/app.test.tsx.snap diff --git a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/app.test.tsx b/x-pack/plugins/canvas/shareable_runtime/components/app.test.tsx similarity index 95% rename from x-pack/plugins/canvas/shareable_runtime/components/__tests__/app.test.tsx rename to x-pack/plugins/canvas/shareable_runtime/components/app.test.tsx index 172336c26df54..ba46bbbcff6cf 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/app.test.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/components/app.test.tsx @@ -13,8 +13,8 @@ import { mount, ReactWrapper } from 'enzyme'; import React from 'react'; // import { act } from 'react-dom/test-utils'; -import { App } from '../app'; -import { sharedWorkpads, WorkpadNames, tick } from '../../test'; +import { App } from './app'; +import { sharedWorkpads, WorkpadNames, tick } from '../test'; import { getScrubber as scrubber, getScrubberSlideContainer as scrubberContainer, @@ -27,11 +27,11 @@ import { getFooter as footer, getPageControlsPrevious as previous, getPageControlsNext as next, -} from '../../test/selectors'; -import { openSettings, selectMenuItem } from '../../test/interactions'; +} from '../test/selectors'; +import { openSettings, selectMenuItem } from '../test/interactions'; // Mock the renderers -jest.mock('../../supported_renderers'); +jest.mock('../supported_renderers'); // Mock the EuiPortal - `insertAdjacentElement is not supported in // `jsdom` 12. We're just going to render a `div` with the children diff --git a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/canvas.test.tsx b/x-pack/plugins/canvas/shareable_runtime/components/canvas.test.tsx similarity index 84% rename from x-pack/plugins/canvas/shareable_runtime/components/__tests__/canvas.test.tsx rename to x-pack/plugins/canvas/shareable_runtime/components/canvas.test.tsx index deb524ed56bc5..b1e6284f6e6a9 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/canvas.test.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/components/canvas.test.tsx @@ -6,11 +6,11 @@ import { mount, ReactWrapper } from 'enzyme'; import React from 'react'; -import { JestContext } from '../../test/context_jest'; -import { getScrubber as scrubber, getPageControlsCenter as center } from '../../test/selectors'; -import { Canvas } from '../canvas'; +import { JestContext } from '../test/context_jest'; +import { getScrubber as scrubber, getPageControlsCenter as center } from '../test/selectors'; +import { Canvas } from './canvas'; -jest.mock('../../supported_renderers'); +jest.mock('../supported_renderers'); describe('', () => { test('null workpad renders nothing', () => { diff --git a/x-pack/plugins/canvas/shareable_runtime/components/footer/__stories__/scrubber.stories.tsx b/x-pack/plugins/canvas/shareable_runtime/components/footer/__stories__/scrubber.stories.tsx index ba938b57f1ead..371f646bf8619 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/footer/__stories__/scrubber.stories.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/components/footer/__stories__/scrubber.stories.tsx @@ -10,7 +10,7 @@ import { storiesOf } from '@storybook/react'; import { CanvasRenderedPage } from '../../../types'; import { ExampleContext } from '../../../test/context_example'; import { Scrubber, ScrubberComponent } from '../scrubber'; -import { workpads } from '../../../../__tests__/fixtures/workpads'; +import { workpads } from '../../../../__fixtures__/workpads'; storiesOf('shareables/Footer/Scrubber', module) .add('contextual: hello', () => ( diff --git a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/page.test.tsx b/x-pack/plugins/canvas/shareable_runtime/components/page.test.tsx similarity index 93% rename from x-pack/plugins/canvas/shareable_runtime/components/__tests__/page.test.tsx rename to x-pack/plugins/canvas/shareable_runtime/components/page.test.tsx index 7e3f5b1cd3555..8e780e24eecfb 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/__tests__/page.test.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/components/page.test.tsx @@ -6,7 +6,7 @@ import { mount } from 'enzyme'; import React from 'react'; -import { Page } from '../page'; +import { Page } from './page'; describe('', () => { test('null workpad renders nothing', () => { diff --git a/x-pack/plugins/canvas/__tests__/helpers/function_wrapper.js b/x-pack/plugins/canvas/test_helpers/function_wrapper.js similarity index 100% rename from x-pack/plugins/canvas/__tests__/helpers/function_wrapper.js rename to x-pack/plugins/canvas/test_helpers/function_wrapper.js