From 84726c3adcbd7da91523ee212873b7100587d987 Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Wed, 13 Apr 2016 14:14:49 -0400 Subject: [PATCH] Backport PR #6865 --------- **Commit 1:** [internal] Replace var assignments with let in ui tests This change was applied to any .js files under __tests__ directories in the ui module. This was an automatic replacement from var to let for any variable declaration that doubles as the initial assignment. Ultimately we want most of these to be converted to const, but this commit is so large that it warrants breaking each step of automation up into its own commit. For example: var foo = 'bar'; becomes let foo = 'var'; This was accomplished by replacing: find: var ([a-zA-Z_$][0-9a-zA-Z_$]*)(\s+)= replace: let $1$2= * Original sha: 863228de379846b54d6a2dbfd56cb90ecaf86bb8 * Authored by Court Ewing on 2016-04-12T15:30:18Z --- src/ui/__tests__/ui_exports.js | 4 +- src/ui/public/Binder/__tests__/Binder.js | 26 +-- .../IndexedArray/__tests__/IndexedArray.js | 40 ++-- .../IndexedArray/__tests__/inflector.js | 16 +- src/ui/public/Vis/__tests__/_AggConfig.js | 96 ++++---- .../public/Vis/__tests__/_AggConfigResult.js | 48 ++-- src/ui/public/Vis/__tests__/_AggConfigs.js | 90 ++++---- src/ui/public/Vis/__tests__/_Renderbot.js | 4 +- src/ui/public/Vis/__tests__/_Vis.js | 18 +- .../geo_json/__tests__/geo_json.js | 38 ++-- .../__tests__/array_to_linked_list.js | 4 +- .../__tests__/build_hierarchical_data.js | 38 ++-- .../hierarchical/__tests__/collect_branch.js | 8 +- .../hierarchical/__tests__/create_raw_data.js | 18 +- .../hierarchical/__tests__/extract_buckets.js | 14 +- .../__tests__/transform_aggregation.js | 14 +- .../point_series/__tests__/_add_to_siri.js | 26 +-- .../point_series/__tests__/_fake_x_aspect.js | 8 +- .../point_series/__tests__/_get_aspects.js | 20 +- .../point_series/__tests__/_get_point.js | 32 +-- .../point_series/__tests__/_get_series.js | 42 ++-- .../point_series/__tests__/_init_x_axis.js | 14 +- .../point_series/__tests__/_init_y_axis.js | 18 +- .../point_series/__tests__/_main.js | 94 ++++---- .../__tests__/_ordered_date_axis.js | 28 +-- .../__tests__/_tooltip_formatter.js | 22 +- .../agg_response/tabify/__tests__/_buckets.js | 22 +- .../tabify/__tests__/_get_columns.js | 28 +-- .../tabify/__tests__/_integration.js | 22 +- .../tabify/__tests__/_response_writer.js | 138 ++++++------ .../agg_response/tabify/__tests__/_table.js | 32 +-- .../tabify/__tests__/_table_group.js | 6 +- src/ui/public/agg_table/__tests__/_group.js | 28 +-- src/ui/public/agg_table/__tests__/_table.js | 54 ++--- .../agg_types/__tests__/AggParamWriter.js | 22 +- .../public/agg_types/__tests__/AggParams.js | 26 +-- src/ui/public/agg_types/__tests__/AggType.js | 46 ++-- .../agg_types/__tests__/bucketCountBetween.js | 64 +++--- .../agg_types/__tests__/buckets/_histogram.js | 26 +-- .../agg_types/__tests__/buckets/_range.js | 20 +- .../buckets/create_filter/date_histogram.js | 28 +-- .../buckets/create_filter/date_range.js | 12 +- .../buckets/create_filter/filters.js | 12 +- .../buckets/create_filter/histogram.js | 12 +- .../buckets/create_filter/ip_range.js | 16 +- .../__tests__/buckets/create_filter/range.js | 10 +- .../__tests__/buckets/create_filter/terms.js | 10 +- .../buckets/date_histogram/_editor.js | 22 +- .../buckets/date_histogram/_params.js | 50 ++--- .../__tests__/controls/number_list.js | 24 +- src/ui/public/agg_types/__tests__/index.js | 4 +- .../param_types/_calculate_interval.js | 16 +- .../agg_types/__tests__/param_types/_field.js | 8 +- .../__tests__/param_types/_optioned.js | 8 +- .../__tests__/param_types/_raw_json.js | 16 +- .../agg_types/__tests__/param_types/_regex.js | 14 +- .../__tests__/param_types/_string.js | 18 +- .../__tests__/utils/_stub_agg_params.js | 10 +- src/ui/public/bind/__tests__/bind.js | 18 +- .../public/chrome/__tests__/nav_controls.js | 4 +- .../app_switcher/__tests__/app_switcher.js | 62 ++--- src/ui/public/config/__tests__/config.js | 18 +- .../data_source/__tests__/decorate_query.js | 10 +- .../__tests__/normalize_sort_request.js | 34 +-- src/ui/public/courier/fetch/__tests__/doc.js | 10 +- .../__tests__/segmented_create_queue.js | 2 +- src/ui/public/debounce/__tests__/debounce.js | 22 +- .../__tests__/auto_select_if_only_one.js | 16 +- src/ui/public/directives/__tests__/config.js | 22 +- .../directives/__tests__/confirm-click.js | 12 +- .../directives/__tests__/css_truncate.js | 10 +- .../directives/__tests__/fixedScroll.js | 36 +-- .../public/directives/__tests__/inequality.js | 6 +- .../directives/__tests__/input_focus.js | 10 +- .../__tests__/input_whole_number.js | 12 +- .../public/directives/__tests__/json_input.js | 12 +- .../directives/__tests__/parse_query.js | 18 +- src/ui/public/directives/__tests__/spinner.js | 10 +- .../public/directives/__tests__/timepicker.js | 34 +-- .../public/directives/__tests__/truncate.js | 10 +- .../public/directives/__tests__/typeahead.js | 34 +-- .../__tests__/validate_cidr_mask.js | 14 +- .../__tests__/validate_date_math.js | 14 +- .../__tests__/validate_index_name.js | 18 +- .../directives/__tests__/validate_ip.js | 14 +- .../directives/__tests__/validate_json.js | 18 +- .../public/doc_table/__tests__/doc_table.js | 18 +- .../doc_table/__tests__/lib/get_sort.js | 8 +- .../doc_table/__tests__/lib/rows_headers.js | 62 ++--- .../public/doc_title/__tests__/doc_title.js | 14 +- .../public/doc_viewer/__tests__/doc_viewer.js | 36 +-- .../public/factories/__tests__/base_object.js | 24 +- src/ui/public/factories/__tests__/events.js | 66 +++--- .../fancy_forms/__tests__/fancy_forms.js | 6 +- .../field_editor/__tests__/field_editor.js | 14 +- .../filter_bar/__tests__/_addFilters.js | 24 +- .../filter_bar/__tests__/_getFilters.js | 38 ++-- .../filter_bar/__tests__/_invertFilters.js | 14 +- .../filter_bar/__tests__/_pinFilters.js | 24 +- .../filter_bar/__tests__/_removeFilters.js | 16 +- .../filter_bar/__tests__/_toggleFilters.js | 14 +- .../filter_bar/__tests__/_updateFilters.js | 12 +- .../public/filter_bar/__tests__/filter_bar.js | 24 +- .../filter_bar/__tests__/push_filter.js | 8 +- .../filter_bar/__tests__/query_filter.js | 6 +- .../lib/__tests__/changeTimeFilter.js | 10 +- .../filter_bar/lib/__tests__/dedupFilters.js | 22 +- .../lib/__tests__/extractTimeFilter.js | 10 +- .../lib/__tests__/filterAppliedAndUnwrap.js | 8 +- .../lib/__tests__/filterOutTimeBasedFilter.js | 8 +- .../lib/__tests__/generateMappingChain.js | 58 ++--- .../lib/__tests__/mapAndFlattenFilters.js | 8 +- .../filter_bar/lib/__tests__/mapDefault.js | 10 +- .../filter_bar/lib/__tests__/mapExists.js | 8 +- .../filter_bar/lib/__tests__/mapFilter.js | 16 +- .../lib/__tests__/mapFlattenAndWrapFilters.js | 10 +- .../lib/__tests__/mapGeoBoundingBox.js | 10 +- .../filter_bar/lib/__tests__/mapMissing.js | 8 +- .../lib/__tests__/mapQueryString.js | 8 +- .../filter_bar/lib/__tests__/mapRange.js | 12 +- .../filter_bar/lib/__tests__/mapScript.js | 10 +- .../filter_bar/lib/__tests__/mapTerms.js | 10 +- .../filter_bar/lib/__tests__/onlyDisabled.js | 44 ++-- .../filter_bar/lib/__tests__/uniqFilters.js | 16 +- .../__tests__/filter_manager.js | 14 +- .../filter_manager/lib/__tests__/phrase.js | 8 +- .../filter_manager/lib/__tests__/query.js | 8 +- .../filter_manager/lib/__tests__/range.js | 12 +- src/ui/public/filters/__tests__/commaList.js | 4 +- src/ui/public/filters/__tests__/field_type.js | 12 +- src/ui/public/filters/__tests__/label.js | 12 +- src/ui/public/filters/__tests__/moment.js | 14 +- src/ui/public/filters/__tests__/rison.js | 12 +- src/ui/public/filters/__tests__/short_dots.js | 10 +- src/ui/public/filters/__tests__/start_from.js | 8 +- src/ui/public/filters/__tests__/uriescape.js | 10 +- .../public/highlight/__tests__/highlight.js | 24 +- .../index_patterns/__tests__/_FieldFormat.js | 52 ++--- .../__tests__/_cast_mapping_type.js | 10 +- .../__tests__/_get_computed_fields.js | 6 +- .../__tests__/_index_pattern.js | 102 ++++----- .../index_patterns/__tests__/_map_field.js | 22 +- .../__tests__/_pattern_to_wildcard.js | 4 +- .../index_patterns/__tests__/flatten_hit.js | 8 +- .../index_patterns/__tests__/intervals.js | 56 ++--- .../jquery/__tests__/findTestSubject.js | 44 ++-- src/ui/public/listen/__tests__/listen.js | 24 +- .../notify/__tests__/lib/_format_es_msg.js | 20 +- .../notify/__tests__/lib/_format_msg.js | 20 +- src/ui/public/notify/__tests__/notifier.js | 30 +-- .../public/paginated_table/__tests__/index.js | 78 +++---- .../persisted_log/__tests__/persisted_log.js | 46 ++-- .../__tests__/persisted_state.js | 212 +++++++++--------- src/ui/public/private/__tests__/private.js | 34 +-- .../__tests__/reflow_watcher.js | 20 +- src/ui/public/registry/__tests__/index.js | 46 ++-- .../public/routes/__tests__/_RouteManager.js | 20 +- src/ui/public/routes/__tests__/_WorkQueue.js | 20 +- .../routes/__tests__/_wrapRouteWithPrep.js | 24 +- .../safe_confirm/__tests__/safe_confirm.js | 8 +- .../state_management/__tests__/app_state.js | 12 +- .../__tests__/global_state.js | 6 +- .../state_management/__tests__/state.js | 42 ++-- src/ui/public/storage/__tests__/storage.js | 26 +-- src/ui/public/stringify/__tests__/_color.js | 8 +- .../stringify/__tests__/_conformance.js | 28 +-- src/ui/public/stringify/__tests__/_date.js | 16 +- src/ui/public/stringify/__tests__/_ip.js | 6 +- src/ui/public/stringify/__tests__/_source.js | 12 +- src/ui/public/stringify/__tests__/_string.js | 8 +- .../public/stringify/__tests__/_truncate.js | 20 +- src/ui/public/stringify/__tests__/_url.js | 36 +-- .../styleCompile/__tests__/styleCompile.js | 8 +- .../timefilter/__tests__/diff_interval.js | 6 +- .../public/timefilter/__tests__/diff_time.js | 6 +- src/ui/public/timefilter/__tests__/index.js | 2 +- src/ui/public/url/__tests__/url.js | 86 +++---- src/ui/public/utils/__tests__/Ipv4Address.js | 8 +- src/ui/public/utils/__tests__/ObjDefine.js | 52 ++--- .../public/utils/__tests__/SimpleEmitter.js | 28 +-- .../public/utils/__tests__/add_word_breaks.js | 12 +- src/ui/public/utils/__tests__/cidr_mask.js | 12 +- src/ui/public/utils/__tests__/datemath.js | 26 +-- src/ui/public/utils/__tests__/diff_object.js | 56 ++--- .../utils/__tests__/diff_time_picker_vals.js | 30 +-- .../public/utils/__tests__/ordinal_suffix.js | 12 +- .../public/utils/__tests__/parse_interval.js | 14 +- src/ui/public/utils/__tests__/range.js | 10 +- src/ui/public/utils/__tests__/scanner.js | 10 +- src/ui/public/utils/__tests__/sequencer.js | 8 +- src/ui/public/utils/__tests__/slugify_id.js | 12 +- .../utils/lodash-mixins/__tests__/_move.js | 16 +- .../lodash-mixins/__tests__/_organize_by.js | 14 +- .../lodash-mixins/__tests__/_push_all.js | 10 +- .../vislib/__tests__/components/color.js | 38 ++-- .../vislib/__tests__/components/labels.js | 62 ++--- .../__tests__/components/zero_injection.js | 46 ++-- src/ui/public/vislib/__tests__/index.js | 10 +- .../public/vislib/__tests__/lib/axis_title.js | 14 +- .../vislib/__tests__/lib/chart_title.js | 14 +- src/ui/public/vislib/__tests__/lib/data.js | 82 +++---- .../public/vislib/__tests__/lib/dispatch.js | 30 +-- .../vislib/__tests__/lib/error_handler.js | 6 +- .../vislib/__tests__/lib/handler/handler.js | 22 +- .../vislib/__tests__/lib/layout/layout.js | 22 +- .../__tests__/lib/layout/layout_types.js | 8 +- .../lib/layout/splits/column_chart/splits.js | 12 +- .../lib/layout/types/column_layout.js | 12 +- .../vislib/__tests__/lib/resize_checker.js | 50 ++--- src/ui/public/vislib/__tests__/lib/x_axis.js | 14 +- src/ui/public/vislib/__tests__/lib/y_axis.js | 74 +++--- src/ui/public/vislib/__tests__/vis.js | 40 ++-- .../__tests__/visualizations/area_chart.js | 38 ++-- .../vislib/__tests__/visualizations/chart.js | 12 +- .../__tests__/visualizations/column_chart.js | 56 ++--- .../__tests__/visualizations/line_chart.js | 42 ++-- .../__tests__/visualizations/pie_chart.js | 52 ++--- .../__tests__/visualizations/tile_maps/map.js | 58 ++--- .../visualizations/tile_maps/markers.js | 144 ++++++------ .../visualizations/tile_maps/tile_map.js | 36 +-- .../__tests__/visualizations/time_marker.js | 36 +-- .../__tests__/visualizations/vis_types.js | 8 +- .../Tooltip/__tests__/positioning.js | 54 ++--- .../__tests__/_VislibRenderbot.js | 46 ++-- .../__tests__/_buildChartData.js | 42 ++-- .../watch_multi/__tests__/watch_multi.js | 36 +-- 226 files changed, 2873 insertions(+), 2873 deletions(-) diff --git a/src/ui/__tests__/ui_exports.js b/src/ui/__tests__/ui_exports.js index 7113adffd95a1..6ef4e6cabf158 100644 --- a/src/ui/__tests__/ui_exports.js +++ b/src/ui/__tests__/ui_exports.js @@ -5,7 +5,7 @@ import UiExports from '../UiExports'; describe('UiExports', function () { describe('#find()', function () { it('finds exports based on the passed export names', function () { - var uiExports = new UiExports({}); + let uiExports = new UiExports({}); uiExports.aliases.foo = ['a', 'b', 'c']; uiExports.aliases.bar = ['d', 'e', 'f']; @@ -15,7 +15,7 @@ describe('UiExports', function () { }); it('allows query types that match nothing', function () { - var uiExports = new UiExports({}); + let uiExports = new UiExports({}); uiExports.aliases.foo = ['a', 'b', 'c']; expect(uiExports.find(['foo'])).to.eql(['a', 'b', 'c']); diff --git a/src/ui/public/Binder/__tests__/Binder.js b/src/ui/public/Binder/__tests__/Binder.js index dd26ad08728f3..cba69bddba4a6 100644 --- a/src/ui/public/Binder/__tests__/Binder.js +++ b/src/ui/public/Binder/__tests__/Binder.js @@ -1,9 +1,9 @@ -var $ = require('jquery'); -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let $ = require('jquery'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); -var Binder = require('ui/Binder'); +let Binder = require('ui/Binder'); describe('Binder class', function () { let $scope; @@ -16,13 +16,13 @@ describe('Binder class', function () { context('Constructing with a $scope', function () { it('accepts a $scope and listens for $destroy', function () { sinon.stub($scope, '$on'); - var binder = new Binder($scope); + let binder = new Binder($scope); expect($scope.$on.callCount).to.be(1); expect($scope.$on.args[0][0]).to.be('$destroy'); }); it('unbinds when the $scope is destroyed', function () { - var binder = new Binder($scope); + let binder = new Binder($scope); sinon.stub(binder, 'destroy'); $scope.$destroy(); expect(binder.destroy.callCount).to.be(1); @@ -31,12 +31,12 @@ describe('Binder class', function () { describe('Binder#on', function () { it('binds to normal event emitters', function () { - var binder = new Binder(); - var emitter = { + let binder = new Binder(); + let emitter = { on: sinon.stub(), removeListener: sinon.stub() }; - var handler = sinon.stub(); + let handler = sinon.stub(); binder.on(emitter, 'click', handler); expect(emitter.on.callCount).to.be(1); @@ -52,9 +52,9 @@ describe('Binder class', function () { describe('Binder#jqOn', function () { it('binds jquery event handlers', function () { - var binder = new Binder(); - var el = document.createElement('div'); - var handler = sinon.stub(); + let binder = new Binder(); + let el = document.createElement('div'); + let handler = sinon.stub(); binder.jqOn(el, 'click', handler); $(el).click(); diff --git a/src/ui/public/IndexedArray/__tests__/IndexedArray.js b/src/ui/public/IndexedArray/__tests__/IndexedArray.js index 56d3f30c7cc6a..63b5324f0b984 100644 --- a/src/ui/public/IndexedArray/__tests__/IndexedArray.js +++ b/src/ui/public/IndexedArray/__tests__/IndexedArray.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var IndexedArray = require('ui/IndexedArray'); +let _ = require('lodash'); +let expect = require('expect.js'); +let IndexedArray = require('ui/IndexedArray'); // this is generally a data-structure that IndexedArray is good for managing -var users = [ +let users = [ { name: 'John', id: 69, username: 'beast', group: 'admins' }, { name: 'Anon', id: 0, username: 'shhhh', group: 'secret' }, { name: 'Fern', id: 42, username: 'kitty', group: 'editor' }, @@ -43,7 +43,7 @@ describe('IndexedArray', function () { describe('Indexing', function () { it('provides the initial set', function () { - var reg = new IndexedArray({ + let reg = new IndexedArray({ initialSet: [1, 2, 3] }); @@ -55,7 +55,7 @@ describe('IndexedArray', function () { }); it('indexes the initial set', function () { - var reg = new IndexedArray({ + let reg = new IndexedArray({ index: ['username'], initialSet: users }); @@ -66,11 +66,11 @@ describe('IndexedArray', function () { it('updates indices after values are added', function () { // split up the user list, and add it in chunks - var firstUser = users.slice(0, 1).pop(); - var otherUsers = users.slice(1); + let firstUser = users.slice(0, 1).pop(); + let otherUsers = users.slice(1); // start off with all but the first - var reg = new IndexedArray({ + let reg = new IndexedArray({ group: ['group'], order: ['id'], initialSet: otherUsers @@ -86,7 +86,7 @@ describe('IndexedArray', function () { it('updates indices after values are removed', function () { // start off with all - var reg = new IndexedArray({ + let reg = new IndexedArray({ group: ['group'], order: ['id'], initialSet: users @@ -95,18 +95,18 @@ describe('IndexedArray', function () { // remove the last reg.pop(); - var expectedCount = users.length - 1; + let expectedCount = users.length - 1; // indexed lists should be updated expect(reg).to.have.length(expectedCount); - var sumOfGroups = _.reduce(reg.byGroup, function (note, group) { + let sumOfGroups = _.reduce(reg.byGroup, function (note, group) { return note + group.length; }, 0); expect(sumOfGroups).to.eql(expectedCount); }); it('removes items based on a predicate', function () { - var reg = new IndexedArray({ + let reg = new IndexedArray({ group: ['group'], order: ['id'], initialSet: users @@ -120,26 +120,26 @@ describe('IndexedArray', function () { }); it('updates indices after values are re-ordered', function () { - var rawUsers = users.slice(0); + let rawUsers = users.slice(0); // collect and shuffle the ids available - var ids = []; + let ids = []; _.times(rawUsers.length, function (i) { ids.push(i); }); ids = _.shuffle(ids); // move something here - var toI = ids.shift(); + let toI = ids.shift(); // from here - var fromI = ids.shift(); + let fromI = ids.shift(); // do the move - var move = function (arr) { arr.splice(toI, 0, arr.splice(fromI, 1)[0]); }; + let move = function (arr) { arr.splice(toI, 0, arr.splice(fromI, 1)[0]); }; - var reg = new IndexedArray({ + let reg = new IndexedArray({ index: ['username'], initialSet: rawUsers }); - var index = reg.byUsername; + let index = reg.byUsername; move(reg); diff --git a/src/ui/public/IndexedArray/__tests__/inflector.js b/src/ui/public/IndexedArray/__tests__/inflector.js index eb4f04696702a..d418931a36af6 100644 --- a/src/ui/public/IndexedArray/__tests__/inflector.js +++ b/src/ui/public/IndexedArray/__tests__/inflector.js @@ -1,15 +1,15 @@ -var inflector = require('ui/IndexedArray/inflector'); -var expect = require('expect.js'); +let inflector = require('ui/IndexedArray/inflector'); +let expect = require('expect.js'); describe('IndexedArray Inflector', function () { it('returns a function', function () { - var getter = inflector(); + let getter = inflector(); expect(getter).to.be.a('function'); }); describe('fn', function () { it('prepends a prefix', function () { - var inflect = inflector('my'); + let inflect = inflector('my'); expect(inflect('Family')).to.be('myFamily'); expect(inflect('family')).to.be('myFamily'); @@ -17,7 +17,7 @@ describe('IndexedArray Inflector', function () { }); it('adds both a prefix and suffix', function () { - var inflect = inflector('foo', 'Bar'); + let inflect = inflector('foo', 'Bar'); expect(inflect('box')).to.be('fooBoxBar'); expect(inflect('box.car.MAX')).to.be('fooBoxCarMaxBar'); @@ -25,19 +25,19 @@ describe('IndexedArray Inflector', function () { }); it('ignores prefix if it is already at the end of the inflected string', function () { - var inflect = inflector('foo', 'Bar'); + let inflect = inflector('foo', 'Bar'); expect(inflect('fooBox')).to.be('fooBoxBar'); expect(inflect('FooBox')).to.be('FooBoxBar'); }); it('ignores postfix if it is already at the end of the inflected string', function () { - var inflect = inflector('foo', 'Bar'); + let inflect = inflector('foo', 'Bar'); expect(inflect('bar')).to.be('fooBar'); expect(inflect('showBoxBar')).to.be('fooShowBoxBar'); }); it('works with "name"', function () { - var inflect = inflector('in', 'Order'); + let inflect = inflector('in', 'Order'); expect(inflect('name')).to.be('inNameOrder'); }); }); diff --git a/src/ui/public/Vis/__tests__/_AggConfig.js b/src/ui/public/Vis/__tests__/_AggConfig.js index 3281dae93c0b8..9297e92db43fc 100644 --- a/src/ui/public/Vis/__tests__/_AggConfig.js +++ b/src/ui/public/Vis/__tests__/_AggConfig.js @@ -1,7 +1,7 @@ describe('AggConfig', function () { - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Vis; let AggType; @@ -20,7 +20,7 @@ describe('AggConfig', function () { describe('#toDsl', function () { it('calls #write()', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -30,15 +30,15 @@ describe('AggConfig', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; - var stub = sinon.stub(aggConfig, 'write').returns({ params: {} }); + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let stub = sinon.stub(aggConfig, 'write').returns({ params: {} }); aggConfig.toDsl(); expect(stub.callCount).to.be(1); }); it('uses the type name as the agg name', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -48,15 +48,15 @@ describe('AggConfig', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; sinon.stub(aggConfig, 'write').returns({ params: {} }); - var dsl = aggConfig.toDsl(); + let dsl = aggConfig.toDsl(); expect(dsl).to.have.property('date_histogram'); }); it('uses the params from #write() output as the agg params', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -66,17 +66,17 @@ describe('AggConfig', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; - var football = {}; + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let football = {}; sinon.stub(aggConfig, 'write').returns({ params: football }); - var dsl = aggConfig.toDsl(); + let dsl = aggConfig.toDsl(); expect(dsl.date_histogram).to.be(football); }); it('includes subAggs from #write() output', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -90,14 +90,14 @@ describe('AggConfig', function () { ] }); - var histoConfig = vis.aggs.byTypeName.date_histogram[0]; - var avgConfig = vis.aggs.byTypeName.avg[0]; - var football = {}; + let histoConfig = vis.aggs.byTypeName.date_histogram[0]; + let avgConfig = vis.aggs.byTypeName.avg[0]; + let football = {}; sinon.stub(histoConfig, 'write').returns({ params: {}, subAggs: [avgConfig] }); sinon.stub(avgConfig, 'write').returns({ params: football }); - var dsl = histoConfig.toDsl(); + let dsl = histoConfig.toDsl(); // didn't use .eql() because of variable key names, and final check is strict expect(dsl).to.have.property('aggs'); @@ -109,7 +109,7 @@ describe('AggConfig', function () { describe('::ensureIds', function () { it('accepts an array of objects and assigns ids to them', function () { - var objs = [ + let objs = [ {}, {}, {}, @@ -123,7 +123,7 @@ describe('AggConfig', function () { }); it('assigns ids relative to the other items in the list', function () { - var objs = [ + let objs = [ { id: '100' }, {}, ]; @@ -133,7 +133,7 @@ describe('AggConfig', function () { }); it('assigns ids relative to the other items in the list', function () { - var objs = [ + let objs = [ { id: '100' }, { id: '200' }, { id: '500' }, @@ -150,14 +150,14 @@ describe('AggConfig', function () { it('uses ::nextId to get the starting value', function () { sinon.stub(AggConfig, 'nextId').returns(534); - var objs = AggConfig.ensureIds([{}]); + let objs = AggConfig.ensureIds([{}]); expect(objs[0]).to.have.property('id', '534'); }); it('only calls ::nextId once', function () { - var start = 420; + let start = 420; sinon.stub(AggConfig, 'nextId').returns(start); - var objs = AggConfig.ensureIds([{}, {}, {}, {}, {}, {}, {}]); + let objs = AggConfig.ensureIds([{}, {}, {}, {}, {}, {}, {}]); expect(AggConfig.nextId).to.have.property('callCount', 1); objs.forEach(function (obj, i) { @@ -168,12 +168,12 @@ describe('AggConfig', function () { describe('::nextId', function () { it('accepts a list of objects and picks the next id', function () { - var next = AggConfig.nextId([ {id: 100}, {id: 500} ]); + let next = AggConfig.nextId([ {id: 100}, {id: 500} ]); expect(next).to.be(501); }); it('handles an empty list', function () { - var next = AggConfig.nextId([]); + let next = AggConfig.nextId([]); expect(next).to.be(1); }); @@ -186,7 +186,7 @@ describe('AggConfig', function () { describe('#toJSON', function () { it('includes the aggs id, params, type and schema', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -196,13 +196,13 @@ describe('AggConfig', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; expect(aggConfig.id).to.be('1'); expect(aggConfig.params).to.be.an('object'); expect(aggConfig.type).to.be.an(AggType).and.have.property('name', 'date_histogram'); expect(aggConfig.schema).to.be.an('object').and.have.property('name', 'segment'); - var state = aggConfig.toJSON(); + let state = aggConfig.toJSON(); expect(state).to.have.property('id', '1'); expect(state.params).to.be.an('object'); expect(state).to.have.property('type', 'date_histogram'); @@ -212,37 +212,37 @@ describe('AggConfig', function () { describe('#makeLabel', function () { it('uses the custom label if it is defined', function () { - var vis = new Vis(indexPattern, {}); - var aggConfig = vis.aggs[0]; + let vis = new Vis(indexPattern, {}); + let aggConfig = vis.aggs[0]; aggConfig.params.customLabel = 'Custom label'; - var label = aggConfig.makeLabel(); + let label = aggConfig.makeLabel(); expect(label).to.be(aggConfig.params.customLabel); }); it('default label should be "Count"', function () { - var vis = new Vis(indexPattern, {}); - var aggConfig = vis.aggs[0]; - var label = aggConfig.makeLabel(); + let vis = new Vis(indexPattern, {}); + let aggConfig = vis.aggs[0]; + let label = aggConfig.makeLabel(); expect(label).to.be('Count'); }); it('default label should be "Percentage of Count" when Vis is in percentage mode', function () { - var vis = new Vis(indexPattern, {}); - var aggConfig = vis.aggs[0]; + let vis = new Vis(indexPattern, {}); + let aggConfig = vis.aggs[0]; aggConfig.vis.params.mode = 'percentage'; - var label = aggConfig.makeLabel(); + let label = aggConfig.makeLabel(); expect(label).to.be('Percentage of Count'); }); it('empty label if the Vis type is not defined', function () { - var vis = new Vis(indexPattern, {}); - var aggConfig = vis.aggs[0]; + let vis = new Vis(indexPattern, {}); + let aggConfig = vis.aggs[0]; aggConfig.type = undefined; - var label = aggConfig.makeLabel(); + let label = aggConfig.makeLabel(); expect(label).to.be(''); }); }); describe('#fieldFormatter', function () { it('returns the fields format unless the agg type has a custom getFormat handler', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -268,7 +268,7 @@ describe('AggConfig', function () { }); it('returns the string format if the field does not have a format', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -279,13 +279,13 @@ describe('AggConfig', function () { ] }); - var agg = vis.aggs[0]; + let agg = vis.aggs[0]; agg.params.field = { type: 'date', format: null }; expect(agg.fieldFormatter()).to.be(fieldFormat.getDefaultInstance('string').getConverterFor()); }); it('returns the string format if their is no field', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -296,13 +296,13 @@ describe('AggConfig', function () { ] }); - var agg = vis.aggs[0]; + let agg = vis.aggs[0]; delete agg.params.field; expect(agg.fieldFormatter()).to.be(fieldFormat.getDefaultInstance('string').getConverterFor()); }); it('returns the html converter if "html" is passed in', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -313,7 +313,7 @@ describe('AggConfig', function () { ] }); - var field = indexPattern.fields.byName.ssl; + let field = indexPattern.fields.byName.ssl; expect(vis.aggs[0].fieldFormatter('html')).to.be(field.format.getConverterFor('html')); }); }); diff --git a/src/ui/public/Vis/__tests__/_AggConfigResult.js b/src/ui/public/Vis/__tests__/_AggConfigResult.js index 8816e5ba0b88f..d855090527907 100644 --- a/src/ui/public/Vis/__tests__/_AggConfigResult.js +++ b/src/ui/public/Vis/__tests__/_AggConfigResult.js @@ -1,8 +1,8 @@ describe('AggConfigResult', function () { - var _ = require('lodash'); - var AggConfigResult = require('ui/Vis/AggConfigResult'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let AggConfig; let indexPattern; @@ -17,12 +17,12 @@ describe('AggConfigResult', function () { describe('initialization', function () { it('should set the type to bucket for bucket based results', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: '_type' } } ] }); - var aggConfig = vis.aggs.byTypeName.terms[0]; - var results = new AggConfigResult(aggConfig, null, 10, 'apache'); + let aggConfig = vis.aggs.byTypeName.terms[0]; + let results = new AggConfigResult(aggConfig, null, 10, 'apache'); expect(results).to.have.property('aggConfig', aggConfig); expect(results).to.have.property('$parent', null); expect(results).to.have.property('type', 'bucket'); @@ -31,12 +31,12 @@ describe('AggConfigResult', function () { }); it('should set the type to metric for metric based results', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } } ] }); - var aggConfig = vis.aggs.byTypeName.avg[0]; - var results = new AggConfigResult(aggConfig, null, 1024); + let aggConfig = vis.aggs.byTypeName.avg[0]; + let results = new AggConfigResult(aggConfig, null, 1024); expect(results).to.have.property('aggConfig', aggConfig); expect(results).to.have.property('$parent', null); expect(results).to.have.property('type', 'metric'); @@ -50,18 +50,18 @@ describe('AggConfigResult', function () { describe('getPath()', function () { it('should return the parent and itself (in an array) for the path', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: '_type' } }, { type: 'terms', schema: 'segment', params: { field: 'extension' } } ] }); - var parentAggConfig = vis.aggs.byTypeName.terms[0]; - var aggConfig = vis.aggs.byTypeName.terms[1]; - var parentResult = new AggConfigResult(parentAggConfig, null, 20, 'apache'); - var result = new AggConfigResult(aggConfig, parentResult, 15, 'php'); - var path = result.getPath(); + let parentAggConfig = vis.aggs.byTypeName.terms[0]; + let aggConfig = vis.aggs.byTypeName.terms[1]; + let parentResult = new AggConfigResult(parentAggConfig, null, 20, 'apache'); + let result = new AggConfigResult(aggConfig, parentResult, 15, 'php'); + let path = result.getPath(); expect(path).to.be.an(Array); expect(path).to.have.length(2); expect(path[0]).to.be(parentResult); @@ -69,15 +69,15 @@ describe('AggConfigResult', function () { }); it('should return itself (in an array) for the path', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: 'extension' } } ] }); - var aggConfig = vis.aggs.byTypeName.terms[0]; - var result = new AggConfigResult(aggConfig, null, 15, 'php'); - var path = result.getPath(); + let aggConfig = vis.aggs.byTypeName.terms[0]; + let result = new AggConfigResult(aggConfig, null, 15, 'php'); + let path = result.getPath(); expect(path).to.be.an(Array); expect(path).to.have.length(1); expect(path[0]).to.be(result); @@ -87,15 +87,15 @@ describe('AggConfigResult', function () { describe('createFilter', function () { it('should return a filter object that represents the result', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: 'extension' } } ] }); - var aggConfig = vis.aggs.byTypeName.terms[0]; - var result = new AggConfigResult(aggConfig, null, 15, 'php'); - var filter = result.createFilter(); + let aggConfig = vis.aggs.byTypeName.terms[0]; + let result = new AggConfigResult(aggConfig, null, 15, 'php'); + let filter = result.createFilter(); expect(filter).to.have.property('query'); expect(filter.query).to.have.property('match'); expect(filter.query.match).to.have.property('extension'); diff --git a/src/ui/public/Vis/__tests__/_AggConfigs.js b/src/ui/public/Vis/__tests__/_AggConfigs.js index 493b6291d73f1..a3c294e20306f 100644 --- a/src/ui/public/Vis/__tests__/_AggConfigs.js +++ b/src/ui/public/Vis/__tests__/_AggConfigs.js @@ -1,8 +1,8 @@ describe('AggConfigs', function () { - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Vis; let IndexedArray; @@ -15,9 +15,9 @@ describe('AggConfigs', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { // replace the AggConfig module with a spy - var RealAggConfigPM = require('ui/Vis/AggConfig'); + let RealAggConfigPM = require('ui/Vis/AggConfig'); AggConfig = Private(RealAggConfigPM); - var spy = sinon.spy(AggConfig); + let spy = sinon.spy(AggConfig); Object.defineProperty(spy, 'aggTypes', { get: function () { return AggConfig.aggTypes; }, set: function (val) { AggConfig.aggTypes = val; } @@ -35,28 +35,28 @@ describe('AggConfigs', function () { })); it('extends IndexedArray', function () { - var ac = new AggConfigs(); + let ac = new AggConfigs(); expect(ac).to.be.a(IndexedArray); }); describe('constructor', function () { it('handles passing just a vis', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var ac = new AggConfigs(vis); + let ac = new AggConfigs(vis); expect(ac).to.have.length(1); }); it('converts configStates into AggConfig objects if they are not already', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var ac = new AggConfigs(vis, [ + let ac = new AggConfigs(vis, [ { type: 'date_histogram', schema: 'segment' @@ -72,12 +72,12 @@ describe('AggConfigs', function () { }); it('attemps to ensure that all states have an id', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var states = [ + let states = [ { type: 'date_histogram', schema: 'segment' @@ -88,8 +88,8 @@ describe('AggConfigs', function () { } ]; - var spy = sinon.spy(SpiedAggConfig, 'ensureIds'); - var ac = new AggConfigs(vis, states); + let spy = sinon.spy(SpiedAggConfig, 'ensureIds'); + let ac = new AggConfigs(vis, states); expect(spy.callCount).to.be(1); expect(spy.firstCall.args[0]).to.be(states); }); @@ -130,17 +130,17 @@ describe('AggConfigs', function () { }); it('should only set the number of defaults defined by the max', function () { - var ac = new AggConfigs(vis); + let ac = new AggConfigs(vis); expect(ac.bySchemaName.metric).to.have.length(2); }); it('should set the defaults defined in the schema when none exist', function () { - var ac = new AggConfigs(vis); + let ac = new AggConfigs(vis); expect(ac).to.have.length(3); }); it('should NOT set the defaults defined in the schema when some exist', function () { - var ac = new AggConfigs(vis, [{ schema: 'segment', type: 'date_histogram' }]); + let ac = new AggConfigs(vis, [{ schema: 'segment', type: 'date_histogram' }]); expect(ac).to.have.length(3); expect(ac.bySchemaName.segment[0].type.name).to.equal('date_histogram'); }); @@ -149,7 +149,7 @@ describe('AggConfigs', function () { describe('#getRequestAggs', function () { it('performs a stable sort, but moves metrics to the bottom', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'avg', schema: 'metric' }, @@ -162,8 +162,8 @@ describe('AggConfigs', function () { ] }); - var sorted = vis.aggs.getRequestAggs(); - var aggs = _.indexBy(vis.aggs, function (agg) { + let sorted = vis.aggs.getRequestAggs(); + let aggs = _.indexBy(vis.aggs, function (agg) { return agg.type.name; }); @@ -180,7 +180,7 @@ describe('AggConfigs', function () { describe('#getResponseAggs', function () { it('returns all request aggs for basic aggs', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'split' }, @@ -189,8 +189,8 @@ describe('AggConfigs', function () { ] }); - var sorted = vis.aggs.getResponseAggs(); - var aggs = _.indexBy(vis.aggs, function (agg) { + let sorted = vis.aggs.getResponseAggs(); + let aggs = _.indexBy(vis.aggs, function (agg) { return agg.type.name; }); @@ -201,7 +201,7 @@ describe('AggConfigs', function () { }); it('expands aggs that have multiple responses', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'split' }, @@ -210,8 +210,8 @@ describe('AggConfigs', function () { ] }); - var sorted = vis.aggs.getResponseAggs(); - var aggs = _.indexBy(vis.aggs, function (agg) { + let sorted = vis.aggs.getResponseAggs(); + let aggs = _.indexBy(vis.aggs, function (agg) { return agg.type.name; }); @@ -226,14 +226,14 @@ describe('AggConfigs', function () { describe('#toDsl', function () { it('uses the sorted aggs', function () { - var vis = new Vis(indexPattern, { type: 'histogram' }); + let vis = new Vis(indexPattern, { type: 'histogram' }); sinon.spy(vis.aggs, 'getRequestAggs'); vis.aggs.toDsl(); expect(vis.aggs.getRequestAggs).to.have.property('callCount', 1); }); it('calls aggConfig#toDsl() on each aggConfig and compiles the nested output', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'date_histogram', schema: 'segment' }, @@ -241,8 +241,8 @@ describe('AggConfigs', function () { ] }); - var aggInfos = vis.aggs.map(function (aggConfig) { - var football = {}; + let aggInfos = vis.aggs.map(function (aggConfig) { + let football = {}; sinon.stub(aggConfig, 'toDsl', function () { return football; @@ -255,7 +255,7 @@ describe('AggConfigs', function () { }); (function recurse(lvl) { - var info = aggInfos.shift(); + let info = aggInfos.shift(); expect(lvl).to.have.property(info.id); expect(lvl[info.id]).to.be(info.football); @@ -269,7 +269,7 @@ describe('AggConfigs', function () { }); it('skips aggs that don\'t have a dsl representation', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, @@ -277,9 +277,9 @@ describe('AggConfigs', function () { ] }); - var dsl = vis.aggs.toDsl(); - var histo = vis.aggs.byTypeName.date_histogram[0]; - var count = vis.aggs.byTypeName.count[0]; + let dsl = vis.aggs.toDsl(); + let histo = vis.aggs.byTypeName.date_histogram[0]; + let count = vis.aggs.byTypeName.count[0]; expect(dsl).to.have.property(histo.id); expect(dsl[histo.id]).to.be.an('object'); @@ -288,7 +288,7 @@ describe('AggConfigs', function () { }); it('writes multiple metric aggregations at the same level', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, @@ -299,10 +299,10 @@ describe('AggConfigs', function () { ] }); - var dsl = vis.aggs.toDsl(); + let dsl = vis.aggs.toDsl(); - var histo = vis.aggs.byTypeName.date_histogram[0]; - var metrics = vis.aggs.bySchemaGroup.metrics; + let histo = vis.aggs.byTypeName.date_histogram[0]; + let metrics = vis.aggs.bySchemaGroup.metrics; expect(dsl).to.have.property(histo.id); expect(dsl[histo.id]).to.be.an('object'); @@ -315,7 +315,7 @@ describe('AggConfigs', function () { }); it('writes multiple metric aggregations at every level if the vis is hierarchical', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: 'ip', orderBy: 1 } }, @@ -328,12 +328,12 @@ describe('AggConfigs', function () { }); vis.isHierarchical = _.constant(true); - var topLevelDsl = vis.aggs.toDsl(); - var buckets = vis.aggs.bySchemaGroup.buckets; - var metrics = vis.aggs.bySchemaGroup.metrics; + let topLevelDsl = vis.aggs.toDsl(); + let buckets = vis.aggs.bySchemaGroup.buckets; + let metrics = vis.aggs.bySchemaGroup.metrics; (function checkLevel(dsl) { - var bucket = buckets.shift(); + let bucket = buckets.shift(); expect(dsl).to.have.property(bucket.id); expect(dsl[bucket.id]).to.be.an('object'); diff --git a/src/ui/public/Vis/__tests__/_Renderbot.js b/src/ui/public/Vis/__tests__/_Renderbot.js index db72e80f3895d..c2e95227703b3 100644 --- a/src/ui/public/Vis/__tests__/_Renderbot.js +++ b/src/ui/public/Vis/__tests__/_Renderbot.js @@ -1,7 +1,7 @@ describe('renderbot', function () { let Renderbot; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); function init() { ngMock.module('kibana'); diff --git a/src/ui/public/Vis/__tests__/_Vis.js b/src/ui/public/Vis/__tests__/_Vis.js index 77d2191f74f68..21512ab0ae66a 100644 --- a/src/ui/public/Vis/__tests__/_Vis.js +++ b/src/ui/public/Vis/__tests__/_Vis.js @@ -1,15 +1,15 @@ describe('Vis Class', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let indexPattern; let Vis; let visTypes; let vis; - var stateFixture = { + let stateFixture = { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -31,7 +31,7 @@ describe('Vis Class', function () { vis = new Vis(indexPattern, stateFixture); }); - var verifyVis = function (vis) { + let verifyVis = function (vis) { expect(vis).to.have.property('aggs'); expect(vis.aggs).to.have.length(3); @@ -55,7 +55,7 @@ describe('Vis Class', function () { describe('getState()', function () { it('should get a state that represents the... er... state', function () { - var state = vis.getState(); + let state = vis.getState(); expect(state).to.have.property('type', 'pie'); expect(state).to.have.property('params'); @@ -72,14 +72,14 @@ describe('Vis Class', function () { describe('clone()', function () { it('should make clone of itself', function () { - var clone = vis.clone(); + let clone = vis.clone(); verifyVis(clone); }); }); describe('setState()', function () { it('should set the state to defualts', function () { - var vis = new Vis(indexPattern); + let vis = new Vis(indexPattern); expect(vis).to.have.property('type'); expect(vis.type).to.eql(visTypes.byName.histogram); expect(vis).to.have.property('aggs'); @@ -99,7 +99,7 @@ describe('Vis Class', function () { expect(vis.isHierarchical()).to.be(true); }); it('should return false for non-hierarchical vis (like histogram)', function () { - var vis = new Vis(indexPattern); + let vis = new Vis(indexPattern); expect(vis.isHierarchical()).to.be(false); }); }); diff --git a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index 61cb4d0386704..d91c0715f9907 100644 --- a/src/ui/public/agg_response/geo_json/__tests__/geo_json.js +++ b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js @@ -1,7 +1,7 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('GeoJson Agg Response Converter', function () { let vis; @@ -12,8 +12,8 @@ describe('GeoJson Agg Response Converter', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var Vis = Private(require('ui/Vis')); - var indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); + let Vis = Private(require('ui/Vis')); + let indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); esResponse = Private(require('fixtures/agg_resp/geohash_grid')); tabify = Private(require('ui/agg_response/tabify/tabify')); @@ -55,8 +55,8 @@ describe('GeoJson Agg Response Converter', function () { describe('with table ' + JSON.stringify(tableOpts), function () { it('outputs a chart', function () { - var table = makeTable(); - var chart = makeSingleChart(table); + let table = makeTable(); + let chart = makeSingleChart(table); expect(chart).to.only.have.keys( 'title', 'tooltipFormatter', @@ -73,9 +73,9 @@ describe('GeoJson Agg Response Converter', function () { }); it('outputs geohash points as features in a feature collection', function () { - var table = makeTable(); - var chart = makeSingleChart(table); - var geoJson = chart.geoJson; + let table = makeTable(); + let chart = makeSingleChart(table); + let geoJson = chart.geoJson; expect(geoJson.type).to.be('FeatureCollection'); expect(geoJson.features).to.be.an('array'); @@ -83,8 +83,8 @@ describe('GeoJson Agg Response Converter', function () { }); it('exports a bunch of properties about the geo hash grid', function () { - var geoJson = makeGeoJson(); - var props = geoJson.properties; + let geoJson = makeGeoJson(); + let props = geoJson.properties; // props expect(props).to.be.an('object'); @@ -117,7 +117,7 @@ describe('GeoJson Agg Response Converter', function () { it('should be geoJson format', function () { table.rows.forEach(function (row, i) { - var feature = chart.geoJson.features[i]; + let feature = chart.geoJson.features[i]; expect(feature).to.have.property('geometry'); expect(feature.geometry).to.be.an('object'); expect(feature).to.have.property('properties'); @@ -127,7 +127,7 @@ describe('GeoJson Agg Response Converter', function () { it('should have valid geometry data', function () { table.rows.forEach(function (row, i) { - var geometry = chart.geoJson.features[i].geometry; + let geometry = chart.geoJson.features[i].geometry; expect(geometry.type).to.be('Point'); expect(geometry).to.have.property('coordinates'); expect(geometry.coordinates).to.be.an('array'); @@ -139,8 +139,8 @@ describe('GeoJson Agg Response Converter', function () { it('should have value properties data', function () { table.rows.forEach(function (row, i) { - var props = chart.geoJson.features[i].properties; - var keys = ['value', 'geohash', 'aggConfigResult', 'rectangle', 'center']; + let props = chart.geoJson.features[i].properties; + let keys = ['value', 'geohash', 'aggConfigResult', 'rectangle', 'center']; expect(props).to.be.an('object'); expect(props).to.only.have.keys(keys); expect(props.geohash).to.be.a('string'); @@ -150,15 +150,15 @@ describe('GeoJson Agg Response Converter', function () { it('should use latLng in properties and lngLat in geometry', function () { table.rows.forEach(function (row, i) { - var geometry = chart.geoJson.features[i].geometry; - var props = chart.geoJson.features[i].properties; + let geometry = chart.geoJson.features[i].geometry; + let props = chart.geoJson.features[i].properties; expect(props.center).to.eql(geometry.coordinates.slice(0).reverse()); }); }); it('should handle both AggConfig and non-AggConfig results', function () { table.rows.forEach(function (row, i) { - var props = chart.geoJson.features[i].properties; + let props = chart.geoJson.features[i].properties; if (tableOpts.asAggConfigResults) { expect(props.aggConfigResult).to.be(row[metricColI]); expect(props.value).to.be(row[metricColI].value); diff --git a/src/ui/public/agg_response/hierarchical/__tests__/array_to_linked_list.js b/src/ui/public/agg_response/hierarchical/__tests__/array_to_linked_list.js index ffa66906f1963..d7a92dd345133 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/array_to_linked_list.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/array_to_linked_list.js @@ -1,6 +1,6 @@ -var arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); -var expect = require('expect.js'); +let arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); +let expect = require('expect.js'); describe('buildHierarchicalData()', function () { describe('arrayToLinkedList', function () { diff --git a/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js b/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js index e891bac393781..0d3405ab95ed9 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js @@ -1,9 +1,9 @@ -var _ = require('lodash'); -var fixtures = require('fixtures/fake_hierarchical_data'); -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let fixtures = require('fixtures/fake_hierarchical_data'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let Vis; let Notifier; @@ -31,7 +31,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -44,7 +44,7 @@ describe('buildHierarchicalData', function () { }); it('should set the slices with one child to a consistent label', function () { - var checkLabel = 'Count'; + let checkLabel = 'Count'; expect(results).to.have.property('slices'); expect(results.slices).to.have.property('children'); expect(results.slices.children).to.have.length(1); @@ -63,8 +63,8 @@ describe('buildHierarchicalData', function () { describe('rows and columns', function () { it('should set the rows', function () { - var id = 1; - var vis = new Vis(indexPattern, { + let id = 1; + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -75,13 +75,13 @@ describe('buildHierarchicalData', function () { }); // We need to set the aggs to a known value. _.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; }); - var results = buildHierarchicalData(vis, fixtures.threeTermBuckets); + let results = buildHierarchicalData(vis, fixtures.threeTermBuckets); expect(results).to.have.property('rows'); }); it('should set the columns', function () { - var id = 1; - var vis = new Vis(indexPattern, { + let id = 1; + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -92,7 +92,7 @@ describe('buildHierarchicalData', function () { }); // We need to set the aggs to a known value. _.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; }); - var results = buildHierarchicalData(vis, fixtures.threeTermBuckets); + let results = buildHierarchicalData(vis, fixtures.threeTermBuckets); expect(results).to.have.property('columns'); }); @@ -103,7 +103,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -145,7 +145,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -177,7 +177,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -218,7 +218,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -254,7 +254,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -277,7 +277,7 @@ describe('buildHierarchicalData', function () { }); it('should set the hits attribute for the results', function () { - var errCall = Notifier.prototype.error.getCall(0); + let errCall = Notifier.prototype.error.getCall(0); expect(errCall).to.be.ok(); expect(errCall.args[0]).to.contain('not supported'); diff --git a/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js b/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js index 8bc2f6730ce5d..0b5574454aca5 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var collectBranch = require('ui/agg_response/hierarchical/_collect_branch'); -var expect = require('expect.js'); +let _ = require('lodash'); +let collectBranch = require('ui/agg_response/hierarchical/_collect_branch'); +let expect = require('expect.js'); describe('collectBranch()', function () { let results; - var convert = function (name) { + let convert = function (name) { return 'converted:' + name; }; diff --git a/src/ui/public/agg_response/hierarchical/__tests__/create_raw_data.js b/src/ui/public/agg_response/hierarchical/__tests__/create_raw_data.js index b289f6b534572..b4118c116a144 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/create_raw_data.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/create_raw_data.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var fixtures = require('fixtures/fake_hierarchical_data'); -var createRawData = require('ui/agg_response/hierarchical/_create_raw_data'); -var arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let fixtures = require('fixtures/fake_hierarchical_data'); +let createRawData = require('ui/agg_response/hierarchical/_create_raw_data'); +let arrayToLinkedList = require('ui/agg_response/hierarchical/_array_to_linked_list'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let AggConfigs; let Vis; @@ -24,7 +24,7 @@ describe('buildHierarchicalData()', function () { })); beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -34,7 +34,7 @@ describe('buildHierarchicalData()', function () { { type: 'terms', schema: 'segment', params: { field: 'geo.src' }} ] }); - var buckets = arrayToLinkedList(vis.aggs.bySchemaGroup.buckets); + let buckets = arrayToLinkedList(vis.aggs.bySchemaGroup.buckets); // We need to set the aggs to a known value. _.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; }); results = createRawData(vis, fixtures.threeTermBuckets); @@ -45,7 +45,7 @@ describe('buildHierarchicalData()', function () { expect(results.columns).to.have.length(6); _.each(results.columns, function (column) { expect(column).to.have.property('aggConfig'); - var agg = column.aggConfig; + let agg = column.aggConfig; expect(column).to.have.property('categoryName', agg.schema.name); expect(column).to.have.property('id', agg.id); expect(column).to.have.property('aggType', agg.type); diff --git a/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js b/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js index ebc0303cdd089..5c3b5f2186f79 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js @@ -1,20 +1,20 @@ -var extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); -var expect = require('expect.js'); +let extractBuckets = require('ui/agg_response/hierarchical/_extract_buckets'); +let expect = require('expect.js'); describe('buildHierarchicalData()', function () { describe('extractBuckets()', function () { it('should normalize a bucket object into an array', function () { - var bucket = { + let bucket = { buckets: { foo: { doc_count: 1 }, bar: { doc_count: 2 } } }; - var buckets = extractBuckets(bucket); + let buckets = extractBuckets(bucket); expect(buckets).to.be.an(Array); expect(buckets).to.have.length(2); expect(buckets[0]).to.have.property('key', 'foo'); @@ -24,19 +24,19 @@ describe('buildHierarchicalData()', function () { }); it('should return an empty array for undefined buckets', function () { - var buckets = extractBuckets(); + let buckets = extractBuckets(); expect(buckets).to.be.an(Array); expect(buckets).to.have.length(0); }); it('should return the bucket array', function () { - var bucket = { + let bucket = { buckets: [ { key: 'foo', doc_count: 1 }, { key: 'bar', doc_count: 2 } ] }; - var buckets = extractBuckets(bucket); + let buckets = extractBuckets(bucket); expect(buckets).to.be.an(Array); expect(buckets).to.be(bucket.buckets); }); diff --git a/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js b/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js index 26a37bfb6d0e1..9ebb2e8dd58cc 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js @@ -1,9 +1,9 @@ describe('buildHierarchicalData()', function () { describe('transformAggregation()', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let transform; let fixture; @@ -41,17 +41,17 @@ describe('buildHierarchicalData()', function () { }); it('relies on metricAgg#getValue() for the size of the children', function () { - var aggData = { + let aggData = { buckets: [ { key: 'foo' }, { key: 'bar' } ] }; - var football = {}; + let football = {}; fixture.metric.getValue = _.constant(football); - var children = transform(fixture.agg, fixture.metric, aggData); + let children = transform(fixture.agg, fixture.metric, aggData); expect(children).to.be.an(Array); expect(children).to.have.length(2); expect(children[0]).to.have.property('size', football); @@ -59,7 +59,7 @@ describe('buildHierarchicalData()', function () { }); it('should create two levels of metrics', function () { - var children = transform(fixture.agg, fixture.metric, fixture.aggData); + let children = transform(fixture.agg, fixture.metric, fixture.aggData); fixture.metric.getValue = function (b) { return b.doc_count; }; expect(children).to.be.an(Array); diff --git a/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js b/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js index 811e7c28a5e75..6aef0e16ead8c 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js +++ b/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js @@ -1,6 +1,6 @@ describe('addToSiri', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let addToSiri; beforeEach(ngMock.module('kibana')); @@ -9,9 +9,9 @@ describe('addToSiri', function () { })); it('creates a new series the first time it sees an id', function () { - var series = new Map(); - var point = {}; - var id = 'id'; + let series = new Map(); + let point = {}; + let id = 'id'; addToSiri(series, point, id); expect(series.has(id)).to.be(true); @@ -22,13 +22,13 @@ describe('addToSiri', function () { }); it('adds points to existing series if id has been seen', function () { - var series = new Map(); - var id = 'id'; + let series = new Map(); + let id = 'id'; - var point = {}; + let point = {}; addToSiri(series, point, id); - var point2 = {}; + let point2 = {}; addToSiri(series, point2, id); expect(series.has(id)).to.be(true); @@ -40,10 +40,10 @@ describe('addToSiri', function () { }); it('allows overriding the series label', function () { - var series = new Map(); - var id = 'id'; - var label = 'label'; - var point = {}; + let series = new Map(); + let id = 'id'; + let label = 'label'; + let point = {}; addToSiri(series, point, id, label); expect(series.has(id)).to.be(true); diff --git a/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js b/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js index 2984520a285e7..fc72b119918c6 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js +++ b/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js @@ -5,8 +5,8 @@ describe('makeFakeXAspect', function () { let AggType; let AggConfig; let indexPattern; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -18,8 +18,8 @@ describe('makeFakeXAspect', function () { })); it('creates an object that looks like an aspect', function () { - var vis = new Vis(indexPattern, { type: 'histogram' }); - var aspect = makeFakeXAspect(vis); + let vis = new Vis(indexPattern, { type: 'histogram' }); + let aspect = makeFakeXAspect(vis); expect(aspect) .to.have.property('i', -1) diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js b/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js index 75f8306c17e70..ba8b5cb455221 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js +++ b/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js @@ -1,8 +1,8 @@ describe('getAspects', function () { - var _ = require('lodash'); - var moment = require('moment'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let moment = require('moment'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Vis; let Table; @@ -22,7 +22,7 @@ describe('getAspects', function () { let vis; let table; - var date = _.memoize(function (n) { + let date = _.memoize(function (n) { return moment().startOf('day').add(n, 'hour').valueOf(); }); @@ -45,7 +45,7 @@ describe('getAspects', function () { function init(group, x, y) { // map args to indicies that should be removed - var filter = filterByIndex([ + let filter = filterByIndex([ x > 0, x > 1, group > 0, @@ -87,7 +87,7 @@ describe('getAspects', function () { ].map(filter) }; - var aggs = vis.aggs.splice(0, vis.aggs.length); + let aggs = vis.aggs.splice(0, vis.aggs.length); filter(aggs).forEach(function (filter) { vis.aggs.push(filter); }); @@ -96,7 +96,7 @@ describe('getAspects', function () { it('produces an aspect object for each of the aspect types found in the columns', function () { init(1, 1, 1); - var aspects = getAspects(vis, table); + let aspects = getAspects(vis, table); validate(aspects.x, 0); validate(aspects.series, 1); validate(aspects.y, 2); @@ -105,7 +105,7 @@ describe('getAspects', function () { it('uses arrays only when there are more than one aspect of a specific type', function () { init(0, 1, 2); - var aspects = getAspects(vis, table); + let aspects = getAspects(vis, table); validate(aspects.x, 0); expect(aspects.series == null).to.be(true); @@ -134,7 +134,7 @@ describe('getAspects', function () { it('creates a fake x aspect if the column does not exist', function () { init(0, 0, 1); - var aspects = getAspects(vis, table); + let aspects = getAspects(vis, table); expect(aspects.x) .to.be.an('object') diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_point.js b/src/ui/public/agg_response/point_series/__tests__/_get_point.js index 1614b788f0fb7..3c144b13b3b87 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_get_point.js +++ b/src/ui/public/agg_response/point_series/__tests__/_get_point.js @@ -1,13 +1,13 @@ describe('getPoint', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let getPoint; - var truthFormatted = { fieldFormatter: _.constant(_.constant(true)) }; - var identFormatted = { fieldFormatter: _.constant(_.identity) }; + let truthFormatted = { fieldFormatter: _.constant(_.constant(true)) }; + let identFormatted = { fieldFormatter: _.constant(_.identity) }; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -28,9 +28,9 @@ describe('getPoint', function () { }); it('properly unwraps and scales values', function () { - var row = [ { value: 1 }, { value: 2 }, { value: 3 } ]; - var zAspect = { i: 2 }; - var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect, zAspect); + let row = [ { value: 1 }, { value: 2 }, { value: 3 } ]; + let zAspect = { i: 2 }; + let point = getPoint(xAspect, seriesAspect, yScale, row, yAspect, zAspect); expect(point) .to.have.property('x', 1) @@ -41,8 +41,8 @@ describe('getPoint', function () { }); it('ignores points with a y value of NaN', function () { - var row = [ { value: 1 }, { value: 'NaN' }]; - var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); + let row = [ { value: 1 }, { value: 'NaN' }]; + let point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point).to.be(void 0); }); }); @@ -61,8 +61,8 @@ describe('getPoint', function () { }); it('properly unwraps and scales values', function () { - var seriesAspect = { i: 1, agg: identFormatted }; - var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); + let seriesAspect = { i: 1, agg: identFormatted }; + let point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point) .to.have.property('x', 1) @@ -72,8 +72,8 @@ describe('getPoint', function () { }); it('properly formats series values', function () { - var seriesAspect = { i: 1, agg: truthFormatted }; - var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); + let seriesAspect = { i: 1, agg: truthFormatted }; + let point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point) .to.have.property('x', 1) @@ -83,8 +83,8 @@ describe('getPoint', function () { }); it ('adds the aggConfig to the points', function () { - var seriesAspect = { i: 1, agg: truthFormatted}; - var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); + let seriesAspect = { i: 1, agg: truthFormatted}; + let point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point).to.have.property('aggConfig', truthFormatted); }); diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_series.js b/src/ui/public/agg_response/point_series/__tests__/_get_series.js index 3c0b67f713309..96aedbc5b126c 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_get_series.js +++ b/src/ui/public/agg_response/point_series/__tests__/_get_series.js @@ -1,10 +1,10 @@ describe('getSeries', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let getSeries; - var agg = { fieldFormatter: _.constant(_.identity) }; + let agg = { fieldFormatter: _.constant(_.identity) }; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -18,7 +18,7 @@ describe('getSeries', function () { } it('produces a single series with points for each row', function () { - var rows = [ + let rows = [ [1, 2, 3], [1, 2, 3], [1, 2, 3], @@ -26,7 +26,7 @@ describe('getSeries', function () { [1, 2, 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: 0 }, y: { i: 1 }, @@ -34,13 +34,13 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') .and.to.have.length(1); - var siri = series[0]; + let siri = series[0]; expect(siri) .to.be.an('object') .and.have.property('label', '') @@ -59,7 +59,7 @@ describe('getSeries', function () { }); it('produces multiple series if there are multiple y aspects', function () { - var rows = [ + let rows = [ [1, 2, 3], [1, 2, 3], [1, 2, 3], @@ -67,7 +67,7 @@ describe('getSeries', function () { [1, 2, 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: 0 }, y: [ @@ -77,7 +77,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -102,7 +102,7 @@ describe('getSeries', function () { }); it('produces multiple series if there is a series aspect', function () { - var rows = [ + let rows = [ ['0', 3], ['1', 3], ['1', 'NaN'], @@ -113,7 +113,7 @@ describe('getSeries', function () { ['1', 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -121,7 +121,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -146,7 +146,7 @@ describe('getSeries', function () { }); it('produces multiple series if there is a series aspect and multipl y aspects', function () { - var rows = [ + let rows = [ ['0', 3, 4], ['1', 3, 4], ['0', 3, 4], @@ -155,7 +155,7 @@ describe('getSeries', function () { ['1', 3, 4] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -166,7 +166,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -196,7 +196,7 @@ describe('getSeries', function () { }); it('produces a series list in the same order as its corresponding metric column', function () { - var rows = [ + let rows = [ ['0', 3, 4], ['1', 3, 4], ['0', 3, 4], @@ -205,7 +205,7 @@ describe('getSeries', function () { ['1', 3, 4] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -216,7 +216,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series[0]).to.have.property('label', '0: 0'); expect(series[1]).to.have.property('label', '0: 1'); expect(series[2]).to.have.property('label', '1: 0'); @@ -229,7 +229,7 @@ describe('getSeries', function () { y.i = i; }); - var series2 = getSeries(rows, chart); + let series2 = getSeries(rows, chart); expect(series2[0]).to.have.property('label', '0: 1'); expect(series2[1]).to.have.property('label', '0: 0'); expect(series2[2]).to.have.property('label', '1: 1'); diff --git a/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js b/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js index cd33603d49387..a6d35ca0d9a64 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js +++ b/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js @@ -1,7 +1,7 @@ describe('initXAxis', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let initXAxis; @@ -10,7 +10,7 @@ describe('initXAxis', function () { initXAxis = Private(require('ui/agg_response/point_series/_init_x_axis')); })); - var baseChart = { + let baseChart = { aspects: { x: { agg: { @@ -26,7 +26,7 @@ describe('initXAxis', function () { }; it('sets the xAxisFormatter if the agg is not ordered', function () { - var chart = _.cloneDeep(baseChart); + let chart = _.cloneDeep(baseChart); initXAxis(chart); expect(chart) .to.have.property('xAxisLabel', 'label') @@ -34,7 +34,7 @@ describe('initXAxis', function () { }); it('makes the chart ordered if the agg is ordered', function () { - var chart = _.cloneDeep(baseChart); + let chart = _.cloneDeep(baseChart); chart.aspects.x.agg.type.ordered = true; initXAxis(chart); @@ -49,7 +49,7 @@ describe('initXAxis', function () { }); it('reads the interval param from the x agg', function () { - var chart = _.cloneDeep(baseChart); + let chart = _.cloneDeep(baseChart); chart.aspects.x.agg.type.ordered = true; chart.aspects.x.agg.write = _.constant({ params: { interval: 10 } }); diff --git a/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js b/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js index dacfd5e02dbb9..1d9f541e7efe1 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js +++ b/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js @@ -1,7 +1,7 @@ describe('initYAxis', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let initYAxis; @@ -18,7 +18,7 @@ describe('initYAxis', function () { }; } - var baseChart = { + let baseChart = { aspects: { y: [ { agg: agg(), col: { title: 'y1' } }, @@ -32,17 +32,17 @@ describe('initYAxis', function () { }; describe('with a single y aspect', function () { - var singleYBaseChart = _.cloneDeep(baseChart); + let singleYBaseChart = _.cloneDeep(baseChart); singleYBaseChart.aspects.y = singleYBaseChart.aspects.y[0]; it('sets the yAxisFormatter the the field formats convert fn', function () { - var chart = _.cloneDeep(singleYBaseChart); + let chart = _.cloneDeep(singleYBaseChart); initYAxis(chart); expect(chart).to.have.property('yAxisFormatter', chart.aspects.y.agg.fieldFormatter()); }); it('sets the yAxisLabel', function () { - var chart = _.cloneDeep(singleYBaseChart); + let chart = _.cloneDeep(singleYBaseChart); initYAxis(chart); expect(chart).to.have.property('yAxisLabel', 'y1'); }); @@ -50,7 +50,7 @@ describe('initYAxis', function () { describe('with mutliple y aspects', function () { it('sets the yAxisFormatter the the field formats convert fn for the first y aspect', function () { - var chart = _.cloneDeep(baseChart); + let chart = _.cloneDeep(baseChart); initYAxis(chart); expect(chart).to.have.property('yAxisFormatter'); @@ -60,7 +60,7 @@ describe('initYAxis', function () { }); it('does not set the yAxisLabel, it does not make sense to put multiple labels on the same axis', function () { - var chart = _.cloneDeep(baseChart); + let chart = _.cloneDeep(baseChart); initYAxis(chart); expect(chart).to.have.property('yAxisLabel', ''); }); diff --git a/src/ui/public/agg_response/point_series/__tests__/_main.js b/src/ui/public/agg_response/point_series/__tests__/_main.js index 8433116a91357..fd5dbee165cee 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_main.js +++ b/src/ui/public/agg_response/point_series/__tests__/_main.js @@ -1,11 +1,11 @@ describe('pointSeriesChartDataFromTable', function () { this.slow(1000); - var _ = require('lodash'); - var moment = require('moment'); - var AggConfigResult = require('ui/Vis/AggConfigResult'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let moment = require('moment'); + let AggConfigResult = require('ui/Vis/AggConfigResult'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let pointSeriesChartDataFromTable; let indexPattern; @@ -21,20 +21,20 @@ describe('pointSeriesChartDataFromTable', function () { })); it('handles a table with just a count', function () { - var vis = new Vis(indexPattern, { type: 'histogram' }); - var agg = vis.aggs[0]; - var result = new AggConfigResult(vis.aggs[0], void 0, 100, 100); + let vis = new Vis(indexPattern, { type: 'histogram' }); + let agg = vis.aggs[0]; + let result = new AggConfigResult(vis.aggs[0], void 0, 100, 100); - var table = new Table(); + let table = new Table(); table.columns = [ { aggConfig: agg } ]; table.rows.push([ result ]); - var chartData = pointSeriesChartDataFromTable(vis, table); + let chartData = pointSeriesChartDataFromTable(vis, table); expect(chartData).to.be.an('object'); expect(chartData.series).to.be.an('array'); expect(chartData.series).to.have.length(1); - var series = chartData.series[0]; + let series = chartData.series[0]; expect(series.values).to.have.length(1); expect(series.values[0]) .to.have.property('x', '_all') @@ -43,7 +43,7 @@ describe('pointSeriesChartDataFromTable', function () { }); it('handles a table with x and y column', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'count', schema: 'metric' }, @@ -51,32 +51,32 @@ describe('pointSeriesChartDataFromTable', function () { ] }); - var y = { + let y = { agg: vis.aggs[0], col: { aggConfig: vis.aggs[0] }, at: function (i) { return 100 * i; } }; - var x = { + let x = { agg: vis.aggs[1], col: { aggConfig: vis.aggs[1] }, at: function (i) { return moment().startOf('day').add(i, 'day').valueOf(); } }; - var rowCount = 3; - var table = new Table(); + let rowCount = 3; + let table = new Table(); table.columns = [ x.col, y.col ]; _.times(rowCount, function (i) { - var date = new AggConfigResult(x.agg, void 0, x.at(i)); + let date = new AggConfigResult(x.agg, void 0, x.at(i)); table.rows.push([date, new AggConfigResult(y.agg, date, y.at(i))]); }); - var chartData = pointSeriesChartDataFromTable(vis, table); + let chartData = pointSeriesChartDataFromTable(vis, table); expect(chartData).to.be.an('object'); expect(chartData.series).to.be.an('array'); expect(chartData.series).to.have.length(1); - var series = chartData.series[0]; + let series = chartData.series[0]; expect(series.values).to.have.length(rowCount); series.values.forEach(function (point, i) { expect(point) @@ -96,7 +96,7 @@ describe('pointSeriesChartDataFromTable', function () { }); it('handles a table with an x and two y aspects', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -105,40 +105,40 @@ describe('pointSeriesChartDataFromTable', function () { ] }); - var avg = { + let avg = { agg: vis.aggs[0], col: { title: 'average', aggConfig: vis.aggs[0] }, at: function (i) { return 75.444 * (i + 1); } }; - var date = { + let date = { agg: vis.aggs[1], col: { title: 'date', aggConfig: vis.aggs[1] }, at: function (i) { return moment().startOf('day').add(i, 'day').valueOf(); } }; - var max = { + let max = { agg: vis.aggs[2], col: { title: 'maximum', aggConfig: vis.aggs[2] }, at: function (i) { return 100 * (i + 1); } }; - var rowCount = 3; - var table = new Table(); + let rowCount = 3; + let table = new Table(); table.columns = [ date.col, avg.col, max.col ]; _.times(rowCount, function (i) { - var dateResult = new AggConfigResult(date.agg, void 0, date.at(i)); - var avgResult = new AggConfigResult(avg.agg, dateResult, avg.at(i)); - var maxResult = new AggConfigResult(max.agg, dateResult, max.at(i)); + let dateResult = new AggConfigResult(date.agg, void 0, date.at(i)); + let avgResult = new AggConfigResult(avg.agg, dateResult, avg.at(i)); + let maxResult = new AggConfigResult(max.agg, dateResult, max.at(i)); table.rows.push([dateResult, avgResult, maxResult]); }); - var chartData = pointSeriesChartDataFromTable(vis, table); + let chartData = pointSeriesChartDataFromTable(vis, table); expect(chartData).to.be.an('object'); expect(chartData.series).to.be.an('array'); expect(chartData.series).to.have.length(2); chartData.series.forEach(function (siri, i) { - var metric = i === 0 ? avg : max; + let metric = i === 0 ? avg : max; expect(siri).to.have.property('label', metric.col.label); expect(siri.values).to.have.length(rowCount); @@ -166,7 +166,7 @@ describe('pointSeriesChartDataFromTable', function () { }); it('handles a table with an x, a series, and two y aspects', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'group', params: { field: 'extension' } }, @@ -176,53 +176,53 @@ describe('pointSeriesChartDataFromTable', function () { ] }); - var extensions = ['php', 'jpg', 'gif', 'css']; - var term = { + let extensions = ['php', 'jpg', 'gif', 'css']; + let term = { agg: vis.aggs[0], col: { title: 'extensions', aggConfig: vis.aggs[0] }, at: function (i) { return extensions[i % extensions.length]; } }; - var avg = { + let avg = { agg: vis.aggs[1], col: { title: 'average', aggConfig: vis.aggs[1] }, at: function (i) { return 75.444 * (i + 1); } }; - var date = { + let date = { agg: vis.aggs[2], col: { title: 'date', aggConfig: vis.aggs[2] }, at: function (i) { return moment().startOf('day').add(i, 'day').valueOf(); } }; - var max = { + let max = { agg: vis.aggs[3], col: { title: 'maximum', aggConfig: vis.aggs[3] }, at: function (i) { return 100 * (i + 1); } }; - var metricCount = 2; - var rowsPerSegment = 2; - var rowCount = extensions.length * rowsPerSegment; - var table = new Table(); + let metricCount = 2; + let rowsPerSegment = 2; + let rowCount = extensions.length * rowsPerSegment; + let table = new Table(); table.columns = [ date.col, term.col, avg.col, max.col ]; _.times(rowCount, function (i) { - var dateResult = new AggConfigResult(date.agg, void 0, date.at(i)); - var termResult = new AggConfigResult(term.agg, dateResult, term.at(i)); - var avgResult = new AggConfigResult(avg.agg, termResult, avg.at(i)); - var maxResult = new AggConfigResult(max.agg, termResult, max.at(i)); + let dateResult = new AggConfigResult(date.agg, void 0, date.at(i)); + let termResult = new AggConfigResult(term.agg, dateResult, term.at(i)); + let avgResult = new AggConfigResult(avg.agg, termResult, avg.at(i)); + let maxResult = new AggConfigResult(max.agg, termResult, max.at(i)); table.rows.push([dateResult, termResult, avgResult, maxResult]); }); - var chartData = pointSeriesChartDataFromTable(vis, table); + let chartData = pointSeriesChartDataFromTable(vis, table); expect(chartData).to.be.an('object'); expect(chartData.series).to.be.an('array'); // one series for each extension, and then one for each metric inside expect(chartData.series).to.have.length(extensions.length * metricCount); chartData.series.forEach(function (siri, i) { // figure out the metric used to create this series - var metricAgg = siri.values[0].aggConfigResult.aggConfig; - var metric = avg.agg === metricAgg ? avg : max; + let metricAgg = siri.values[0].aggConfigResult.aggConfig; + let metric = avg.agg === metricAgg ? avg : max; expect(siri.values).to.have.length(rowsPerSegment); siri.values.forEach(function (point) { diff --git a/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js b/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js index 17d576ed0589f..490e25f241c54 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js +++ b/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js @@ -1,11 +1,11 @@ describe('orderedDateAxis', function () { - var moment = require('moment'); - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let moment = require('moment'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); - var baseArgs = { + let baseArgs = { vis: { indexPattern: { timeFieldName: '@timestamp' @@ -36,7 +36,7 @@ describe('orderedDateAxis', function () { describe('xAxisFormatter', function () { it('sets the xAxisFormatter', function () { - var args = _.cloneDeep(baseArgs); + let args = _.cloneDeep(baseArgs); orderedDateAxis(args.vis, args.chart); expect(args.chart).to.have.property('xAxisFormatter'); @@ -44,10 +44,10 @@ describe('orderedDateAxis', function () { }); it('formats values using moment, and returns strings', function () { - var args = _.cloneDeep(baseArgs); + let args = _.cloneDeep(baseArgs); orderedDateAxis(args.vis, args.chart); - var val = '2014-08-06T12:34:01'; + let val = '2014-08-06T12:34:01'; expect(args.chart.xAxisFormatter(val)) .to.be(moment(val).format('hh:mm:ss')); }); @@ -55,7 +55,7 @@ describe('orderedDateAxis', function () { describe('ordered object', function () { it('sets date: true', function () { - var args = _.cloneDeep(baseArgs); + let args = _.cloneDeep(baseArgs); orderedDateAxis(args.vis, args.chart); expect(args.chart) @@ -66,21 +66,21 @@ describe('orderedDateAxis', function () { }); it('relies on agg.buckets for the interval', function () { - var args = _.cloneDeep(baseArgs); - var spy = sinon.spy(args.chart.aspects.x.agg.buckets, 'getInterval'); + let args = _.cloneDeep(baseArgs); + let spy = sinon.spy(args.chart.aspects.x.agg.buckets, 'getInterval'); orderedDateAxis(args.vis, args.chart); expect(spy).to.have.property('callCount', 1); }); it('sets the min/max when the buckets are bounded', function () { - var args = _.cloneDeep(baseArgs); + let args = _.cloneDeep(baseArgs); orderedDateAxis(args.vis, args.chart); expect(moment.isMoment(args.chart.ordered.min)).to.be(true); expect(moment.isMoment(args.chart.ordered.max)).to.be(true); }); it('does not set the min/max when the buckets are unbounded', function () { - var args = _.cloneDeep(baseArgs); + let args = _.cloneDeep(baseArgs); args.chart.aspects.x.agg.buckets.getBounds = _.constant(); orderedDateAxis(args.vis, args.chart); expect(args.chart.ordered).to.not.have.property('min'); diff --git a/src/ui/public/agg_response/point_series/__tests__/_tooltip_formatter.js b/src/ui/public/agg_response/point_series/__tests__/_tooltip_formatter.js index a3cbc69009301..9a77e2b9ab95a 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_tooltip_formatter.js +++ b/src/ui/public/agg_response/point_series/__tests__/_tooltip_formatter.js @@ -1,8 +1,8 @@ describe('tooltipFormatter', function () { - var _ = require('lodash'); - var $ = require('jquery'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let $ = require('jquery'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let tooltipFormatter; @@ -22,7 +22,7 @@ describe('tooltipFormatter', function () { return $row.eq(i).text().trim(); } - var baseEvent = { + let baseEvent = { datum: { aggConfigResult: { aggConfig: agg('inner'), @@ -41,20 +41,20 @@ describe('tooltipFormatter', function () { }; it('returns html based on the mouse event', function () { - var event = _.cloneDeep(baseEvent); - var $el = $(tooltipFormatter(event)); - var $rows = $el.find('tr'); + let event = _.cloneDeep(baseEvent); + let $el = $(tooltipFormatter(event)); + let $rows = $el.find('tr'); expect($rows.size()).to.be(3); - var $row1 = $rows.eq(0).find('td'); + let $row1 = $rows.eq(0).find('td'); expect(cell($row1, 0)).to.be('inner'); expect(cell($row1, 1)).to.be('(3)'); - var $row2 = $rows.eq(1).find('td'); + let $row2 = $rows.eq(1).find('td'); expect(cell($row2, 0)).to.be('middle'); expect(cell($row2, 1)).to.be('(2)'); - var $row3 = $rows.eq(2).find('td'); + let $row3 = $rows.eq(2).find('td'); expect(cell($row3, 0)).to.be('top'); expect(cell($row3, 1)).to.be('(1)'); }); diff --git a/src/ui/public/agg_response/tabify/__tests__/_buckets.js b/src/ui/public/agg_response/tabify/__tests__/_buckets.js index 78899f26c3bcc..a6901d891adce 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_buckets.js +++ b/src/ui/public/agg_response/tabify/__tests__/_buckets.js @@ -1,7 +1,7 @@ describe('Buckets wrapper', function () { let Buckets; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { @@ -11,13 +11,13 @@ describe('Buckets wrapper', function () { function test(aggResp, count, keys) { it('reads the length', function () { - var buckets = new Buckets(aggResp); + let buckets = new Buckets(aggResp); expect(buckets).to.have.length(count); }); it('itterates properly, passing in the key', function () { - var buckets = new Buckets(aggResp); - var keysSent = []; + let buckets = new Buckets(aggResp); + let keysSent = []; buckets.forEach(function (bucket, key) { keysSent.push(key); }); @@ -28,7 +28,7 @@ describe('Buckets wrapper', function () { } describe('with object style buckets', function () { - var aggResp = { + let aggResp = { buckets: { '0-100': {}, '100-200': {}, @@ -36,14 +36,14 @@ describe('Buckets wrapper', function () { } }; - var count = 3; - var keys = ['0-100', '100-200', '200-300']; + let count = 3; + let keys = ['0-100', '100-200', '200-300']; test(aggResp, count, keys); }); describe('with array style buckets', function () { - var aggResp = { + let aggResp = { buckets: [ { key: '0-100', value: {} }, { key: '100-200', value: {} }, @@ -51,8 +51,8 @@ describe('Buckets wrapper', function () { ] }; - var count = 3; - var keys = ['0-100', '100-200', '200-300']; + let count = 3; + let keys = ['0-100', '100-200', '200-300']; test(aggResp, count, keys); }); diff --git a/src/ui/public/agg_response/tabify/__tests__/_get_columns.js b/src/ui/public/agg_response/tabify/__tests__/_get_columns.js index 36138c2fb7c96..fdd7c078670dc 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_get_columns.js +++ b/src/ui/public/agg_response/tabify/__tests__/_get_columns.js @@ -2,8 +2,8 @@ describe('get columns', function () { let getColumns; let Vis; let indexPattern; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { @@ -13,11 +13,11 @@ describe('get columns', function () { })); it('should inject a count metric if no aggs exist', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie' }); while (vis.aggs.length) vis.aggs.pop(); - var columns = getColumns(vis); + let columns = getColumns(vis); expect(columns).to.have.length(1); expect(columns[0]).to.have.property('aggConfig'); @@ -25,14 +25,14 @@ describe('get columns', function () { }); it('should inject a count metric if only buckets exist', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } } ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); expect(columns).to.have.length(2); expect(columns[1]).to.have.property('aggConfig'); @@ -40,7 +40,7 @@ describe('get columns', function () { }); it('should inject the metric after each bucket if the vis is hierarchical', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, @@ -50,7 +50,7 @@ describe('get columns', function () { ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); expect(columns).to.have.length(8); columns.forEach(function (column, i) { @@ -60,7 +60,7 @@ describe('get columns', function () { }); it('should inject the multiple metrics after each bucket if the vis is hierarchical', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, @@ -72,7 +72,7 @@ describe('get columns', function () { ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); function checkColumns(column, i) { expect(column).to.have.property('aggConfig'); @@ -90,14 +90,14 @@ describe('get columns', function () { } expect(columns).to.have.length(12); - for (var i = 0; i < columns.length; i += 3) { - var counts = { buckets: 0, metrics: 0 }; + for (let i = 0; i < columns.length; i += 3) { + let counts = { buckets: 0, metrics: 0 }; columns.slice(i, i + 3).forEach(checkColumns); } }); it('should put all metrics at the end of the columns if the vis is not hierarchical', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, @@ -109,7 +109,7 @@ describe('get columns', function () { ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); expect(columns).to.have.length(6); // sum should be last diff --git a/src/ui/public/agg_response/tabify/__tests__/_integration.js b/src/ui/public/agg_response/tabify/__tests__/_integration.js index 23ae2e98d8495..321924347d2af 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_integration.js +++ b/src/ui/public/agg_response/tabify/__tests__/_integration.js @@ -1,8 +1,8 @@ describe('tabifyAggResponse Integration', function () { - var _ = require('lodash'); - var fixtures = require('fixtures/fake_hierarchical_data'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let fixtures = require('fixtures/fake_hierarchical_data'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Vis; let Buckets; @@ -23,13 +23,13 @@ describe('tabifyAggResponse Integration', function () { } it('transforms a simple response properly', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); normalizeIds(vis); - var resp = tabifyAggResponse(vis, fixtures.metricOnly, { canSplit: false }); + let resp = tabifyAggResponse(vis, fixtures.metricOnly, { canSplit: false }); expect(resp).to.not.have.property('tables'); expect(resp).to.have.property('rows').and.property('columns'); @@ -78,7 +78,7 @@ describe('tabifyAggResponse Integration', function () { function expectRootGroup(rootTableGroup, expectInnerTables) { expect(rootTableGroup).to.have.property('tables'); - var tables = rootTableGroup.tables; + let tables = rootTableGroup.tables; expect(tables).to.be.an('array').and.have.length(3); expectExtensionSplit(tables[0], 'png', expectInnerTables); expectExtensionSplit(tables[1], 'css', expectInnerTables); @@ -152,7 +152,7 @@ describe('tabifyAggResponse Integration', function () { // only complete rows, and only put the metrics at the end. vis.isHierarchical = _.constant(false); - var tabbed = tabifyAggResponse(vis, esResp); + let tabbed = tabifyAggResponse(vis, esResp); expectRootGroup(tabbed, function expectTable(table, splitKey) { expectColumns(table, [src, os, avg]); @@ -178,7 +178,7 @@ describe('tabifyAggResponse Integration', function () { // the existing bucket and it's metric vis.isHierarchical = _.constant(true); - var tabbed = tabifyAggResponse(vis, esResp, { + let tabbed = tabifyAggResponse(vis, esResp, { partialRows: true }); @@ -212,7 +212,7 @@ describe('tabifyAggResponse Integration', function () { // the end vis.isHierarchical = _.constant(true); - var tabbed = tabifyAggResponse(vis, esResp, { + let tabbed = tabifyAggResponse(vis, esResp, { partialRows: true, minimalColumns: true }); @@ -244,7 +244,7 @@ describe('tabifyAggResponse Integration', function () { // create metric columns after each bucket vis.isHierarchical = _.constant(false); - var tabbed = tabifyAggResponse(vis, esResp, { + let tabbed = tabifyAggResponse(vis, esResp, { minimalColumns: false }); diff --git a/src/ui/public/agg_response/tabify/__tests__/_response_writer.js b/src/ui/public/agg_response/tabify/__tests__/_response_writer.js index ccc63dfd35442..7bfd0aa9bfafa 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_response_writer.js +++ b/src/ui/public/agg_response/tabify/__tests__/_response_writer.js @@ -1,8 +1,8 @@ describe('ResponseWriter class', function () { - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Vis; let Table; @@ -36,15 +36,15 @@ describe('ResponseWriter class', function () { defineSetup(true); it('gets the columns for the vis', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis); expect(getColumns).to.have.property('callCount', 1); expect(getColumns.firstCall.args[0]).to.be(vis); }); it('collects the aggConfigs from each column in aggStack', function () { - var aggs = [ + let aggs = [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } }, { type: 'terms', schema: 'segment', params: { field: 'extension' } }, { type: 'avg', schema: 'metric', params: { field: '@timestamp' } } @@ -54,12 +54,12 @@ describe('ResponseWriter class', function () { return { aggConfig: agg }; })); - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: aggs }); - var writer = new ResponseWriter(vis); + let writer = new ResponseWriter(vis); expect(writer.aggStack).to.be.an('array'); expect(writer.aggStack).to.have.length(aggs.length); writer.aggStack.forEach(function (agg, i) { @@ -68,40 +68,40 @@ describe('ResponseWriter class', function () { }); it('sets canSplit=true by default', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis); expect(writer).to.have.property('canSplit', true); }); it('sets canSplit=false when config says to', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis, { canSplit: false }); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis, { canSplit: false }); expect(writer).to.have.property('canSplit', false); }); describe('sets partialRows', function () { it('to the value of the config if set', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var partial = Boolean(Math.round(Math.random())); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let partial = Boolean(Math.round(Math.random())); - var writer = new ResponseWriter(vis, { partialRows: partial }); + let writer = new ResponseWriter(vis, { partialRows: partial }); expect(writer).to.have.property('partialRows', partial); }); it('to the value of vis.isHierarchical if no config', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var hierarchical = Boolean(Math.round(Math.random())); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let hierarchical = Boolean(Math.round(Math.random())); sinon.stub(vis, 'isHierarchical').returns(hierarchical); - var writer = new ResponseWriter(vis, {}); + let writer = new ResponseWriter(vis, {}); expect(writer).to.have.property('partialRows', hierarchical); }); }); it('starts off with a root TableGroup', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let writer = new ResponseWriter(vis); expect(writer.root).to.be.a(TableGroup); expect(writer.splitStack).to.be.an('array'); expect(writer.splitStack).to.have.length(1); @@ -114,29 +114,29 @@ describe('ResponseWriter class', function () { describe('#response()', function () { it('returns the root TableGroup if splitting', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis); expect(writer.response()).to.be(writer.root); }); it('returns the first table if not splitting', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis, { canSplit: false }); - var table = writer._table(); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis, { canSplit: false }); + let table = writer._table(); expect(writer.response()).to.be(table); }); it('adds columns to all of the tables', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', params: { field: '_type' }, schema: 'split' }, { type: 'count', schema: 'metric' } ] }); - var buckets = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); - var writer = new ResponseWriter(vis); - var tables = []; + let buckets = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); + let writer = new ResponseWriter(vis); + let tables = []; writer.split(vis.aggs[0], buckets, function () { writer.cell(vis.aggs[1], 100, function () { @@ -148,11 +148,11 @@ describe('ResponseWriter class', function () { expect(table.columns == null).to.be(true); }); - var resp = writer.response(); + let resp = writer.response(); expect(resp).to.be.a(TableGroup); expect(resp.tables).to.have.length(2); - var nginx = resp.tables.shift(); + let nginx = resp.tables.shift(); expect(nginx).to.have.property('aggConfig', vis.aggs[0]); expect(nginx).to.have.property('key', 'nginx'); expect(nginx.tables).to.have.length(1); @@ -160,7 +160,7 @@ describe('ResponseWriter class', function () { expect(_.contains(tables, table)).to.be(true); }); - var apache = resp.tables.shift(); + let apache = resp.tables.shift(); expect(apache).to.have.property('aggConfig', vis.aggs[0]); expect(apache).to.have.property('key', 'apache'); expect(apache.tables).to.have.length(1); @@ -178,16 +178,16 @@ describe('ResponseWriter class', function () { describe('#split()', function () { it('with break if the user has specified that splitting is to be disabled', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'split', params: { field: '_type' } }, { type: 'count', schema: 'metric' } ] }); - var agg = vis.aggs.bySchemaName.split[0]; - var buckets = new Buckets({ buckets: [ { key: 'apache' } ]}); - var writer = new ResponseWriter(vis, { canSplit: false }); + let agg = vis.aggs.bySchemaName.split[0]; + let buckets = new Buckets({ buckets: [ { key: 'apache' } ]}); + let writer = new ResponseWriter(vis, { canSplit: false }); expect(function () { writer.split(agg, buckets, _.noop); @@ -195,7 +195,7 @@ describe('ResponseWriter class', function () { }); it('forks the acrStack and rewrites the parents', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', params: { field: 'extension' }, schema: 'segment' }, @@ -205,10 +205,10 @@ describe('ResponseWriter class', function () { ] }); - var writer = new ResponseWriter(vis, { asAggConfigResults: true }); - var extensions = new Buckets({ buckets: [ { key: 'jpg' }, { key: 'png' } ] }); - var types = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); - var os = new Buckets({ buckets: [ { key: 'window' }, { key: 'osx' } ] }); + let writer = new ResponseWriter(vis, { asAggConfigResults: true }); + let extensions = new Buckets({ buckets: [ { key: 'jpg' }, { key: 'png' } ] }); + let types = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); + let os = new Buckets({ buckets: [ { key: 'window' }, { key: 'osx' } ] }); extensions.forEach(function (b, extension) { writer.cell(vis.aggs[0], extension, function () { @@ -224,11 +224,11 @@ describe('ResponseWriter class', function () { }); }); - var tables = _.flattenDeep(_.pluck(writer.response().tables, 'tables')); + let tables = _.flattenDeep(_.pluck(writer.response().tables, 'tables')); expect(tables.length).to.be(types.length); // collect the far left acr from each table - var leftAcrs = _.pluck(tables, 'rows[0][0]'); + let leftAcrs = _.pluck(tables, 'rows[0][0]'); leftAcrs.forEach(function (acr, i, acrs) { expect(acr.aggConfig).to.be(vis.aggs[0]); @@ -237,7 +237,7 @@ describe('ResponseWriter class', function () { // for all but the last acr, compare to the next if (i + 1 >= acrs.length) return; - var acr2 = leftAcrs[i + 1]; + let acr2 = leftAcrs[i + 1]; expect(acr.key).to.be(acr2.key); expect(acr.value).to.be(acr2.value); @@ -252,8 +252,8 @@ describe('ResponseWriter class', function () { describe('#cell()', function () { it('logs a cell in the ResponseWriters row buffer, calls the block arg, then removes the value from the buffer', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis); expect(writer.rowBuffer).to.have.length(0); writer.cell({}, 500, function () { @@ -266,10 +266,10 @@ describe('ResponseWriter class', function () { describe('#row()', function () { it('writes the ResponseWriters internal rowBuffer into a table', function () { - var vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var writer = new ResponseWriter(vis); + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); + let writer = new ResponseWriter(vis); - var table = writer._table(); + let table = writer._table(); writer.cell({}, 1, function () { writer.cell({}, 2, function () { writer.cell({}, 3, function () { @@ -283,7 +283,7 @@ describe('ResponseWriter class', function () { }); it('always writes to the table group at the top of the split stack', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'split', params: { field: '_type' } }, @@ -292,20 +292,20 @@ describe('ResponseWriter class', function () { { type: 'count', schema: 'metric' } ] }); - var splits = vis.aggs.bySchemaName.split; + let splits = vis.aggs.bySchemaName.split; - var type = splits[0]; - var typeBuckets = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); + let type = splits[0]; + let typeBuckets = new Buckets({ buckets: [ { key: 'nginx' }, { key: 'apache' } ] }); - var ext = splits[1]; - var extBuckets = new Buckets({ buckets: [ { key: 'jpg' }, { key: 'png' } ] }); + let ext = splits[1]; + let extBuckets = new Buckets({ buckets: [ { key: 'jpg' }, { key: 'png' } ] }); - var os = splits[2]; - var osBuckets = new Buckets({ buckets: [ { key: 'windows' }, { key: 'mac' } ] }); + let os = splits[2]; + let osBuckets = new Buckets({ buckets: [ { key: 'windows' }, { key: 'mac' } ] }); - var count = vis.aggs[3]; + let count = vis.aggs[3]; - var writer = new ResponseWriter(vis); + let writer = new ResponseWriter(vis); writer.split(type, typeBuckets, function () { writer.split(ext, extBuckets, function () { writer.split(os, osBuckets, function (bucket, key) { @@ -316,9 +316,9 @@ describe('ResponseWriter class', function () { }); }); - var resp = writer.response(); - var sum = 0; - var tables = 0; + let resp = writer.response(); + let sum = 0; + let tables = 0; (function recurse(t) { if (t.tables) { // table group @@ -341,7 +341,7 @@ describe('ResponseWriter class', function () { }); it('writes partial rows for hierarchical vis', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'terms', schema: 'segment', params: { field: '_type' }}, @@ -349,8 +349,8 @@ describe('ResponseWriter class', function () { ] }); - var writer = new ResponseWriter(vis); - var table = writer._table(); + let writer = new ResponseWriter(vis); + let table = writer._table(); writer.cell(vis.aggs[0], 'apache', function () { writer.row(); }); @@ -360,7 +360,7 @@ describe('ResponseWriter class', function () { }); it('skips partial rows for non-hierarchical vis', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: '_type' }}, @@ -368,8 +368,8 @@ describe('ResponseWriter class', function () { ] }); - var writer = new ResponseWriter(vis); - var table = writer._table(); + let writer = new ResponseWriter(vis); + let table = writer._table(); writer.cell(vis.aggs[0], 'apache', function () { writer.row(); }); diff --git a/src/ui/public/agg_response/tabify/__tests__/_table.js b/src/ui/public/agg_response/tabify/__tests__/_table.js index 953d3412a4be0..ed5d3c972881c 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_table.js +++ b/src/ui/public/agg_response/tabify/__tests__/_table.js @@ -1,7 +1,7 @@ describe('Table class', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Table; @@ -11,16 +11,16 @@ describe('Table class', function () { })); it('exposes rows array, but not the columns', function () { - var table = new Table(); + let table = new Table(); expect(table.rows).to.be.an('array'); expect(table.columns == null).to.be.ok(); }); describe('#aggConfig', function () { it('accepts a column from the table and returns its agg config', function () { - var table = new Table(); - var football = {}; - var column = { + let table = new Table(); + let football = {}; + let column = { aggConfig: football }; @@ -29,7 +29,7 @@ describe('Table class', function () { it('throws a TypeError if the column is malformed', function () { expect(function () { - var notAColumn = {}; + let notAColumn = {}; (new Table()).aggConfig(notAColumn); }).to.throwException(TypeError); }); @@ -37,12 +37,12 @@ describe('Table class', function () { describe('#title', function () { it('returns nothing if the table is not part of a table group', function () { - var table = new Table(); + let table = new Table(); expect(table.title()).to.be(''); }); it('returns the title of the TableGroup if the table is part of one', function () { - var table = new Table(); + let table = new Table(); table.$parent = { title: 'TableGroup Title', tables: [table] @@ -54,9 +54,9 @@ describe('Table class', function () { describe('#field', function () { it('calls the columns aggConfig#field() method', function () { - var table = new Table(); - var football = {}; - var column = { + let table = new Table(); + let football = {}; + let column = { aggConfig: { field: _.constant(football) } @@ -68,9 +68,9 @@ describe('Table class', function () { describe('#fieldFormatter', function () { it('calls the columns aggConfig#fieldFormatter() method', function () { - var table = new Table(); - var football = {}; - var column = { + let table = new Table(); + let football = {}; + let column = { aggConfig: { fieldFormatter: _.constant(football) } diff --git a/src/ui/public/agg_response/tabify/__tests__/_table_group.js b/src/ui/public/agg_response/tabify/__tests__/_table_group.js index 29be6627b7a40..b3e020d4d9b85 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_table_group.js +++ b/src/ui/public/agg_response/tabify/__tests__/_table_group.js @@ -1,7 +1,7 @@ describe('Table Group class', function () { let TableGroup; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { @@ -9,7 +9,7 @@ describe('Table Group class', function () { })); it('exposes tables array and empty aggConfig, key and title', function () { - var tableGroup = new TableGroup(); + let tableGroup = new TableGroup(); expect(tableGroup.tables).to.be.an('array'); expect(tableGroup.aggConfig).to.be(null); expect(tableGroup.key).to.be(null); diff --git a/src/ui/public/agg_table/__tests__/_group.js b/src/ui/public/agg_table/__tests__/_group.js index 0cef2c5be64cb..c0b236ade0bb9 100644 --- a/src/ui/public/agg_table/__tests__/_group.js +++ b/src/ui/public/agg_table/__tests__/_group.js @@ -1,9 +1,9 @@ describe('AggTableGroup Directive', function () { - var _ = require('lodash'); - var $ = require('jquery'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var fixtures = require('fixtures/fake_hierarchical_data'); + let _ = require('lodash'); + let $ = require('jquery'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let fixtures = require('fixtures/fake_hierarchical_data'); let $rootScope; let $compile; @@ -31,9 +31,9 @@ describe('AggTableGroup Directive', function () { it('renders a simple split response properly', function () { - var vis = new Vis(indexPattern, 'table'); + let vis = new Vis(indexPattern, 'table'); $scope.group = tabifyAggResponse(vis, fixtures.metricOnly); - var $el = $(''); + let $el = $(''); $compile($el)($scope); $scope.$digest(); @@ -43,7 +43,7 @@ describe('AggTableGroup Directive', function () { }); it('renders nothing if the table list is empty', function () { - var $el = $(''); + let $el = $(''); $scope.group = { tables: [] @@ -52,12 +52,12 @@ describe('AggTableGroup Directive', function () { $compile($el)($scope); $scope.$digest(); - var $subTables = $el.find('kbn-agg-table'); + let $subTables = $el.find('kbn-agg-table'); expect($subTables.size()).to.be(0); }); it('renders a complex response properly', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -70,15 +70,15 @@ describe('AggTableGroup Directive', function () { agg.id = 'agg_' + (i + 1); }); - var group = $scope.group = tabifyAggResponse(vis, fixtures.threeTermBuckets); - var $el = $(''); + let group = $scope.group = tabifyAggResponse(vis, fixtures.threeTermBuckets); + let $el = $(''); $compile($el)($scope); $scope.$digest(); - var $subTables = $el.find('kbn-agg-table'); + let $subTables = $el.find('kbn-agg-table'); expect($subTables.size()).to.be(3); - var $subTableHeaders = $el.find('.agg-table-group-header'); + let $subTableHeaders = $el.find('.agg-table-group-header'); expect($subTableHeaders.size()).to.be(3); $subTableHeaders.each(function (i) { diff --git a/src/ui/public/agg_table/__tests__/_table.js b/src/ui/public/agg_table/__tests__/_table.js index 583b6fff30c78..57e43382bc29c 100644 --- a/src/ui/public/agg_table/__tests__/_table.js +++ b/src/ui/public/agg_table/__tests__/_table.js @@ -1,10 +1,10 @@ describe('AggTable Directive', function () { - var _ = require('lodash'); - var $ = require('jquery'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var fixtures = require('fixtures/fake_hierarchical_data'); - var sinon = require('auto-release-sinon'); + let _ = require('lodash'); + let $ = require('jquery'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let fixtures = require('fixtures/fake_hierarchical_data'); + let sinon = require('auto-release-sinon'); let $rootScope; let $compile; @@ -32,10 +32,10 @@ describe('AggTable Directive', function () { it('renders a simple response properly', function () { - var vis = new Vis(indexPattern, 'table'); + let vis = new Vis(indexPattern, 'table'); $scope.table = tabifyAggResponse(vis, fixtures.metricOnly, { canSplit: false }); - var $el = $compile('')($scope); + let $el = $compile('')($scope); $scope.$digest(); expect($el.find('tbody').size()).to.be(1); @@ -45,14 +45,14 @@ describe('AggTable Directive', function () { it('renders nothing if the table is empty', function () { $scope.table = null; - var $el = $compile('')($scope); + let $el = $compile('')($scope); $scope.$digest(); expect($el.find('tbody').size()).to.be(0); }); it('renders a complex response properly', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -66,27 +66,27 @@ describe('AggTable Directive', function () { }); $scope.table = tabifyAggResponse(vis, fixtures.threeTermBuckets, { canSplit: false }); - var $el = $(''); + let $el = $(''); $compile($el)($scope); $scope.$digest(); expect($el.find('tbody').size()).to.be(1); - var $rows = $el.find('tbody tr'); + let $rows = $el.find('tbody tr'); expect($rows.size()).to.be.greaterThan(0); function validBytes(str) { expect(str).to.match(/^\d+$/); - var bytesAsNum = _.parseInt(str); + let bytesAsNum = _.parseInt(str); expect(bytesAsNum === 0 || bytesAsNum > 1000).to.be.ok(); } $rows.each(function (i) { // 6 cells in every row - var $cells = $(this).find('td'); + let $cells = $(this).find('td'); expect($cells.size()).to.be(6); - var txts = $cells.map(function () { + let txts = $cells.map(function () { return $(this).text().trim(); }); @@ -106,11 +106,11 @@ describe('AggTable Directive', function () { describe('aggTable.toCsv()', function () { it('escapes and formats the rows and columns properly', function () { - var $el = $compile('')($scope); + let $el = $compile('')($scope); $scope.$digest(); - var $tableScope = $el.isolateScope(); - var aggTable = $tableScope.aggTable; + let $tableScope = $el.isolateScope(); + let aggTable = $tableScope.aggTable; $tableScope.table = { columns: [ @@ -147,13 +147,13 @@ describe('AggTable Directive', function () { }); it('calls _saveAs properly', function () { - var $el = $compile('')($scope); + let $el = $compile('')($scope); $scope.$digest(); - var $tableScope = $el.isolateScope(); - var aggTable = $tableScope.aggTable; + let $tableScope = $el.isolateScope(); + let aggTable = $tableScope.aggTable; - var saveAs = sinon.stub(aggTable, '_saveAs'); + let saveAs = sinon.stub(aggTable, '_saveAs'); $tableScope.table = { columns: [ { title: 'one' }, @@ -169,7 +169,7 @@ describe('AggTable Directive', function () { aggTable.exportAsCsv(); expect(saveAs.callCount).to.be(1); - var call = saveAs.getCall(0); + let call = saveAs.getCall(0); expect(call.args[0]).to.be.a(FakeBlob); expect(call.args[0].slices).to.eql([ 'one,two,"with double-quotes("")"' + '\r\n' + @@ -182,12 +182,12 @@ describe('AggTable Directive', function () { }); it('should use the export-title attribute', function () { - var expected = 'export file name'; - var $el = $compile(``)($scope); + let expected = 'export file name'; + let $el = $compile(``)($scope); $scope.$digest(); - var $tableScope = $el.isolateScope(); - var aggTable = $tableScope.aggTable; + let $tableScope = $el.isolateScope(); + let aggTable = $tableScope.aggTable; $tableScope.table = { columns: [], rows: [] diff --git a/src/ui/public/agg_types/__tests__/AggParamWriter.js b/src/ui/public/agg_types/__tests__/AggParamWriter.js index b37ff90795d57..1810e535584c5 100644 --- a/src/ui/public/agg_types/__tests__/AggParamWriter.js +++ b/src/ui/public/agg_types/__tests__/AggParamWriter.js @@ -1,9 +1,9 @@ module.exports = function AggParamWriterHelper(Private) { - var _ = require('lodash'); - var Vis = Private(require('ui/Vis')); - var aggTypes = Private(require('ui/agg_types/index')); - var visTypes = Private(require('ui/registry/vis_types')); - var stubbedLogstashIndexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); + let _ = require('lodash'); + let Vis = Private(require('ui/Vis')); + let aggTypes = Private(require('ui/agg_types/index')); + let visTypes = Private(require('ui/registry/vis_types')); + let stubbedLogstashIndexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); /** * Helper object for writing aggParams. Specify an aggType and it will find a vis & schema, and @@ -13,8 +13,8 @@ module.exports = function AggParamWriterHelper(Private) { * - Verify that the interval parameter of the histogram visualization casts its input to a number * ```js * it('casts to a number', function () { - * var writer = new AggParamWriter({ aggType: 'histogram' }); - * var output = writer.write({ interval : '100/10' }); + * let writer = new AggParamWriter({ aggType: 'histogram' }); + * let output = writer.write({ interval : '100/10' }); * expect(output.params.interval).to.be.a('number'); * expect(output.params.interval).to.be(100); * }); @@ -25,7 +25,7 @@ module.exports = function AggParamWriterHelper(Private) { * @param {string} opts.aggType - the name of the aggType we want to test. ('histogram', 'filter', etc.) */ function AggParamWriter(opts) { - var self = this; + let self = this; self.aggType = opts.aggType; if (_.isString(self.aggType)) { @@ -43,7 +43,7 @@ module.exports = function AggParamWriterHelper(Private) { // find a suitable vis type and schema _.find(visTypes, function (visType) { - var schema = _.find(visType.schemas.all, function (schema) { + let schema = _.find(visType.schemas.all, function (schema) { // type, type, type, type, type... :( return schema.group === self.aggType.type; }); @@ -65,7 +65,7 @@ module.exports = function AggParamWriterHelper(Private) { } AggParamWriter.prototype.write = function (paramValues) { - var self = this; + let self = this; paramValues = _.clone(paramValues); if (self.aggType.params.byName.field && !paramValues.field) { @@ -86,7 +86,7 @@ module.exports = function AggParamWriterHelper(Private) { }] }); - var aggConfig = _.find(self.vis.aggs, function (aggConfig) { + let aggConfig = _.find(self.vis.aggs, function (aggConfig) { return aggConfig.type === self.aggType; }); diff --git a/src/ui/public/agg_types/__tests__/AggParams.js b/src/ui/public/agg_types/__tests__/AggParams.js index d1e7e7bf286ec..9f3f8e077bb89 100644 --- a/src/ui/public/agg_types/__tests__/AggParams.js +++ b/src/ui/public/agg_types/__tests__/AggParams.js @@ -1,7 +1,7 @@ describe('AggParams class', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let AggParams; let BaseAggParam; @@ -23,11 +23,11 @@ describe('AggParams class', function () { describe('constructor args', function () { it('accepts an array of param defs', function () { - var params = [ + let params = [ { name: 'one' }, { name: 'two' } ]; - var aggParams = new AggParams(params); + let aggParams = new AggParams(params); expect(aggParams).to.have.length(params.length); expect(aggParams).to.be.an(Array); @@ -37,43 +37,43 @@ describe('AggParams class', function () { describe('AggParam creation', function () { it('Uses the FieldAggParam class for params with the name "field"', function () { - var params = [ + let params = [ { name: 'field' } ]; - var aggParams = new AggParams(params); + let aggParams = new AggParams(params); expect(aggParams).to.have.length(params.length); expect(aggParams[0]).to.be.a(FieldAggParam); }); it('Uses the OptionedAggParam class for params of type "optioned"', function () { - var params = [ + let params = [ { name: 'interval', type: 'optioned' } ]; - var aggParams = new AggParams(params); + let aggParams = new AggParams(params); expect(aggParams).to.have.length(params.length); expect(aggParams[0]).to.be.a(OptionedAggParam); }); it('Uses the RegexAggParam class for params of type "regex"', function () { - var params = [ + let params = [ { name: 'exclude', type: 'regex' } ]; - var aggParams = new AggParams(params); + let aggParams = new AggParams(params); expect(aggParams).to.have.length(params.length); expect(aggParams[0]).to.be.a(RegexAggParam); }); it('Always converts the params to a BaseAggParam', function () { - var params = [ + let params = [ { name: 'height', editor: 'high' @@ -87,7 +87,7 @@ describe('AggParams class', function () { editor: 'small' } ]; - var aggParams = new AggParams(params); + let aggParams = new AggParams(params); expect(BaseAggParam).to.have.property('callCount', params.length); expect(FieldAggParam).to.have.property('callCount', 0); diff --git a/src/ui/public/agg_types/__tests__/AggType.js b/src/ui/public/agg_types/__tests__/AggType.js index 5d3fc211475cb..21ba2db39114b 100644 --- a/src/ui/public/agg_types/__tests__/AggType.js +++ b/src/ui/public/agg_types/__tests__/AggType.js @@ -1,8 +1,8 @@ describe('AggType Class', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); - var sinon = require('auto-release-sinon'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); + let sinon = require('auto-release-sinon'); let AggType; let AggParams; let AggConfig; @@ -14,7 +14,7 @@ describe('AggType Class', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var AggParamsPM = require('ui/agg_types/AggParams'); + let AggParamsPM = require('ui/agg_types/AggParams'); AggParams = sinon.spy(Private(AggParamsPM)); Private.stub(AggParamsPM, AggParams); @@ -34,7 +34,7 @@ describe('AggType Class', function () { }); describe('application of config properties', function () { - var copiedConfigProps = [ + let copiedConfigProps = [ 'name', 'title', 'makeLabel', @@ -43,11 +43,11 @@ describe('AggType Class', function () { describe('"' + copiedConfigProps.join('", "') + '"', function () { it('assigns the config value to itself', function () { - var config = _.transform(copiedConfigProps, function (config, prop) { + let config = _.transform(copiedConfigProps, function (config, prop) { config[prop] = {}; }, {}); - var aggType = new AggType(config); + let aggType = new AggType(config); copiedConfigProps.forEach(function (prop) { expect(aggType[prop]).to.be(config[prop]); @@ -57,9 +57,9 @@ describe('AggType Class', function () { describe('makeLabel', function () { it('makes a function when the makeLabel config is not specified', function () { - var someGetter = function () {}; + let someGetter = function () {}; - var aggType = new AggType({ + let aggType = new AggType({ makeLabel: someGetter }); @@ -76,9 +76,9 @@ describe('AggType Class', function () { describe('getFormat', function () { it('returns the formatter for the aggConfig', function () { - var aggType = new AggType({}); + let aggType = new AggType({}); - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -88,7 +88,7 @@ describe('AggType Class', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; expect(aggType.getFormat(aggConfig)).to.be(fieldFormat.getDefaultInstance('date')); @@ -107,9 +107,9 @@ describe('AggType Class', function () { }); it('can be overridden via config', function () { - var someGetter = function () {}; + let someGetter = function () {}; - var aggType = new AggType({ + let aggType = new AggType({ getFormat: someGetter }); @@ -123,7 +123,7 @@ describe('AggType Class', function () { }); it('defaults to AggParams object with JSON param', function () { - var aggType = new AggType({ + let aggType = new AggType({ name: 'smart agg' }); @@ -134,7 +134,7 @@ describe('AggType Class', function () { }); it('can disable customLabel', function () { - var aggType = new AggType({ + let aggType = new AggType({ name: 'smart agg', customLabels: false }); @@ -144,13 +144,13 @@ describe('AggType Class', function () { }); it('passes the params arg directly to the AggParams constructor', function () { - var params = [ + let params = [ {name: 'one'}, {name: 'two'} ]; - var paramLength = params.length + 2; // json and custom label are always appended + let paramLength = params.length + 2; // json and custom label are always appended - var aggType = new AggType({ + let aggType = new AggType({ name: 'bucketeer', params: params }); @@ -164,8 +164,8 @@ describe('AggType Class', function () { describe('getResponseAggs', function () { it('copies the value', function () { - var football = {}; - var aggType = new AggType({ + let football = {}; + let aggType = new AggType({ getResponseAggs: football }); @@ -173,7 +173,7 @@ describe('AggType Class', function () { }); it('defaults to _.noop', function () { - var aggType = new AggType({}); + let aggType = new AggType({}); expect(aggType.getResponseAggs).to.be(_.noop); }); diff --git a/src/ui/public/agg_types/__tests__/bucketCountBetween.js b/src/ui/public/agg_types/__tests__/bucketCountBetween.js index 46db7ec09ed6b..73fb0d5d31837 100644 --- a/src/ui/public/agg_types/__tests__/bucketCountBetween.js +++ b/src/ui/public/agg_types/__tests__/bucketCountBetween.js @@ -1,7 +1,7 @@ describe('bucketCountBetween util', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let indexPattern; let Vis; let visTypes; @@ -26,7 +26,7 @@ describe('bucketCountBetween util', function () { })); it('returns a positive number when a is before b', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -40,14 +40,14 @@ describe('bucketCountBetween util', function () { ] }); - var a = vis.aggs.byTypeName.date_histogram[0]; - var b = vis.aggs.byTypeName.terms[0]; - var count = bucketCountBetween(a, b); + let a = vis.aggs.byTypeName.date_histogram[0]; + let b = vis.aggs.byTypeName.terms[0]; + let count = bucketCountBetween(a, b); expect(isNegative(count)).to.be(false); }); it('returns a negative number when a is after b', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -61,14 +61,14 @@ describe('bucketCountBetween util', function () { ] }); - var a = vis.aggs.byTypeName.terms[0]; - var b = vis.aggs.byTypeName.date_histogram[0]; - var count = bucketCountBetween(a, b); + let a = vis.aggs.byTypeName.terms[0]; + let b = vis.aggs.byTypeName.date_histogram[0]; + let count = bucketCountBetween(a, b); expect(isNegative(count)).to.be(true); }); it('returns 0 when there are no buckets between a and b', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -82,13 +82,13 @@ describe('bucketCountBetween util', function () { ] }); - var a = vis.aggs.byTypeName.date_histogram[0]; - var b = vis.aggs.byTypeName.terms[0]; + let a = vis.aggs.byTypeName.date_histogram[0]; + let b = vis.aggs.byTypeName.terms[0]; expect(bucketCountBetween(a, b)).to.be(0); }); it('returns null when b is not in the aggs', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -98,8 +98,8 @@ describe('bucketCountBetween util', function () { ] }); - var a = vis.aggs.byTypeName.date_histogram[0]; - var b = new AggConfig(vis, { + let a = vis.aggs.byTypeName.date_histogram[0]; + let b = new AggConfig(vis, { type: 'terms', schema: 'segment' }); @@ -108,7 +108,7 @@ describe('bucketCountBetween util', function () { }); it('returns null when a is not in the aggs', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -118,27 +118,27 @@ describe('bucketCountBetween util', function () { ] }); - var a = new AggConfig(vis, { + let a = new AggConfig(vis, { type: 'terms', schema: 'segment' }); - var b = vis.aggs.byTypeName.date_histogram[0]; + let b = vis.aggs.byTypeName.date_histogram[0]; expect(bucketCountBetween(a, b)).to.be(null); }); it('returns null when a and b are not in the aggs', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var a = new AggConfig(vis, { + let a = new AggConfig(vis, { type: 'terms', schema: 'segment' }); - var b = new AggConfig(vis, { + let b = new AggConfig(vis, { type: 'date_histogram', schema: 'segment' }); @@ -148,14 +148,14 @@ describe('bucketCountBetween util', function () { function countTest(pre, post) { return function () { - var schemas = visTypes.byName.histogram.schemas.buckets; + let schemas = visTypes.byName.histogram.schemas.buckets; // slow for this test is actually somewhere around 1/2 a sec this.slow(500); function randBucketAggForVis(vis) { - var schema = _.sample(schemas); - var aggType = _.sample(aggTypes.byType.buckets); + let schema = _.sample(schemas); + let aggType = _.sample(aggTypes.byType.buckets); return new AggConfig(vis, { schema: schema, @@ -164,20 +164,20 @@ describe('bucketCountBetween util', function () { } _.times(50, function (n) { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [] }); - var randBucketAgg = _.partial(randBucketAggForVis, vis); + let randBucketAgg = _.partial(randBucketAggForVis, vis); - var a = randBucketAgg(); - var b = randBucketAgg(); + let a = randBucketAgg(); + let b = randBucketAgg(); // create n aggs between a and b - var aggs = []; + let aggs = []; aggs.fill = function (n) { - for (var i = 0; i < n; i++) { + for (let i = 0; i < n; i++) { aggs.push(randBucketAgg()); } }; diff --git a/src/ui/public/agg_types/__tests__/buckets/_histogram.js b/src/ui/public/agg_types/__tests__/buckets/_histogram.js index f303515aee164..7fabfadf54b0d 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/_histogram.js @@ -1,7 +1,7 @@ describe('Histogram Agg', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); describe('ordered', function () { let histogram; @@ -26,7 +26,7 @@ describe('Histogram Agg', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var AggParamWriter = Private(require('../AggParamWriter')); + let AggParamWriter = Private(require('../AggParamWriter')); paramWriter = new AggParamWriter({ aggType: 'histogram' }); })); @@ -34,25 +34,25 @@ describe('Histogram Agg', function () { // reads aggConfig.params.interval, writes to dsl.interval it('accepts a number', function () { - var output = paramWriter.write({ interval: 100 }); + let output = paramWriter.write({ interval: 100 }); expect(output.params).to.have.property('interval', 100); }); it('accepts a string', function () { - var output = paramWriter.write({ interval: '10' }); + let output = paramWriter.write({ interval: '10' }); expect(output.params).to.have.property('interval', 10); }); it('fails on non-numeric values', function () { // template validation prevents this from users, not devs - var output = paramWriter.write({ interval: [] }); + let output = paramWriter.write({ interval: [] }); expect(isNaN(output.params.interval)).to.be.ok(); }); }); describe('min_doc_count', function () { it('casts true values to 0', function () { - var output = paramWriter.write({ min_doc_count: true }); + let output = paramWriter.write({ min_doc_count: true }); expect(output.params).to.have.property('min_doc_count', 0); output = paramWriter.write({ min_doc_count: 'yes' }); @@ -66,7 +66,7 @@ describe('Histogram Agg', function () { }); it('writes nothing for false values', function () { - var output = paramWriter.write({ min_doc_count: '' }); + let output = paramWriter.write({ min_doc_count: '' }); expect(output.params).to.not.have.property('min_doc_count'); output = paramWriter.write({ min_doc_count: null }); @@ -79,7 +79,7 @@ describe('Histogram Agg', function () { describe('extended_bounds', function () { it('writes when only eb.min is set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ extended_bounds: { min: 0 } }); expect(output.params.extended_bounds).to.have.property('min', 0); @@ -87,7 +87,7 @@ describe('Histogram Agg', function () { }); it('writes when only eb.max is set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ extended_bounds: { max: 0 } }); expect(output.params.extended_bounds).to.have.property('min', undefined); @@ -95,7 +95,7 @@ describe('Histogram Agg', function () { }); it('writes when both eb.min and eb.max are set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ extended_bounds: { min: 99, max: 100 } }); expect(output.params.extended_bounds).to.have.property('min', 99); @@ -103,7 +103,7 @@ describe('Histogram Agg', function () { }); it('does not write when nothing is set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ extended_bounds: {} }); expect(output.params).to.not.have.property('extended_bounds'); diff --git a/src/ui/public/agg_types/__tests__/buckets/_range.js b/src/ui/public/agg_types/__tests__/buckets/_range.js index 95ff74caeb8cc..7f82d99183738 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_range.js +++ b/src/ui/public/agg_types/__tests__/buckets/_range.js @@ -1,11 +1,11 @@ describe('Range Agg', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var values = require('lodash').values; + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let values = require('lodash').values; - var resp = require('fixtures/agg_resp/range'); - var buckets = values(resp.aggregations[1].buckets); + let resp = require('fixtures/agg_resp/range'); + let buckets = values(resp.aggregations[1].buckets); let range; let Vis; @@ -17,7 +17,7 @@ describe('Range Agg', function () { Vis = Private(require('ui/Vis')); indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); - var BytesFormat = Private(require('ui/registry/field_formats')).byId.bytes; + let BytesFormat = Private(require('ui/registry/field_formats')).byId.bytes; indexPattern.fieldFormatMap.bytes = new BytesFormat({ pattern: '0,0.[000] b' @@ -28,7 +28,7 @@ describe('Range Agg', function () { describe('formating', function () { it('formats bucket keys properly', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -45,8 +45,8 @@ describe('Range Agg', function () { ] }); - var agg = vis.aggs.byTypeName.range[0]; - var format = function (val) { + let agg = vis.aggs.byTypeName.range[0]; + let format = function (val) { return agg.fieldFormatter()(agg.getKey(val)); }; expect(format(buckets[0])).to.be('-∞ to 1 KB'); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js index 236575d3659d0..cc8fa36e2daa8 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_histogram.js @@ -1,11 +1,11 @@ describe('AggConfig Filters', function () { describe('date_histogram', function () { - var _ = require('lodash'); - var moment = require('moment'); - var sinon = require('auto-release-sinon'); - var aggResp = require('fixtures/agg_resp/date_histogram'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let _ = require('lodash'); + let moment = require('moment'); + let sinon = require('auto-release-sinon'); + let aggResp = require('fixtures/agg_resp/date_histogram'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let vis; let agg; @@ -20,10 +20,10 @@ describe('AggConfig Filters', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - var Vis = Private(require('ui/Vis')); - var indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); - var createFilter = Private(require('ui/agg_types/buckets/create_filter/date_histogram')); - var TimeBuckets = Private(require('ui/time_buckets')); + let Vis = Private(require('ui/Vis')); + let indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); + let createFilter = Private(require('ui/agg_types/buckets/create_filter/date_histogram')); + let TimeBuckets = Private(require('ui/time_buckets')); intervalOptions = Private(require('ui/agg_types/buckets/_interval_options')); init = function (interval, duration) { @@ -46,7 +46,7 @@ describe('AggConfig Filters', function () { bucketKey = _.sample(aggResp.aggregations['1'].buckets).key; bucketStart = moment(bucketKey); - var timePad = moment.duration(duration / 2); + let timePad = moment.duration(duration / 2); agg.buckets.setBounds({ min: bucketStart.clone().subtract(timePad), max: bucketStart.clone().add(timePad), @@ -63,7 +63,7 @@ describe('AggConfig Filters', function () { expect(filter).to.have.property('range'); expect(filter.range).to.have.property(field.name); - var fieldParams = filter.range[field.name]; + let fieldParams = filter.range[field.name]; expect(fieldParams).to.have.property('gte'); expect(fieldParams.gte).to.be.a('number'); @@ -90,8 +90,8 @@ describe('AggConfig Filters', function () { init(option.val, duration); - var interval = agg.buckets.getInterval(); - var params = filter.range[field.name]; + let interval = agg.buckets.getInterval(); + let params = filter.range[field.name]; expect(params.gte).to.be(+bucketStart); expect(params.lte).to.be(+bucketStart.clone().add(interval).subtract(1, 'ms')); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_range.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_range.js index 909be6cdae409..09d357bd6ce28 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/date_range.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/date_range.js @@ -1,7 +1,7 @@ -var moment = require('moment'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let moment = require('moment'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('AggConfig Filters', function () { describe('Date range', function () { @@ -19,7 +19,7 @@ describe('AggConfig Filters', function () { })); it('should return a range filter for date_range agg', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -34,8 +34,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.date_range[0]; - var filter = createFilter(aggConfig, 'February 1st, 2015 to February 7th, 2015'); + let aggConfig = vis.aggs.byTypeName.date_range[0]; + let filter = createFilter(aggConfig, 'February 1st, 2015 to February 7th, 2015'); expect(filter).to.have.property('range'); expect(filter).to.have.property('meta'); expect(filter.meta).to.have.property('index', indexPattern.id); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/filters.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/filters.js index cd11fab3c047d..19dfe044af4f0 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/filters.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/filters.js @@ -1,7 +1,7 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('AggConfig Filters', function () { describe('filters', function () { @@ -19,7 +19,7 @@ describe('AggConfig Filters', function () { })); it('should return a filters filter', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -35,8 +35,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.filters[0]; - var filter = createFilter(aggConfig, '_type:nginx'); + let aggConfig = vis.aggs.byTypeName.filters[0]; + let filter = createFilter(aggConfig, '_type:nginx'); expect(_.omit(filter, 'meta')).to.eql(aggConfig.params.filters[1].input); expect(filter.meta).to.have.property('index', indexPattern.id); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/histogram.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/histogram.js index 68441b3283148..ab4873a6e6152 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/histogram.js @@ -1,7 +1,7 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('AggConfig Filters', function () { describe('histogram', function () { @@ -19,7 +19,7 @@ describe('AggConfig Filters', function () { })); it('should return an range filter for histogram', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -30,8 +30,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.histogram[0]; - var filter = createFilter(aggConfig, 2048); + let aggConfig = vis.aggs.byTypeName.histogram[0]; + let filter = createFilter(aggConfig, 2048); expect(filter).to.have.property('meta'); expect(filter.meta).to.have.property('index', indexPattern.id); expect(filter).to.have.property('range'); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/ip_range.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/ip_range.js index fba808068c300..8f11c0406efb0 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/ip_range.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/ip_range.js @@ -1,6 +1,6 @@ describe('AggConfig Filters', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); describe('IP range', function () { let AggConfig; @@ -17,7 +17,7 @@ describe('AggConfig Filters', function () { })); it('should return a range filter for ip_range agg', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -36,8 +36,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.ip_range[0]; - var filter = createFilter(aggConfig, '0.0.0.0-1.1.1.1'); + let aggConfig = vis.aggs.byTypeName.ip_range[0]; + let filter = createFilter(aggConfig, '0.0.0.0-1.1.1.1'); expect(filter).to.have.property('range'); expect(filter).to.have.property('meta'); expect(filter.meta).to.have.property('index', indexPattern.id); @@ -47,7 +47,7 @@ describe('AggConfig Filters', function () { }); it('should return a range filter for ip_range agg using a CIDR mask', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -66,8 +66,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.ip_range[0]; - var filter = createFilter(aggConfig, '67.129.65.201/27'); + let aggConfig = vis.aggs.byTypeName.ip_range[0]; + let filter = createFilter(aggConfig, '67.129.65.201/27'); expect(filter).to.have.property('range'); expect(filter).to.have.property('meta'); expect(filter.meta).to.have.property('index', indexPattern.id); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/range.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/range.js index aafcf3f5bed3d..24da70169b1e7 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/range.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/range.js @@ -1,6 +1,6 @@ describe('AggConfig Filters', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); describe('range', function () { let AggConfig; @@ -17,7 +17,7 @@ describe('AggConfig Filters', function () { })); it('should return a range filter for range agg', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -33,8 +33,8 @@ describe('AggConfig Filters', function () { ] }); - var aggConfig = vis.aggs.byTypeName.range[0]; - var filter = createFilter(aggConfig, { gte: 1024, lt: 2048.0 }); + let aggConfig = vis.aggs.byTypeName.range[0]; + let filter = createFilter(aggConfig, { gte: 1024, lt: 2048.0 }); expect(filter).to.have.property('range'); expect(filter).to.have.property('meta'); expect(filter.meta).to.have.property('index', indexPattern.id); diff --git a/src/ui/public/agg_types/__tests__/buckets/create_filter/terms.js b/src/ui/public/agg_types/__tests__/buckets/create_filter/terms.js index 465c8ec6c0112..947d3e7942709 100644 --- a/src/ui/public/agg_types/__tests__/buckets/create_filter/terms.js +++ b/src/ui/public/agg_types/__tests__/buckets/create_filter/terms.js @@ -1,6 +1,6 @@ describe('AggConfig Filters', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); describe('terms', function () { let AggConfig; @@ -17,12 +17,12 @@ describe('AggConfig Filters', function () { })); it('should return a match filter for terms', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'terms', schema: 'segment', params: { field: '_type' } } ] }); - var aggConfig = vis.aggs.byTypeName.terms[0]; - var filter = createFilter(aggConfig, 'apache'); + let aggConfig = vis.aggs.byTypeName.terms[0]; + let filter = createFilter(aggConfig, 'apache'); expect(filter).to.have.property('query'); expect(filter.query).to.have.property('match'); expect(filter.query.match).to.have.property('_type'); diff --git a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js index a0fb283c892a8..10fe400ae093b 100644 --- a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js +++ b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js @@ -1,8 +1,8 @@ describe('editor', function () { - var _ = require('lodash'); - var $ = require('jquery'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let _ = require('lodash'); + let $ = require('jquery'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let indexPattern; let vis; @@ -14,7 +14,7 @@ describe('editor', function () { beforeEach(ngMock.inject(function (Private, $injector, $compile) { indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); - var Vis = Private(require('ui/Vis')); + let Vis = Private(require('ui/Vis')); /** * Render the AggParams editor for the date histogram aggregation @@ -35,8 +35,8 @@ describe('editor', function () { ] }); - var $el = $(''); - var $parentScope = $injector.get('$rootScope').$new(); + let $el = $(''); + let $parentScope = $injector.get('$rootScope').$new(); agg = $parentScope.agg = vis.aggs.bySchemaName.segment[0]; $parentScope.groupName = 'buckets'; @@ -45,10 +45,10 @@ describe('editor', function () { $scope = $el.scope(); $scope.$digest(); - var $inputs = $('vis-agg-param-editor', $el); + let $inputs = $('vis-agg-param-editor', $el); return _.transform($inputs.toArray(), function (inputs, e) { - var $el = $(e); - var $scope = $el.scope(); + let $el = $(e); + let $scope = $el.scope(); inputs[$scope.aggParam.name] = { $el: $el, @@ -104,7 +104,7 @@ describe('editor', function () { expect(params.interval.modelValue().val).to.be('auto'); expect(params.field.modelValue().name).to.be(indexPattern.timeFieldName); - var field = _.find(indexPattern.fields, function (f) { + let field = _.find(indexPattern.fields, function (f) { return f.type === 'date' && f.name !== indexPattern.timeFieldName; }); diff --git a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_params.js b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_params.js index 5944e119bf3b6..fd2be913b4410 100644 --- a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_params.js +++ b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_params.js @@ -1,8 +1,8 @@ describe('params', function () { - var _ = require('lodash'); - var moment = require('moment'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let moment = require('moment'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let paramWriter; let writeInterval; @@ -14,9 +14,9 @@ describe('params', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - var AggParamWriter = Private(require('../../AggParamWriter')); - var indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); - var timefilter = $injector.get('timefilter'); + let AggParamWriter = Private(require('../../AggParamWriter')); + let indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); + let timefilter = $injector.get('timefilter'); timeField = indexPattern.timeFieldName; aggTypes = Private(require('ui/agg_types/index')); @@ -27,7 +27,7 @@ describe('params', function () { return paramWriter.write({ interval: interval, field: timeField }); }; - var now = moment(); + let now = moment(); setTimeBounds = function (n, units) { timefilter.enabled = true; timefilter.getBounds = _.constant({ @@ -39,24 +39,24 @@ describe('params', function () { describe('interval', function () { it('accepts a valid interval', function () { - var output = writeInterval('d'); + let output = writeInterval('d'); expect(output.params).to.have.property('interval', '1d'); }); it('ignores invalid intervals', function () { - var output = writeInterval('foo'); + let output = writeInterval('foo'); expect(output.params).to.have.property('interval', '0ms'); }); it('automatically picks an interval', function () { setTimeBounds(15, 'm'); - var output = writeInterval('auto'); + let output = writeInterval('auto'); expect(output.params.interval).to.be('30s'); }); it('scales up the interval if it will make too many buckets', function () { setTimeBounds(30, 'm'); - var output = writeInterval('s'); + let output = writeInterval('s'); expect(output.params.interval).to.be('10s'); expect(output.metricScaleText).to.be('second'); expect(output.metricScale).to.be(0.1); @@ -64,30 +64,30 @@ describe('params', function () { it('does not scale down the interval', function () { setTimeBounds(1, 'm'); - var output = writeInterval('h'); + let output = writeInterval('h'); expect(output.params.interval).to.be('1h'); expect(output.metricScaleText).to.be(undefined); expect(output.metricScale).to.be(undefined); }); describe('only scales when all metrics are sum or count', function () { - var tests = [ + let tests = [ [ false, 'avg', 'count', 'sum' ], [ true, 'count', 'sum' ], [ false, 'count', 'cardinality' ] ]; tests.forEach(function (test) { - var should = test.shift(); - var typeNames = test.slice(); + let should = test.shift(); + let typeNames = test.slice(); it(typeNames.join(', ') + ' should ' + (should ? '' : 'not') + ' scale', function () { setTimeBounds(1, 'y'); - var vis = paramWriter.vis; + let vis = paramWriter.vis; vis.aggs.splice(0); - var histoConfig = new AggConfig(vis, { + let histoConfig = new AggConfig(vis, { type: aggTypes.byName.date_histogram, schema: 'segment', params: { interval: 's', field: timeField } @@ -102,7 +102,7 @@ describe('params', function () { })); }); - var output = histoConfig.write(); + let output = histoConfig.write(); expect(_.has(output, 'metricScale')).to.be(should); }); }); @@ -111,9 +111,9 @@ describe('params', function () { describe('extended_bounds', function () { it('should write a long value if a moment passed in', function () { - var then = moment(0); - var now = moment(500); - var output = paramWriter.write({ + let then = moment(0); + let now = moment(500); + let output = paramWriter.write({ extended_bounds: { min: then, max: now @@ -129,9 +129,9 @@ describe('params', function () { }); it('should write a long if a long is passed', function () { - var then = 0; - var now = 500; - var output = paramWriter.write({ + let then = 0; + let now = 500; + let output = paramWriter.write({ extended_bounds: { min: then, max: now diff --git a/src/ui/public/agg_types/__tests__/controls/number_list.js b/src/ui/public/agg_types/__tests__/controls/number_list.js index 3eb2d322fae17..6f069f6bcb558 100644 --- a/src/ui/public/agg_types/__tests__/controls/number_list.js +++ b/src/ui/public/agg_types/__tests__/controls/number_list.js @@ -1,9 +1,9 @@ describe('NumberList directive', function () { - var $ = require('jquery'); - var _ = require('lodash'); - var expect = require('expect.js'); - var simulateKeys = require('testUtils/simulateKeys'); - var ngMock = require('ngMock'); + let $ = require('jquery'); + let _ = require('lodash'); + let expect = require('expect.js'); + let simulateKeys = require('testUtils/simulateKeys'); + let ngMock = require('ngMock'); require('ui/number_list'); @@ -13,15 +13,15 @@ describe('NumberList directive', function () { function onlyValidValues() { return $el.find('[ng-model]').toArray().map(function (el) { - var ngModel = $(el).controller('ngModel'); + let ngModel = $(el).controller('ngModel'); return ngModel.$valid ? ngModel.$modelValue : undefined; }); } beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function ($injector) { - var $compile = $injector.get('$compile'); - var $rootScope = $injector.get('$rootScope'); + let $compile = $injector.get('$compile'); + let $rootScope = $injector.get('$rootScope'); $scope = $rootScope.$new(); $el = $(''); @@ -75,7 +75,7 @@ describe('NumberList directive', function () { it('shift-up increases by 0.1', function () { compile([4.8]); - var seq = [ + let seq = [ { type: 'press', key: 'shift', @@ -111,7 +111,7 @@ describe('NumberList directive', function () { it('shift-down decreases by 0.1', function () { compile([5.1]); - var seq = [ + let seq = [ { type: 'press', key: 'shift', @@ -135,12 +135,12 @@ describe('NumberList directive', function () { it('maintains valid number', function () { compile([9, 11, 13]); - var seq = [ + let seq = [ 'down', // 10 (11 - 1) 'down' // 10 (limited by 9) ]; - var getEl = function () { return $el.find('input').eq(1); }; + let getEl = function () { return $el.find('input').eq(1); }; return simulateKeys(getEl, seq) .then(function () { diff --git a/src/ui/public/agg_types/__tests__/index.js b/src/ui/public/agg_types/__tests__/index.js index b239079de277b..4bfa00ed47968 100644 --- a/src/ui/public/agg_types/__tests__/index.js +++ b/src/ui/public/agg_types/__tests__/index.js @@ -1,5 +1,5 @@ -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('AggTypesComponent', function () { require('./AggType'); diff --git a/src/ui/public/agg_types/__tests__/param_types/_calculate_interval.js b/src/ui/public/agg_types/__tests__/param_types/_calculate_interval.js index aa2e3c69a8e3b..1ea55f7945c17 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_calculate_interval.js +++ b/src/ui/public/agg_types/__tests__/param_types/_calculate_interval.js @@ -1,6 +1,6 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('calculateInterval()', function () { let AggConfig; @@ -17,15 +17,15 @@ describe('calculateInterval()', function () { calculateInterval = Private(require('ui/agg_types/param_types/_calculate_interval')); })); - var testInterval = function (option, expected) { - var msg = 'should return ' + JSON.stringify(expected) + ' for ' + option; + let testInterval = function (option, expected) { + let msg = 'should return ' + JSON.stringify(expected) + ' for ' + option; it(msg, function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { type: 'date_histogram', schema: 'segment', params: { field: '@timestamp', interval: option } } ] }); - var aggConfig = vis.aggs.byTypeName.date_histogram[0]; - var interval = calculateInterval(aggConfig); + let aggConfig = vis.aggs.byTypeName.date_histogram[0]; + let interval = calculateInterval(aggConfig); _.each(expected, function (val, key) { expect(interval).to.have.property(key, val); }); diff --git a/src/ui/public/agg_types/__tests__/param_types/_field.js b/src/ui/public/agg_types/__tests__/param_types/_field.js index 8e37583e8c35b..012c4d1bc68e6 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_field.js +++ b/src/ui/public/agg_types/__tests__/param_types/_field.js @@ -1,7 +1,7 @@ describe('Field', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let BaseAggParam; let FieldAggParam; @@ -15,7 +15,7 @@ describe('Field', function () { describe('constructor', function () { it('it is an instance of BaseAggParam', function () { - var aggParam = new FieldAggParam({ + let aggParam = new FieldAggParam({ name: 'field' }); diff --git a/src/ui/public/agg_types/__tests__/param_types/_optioned.js b/src/ui/public/agg_types/__tests__/param_types/_optioned.js index 0571d7440d9f5..9af596c3bf75e 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_optioned.js +++ b/src/ui/public/agg_types/__tests__/param_types/_optioned.js @@ -1,7 +1,7 @@ describe('Optioned', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let BaseAggParam; let OptionedAggParam; @@ -15,7 +15,7 @@ describe('Optioned', function () { describe('constructor', function () { it('it is an instance of BaseAggParam', function () { - var aggParam = new OptionedAggParam({ + let aggParam = new OptionedAggParam({ name: 'some_param', type: 'optioned' }); diff --git a/src/ui/public/agg_types/__tests__/param_types/_raw_json.js b/src/ui/public/agg_types/__tests__/param_types/_raw_json.js index bc8a312120c44..f4abd9d735897 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_raw_json.js +++ b/src/ui/public/agg_types/__tests__/param_types/_raw_json.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); module.exports = describe('JSON', function () { - var paramName = 'json_test'; + let paramName = 'json_test'; let BaseAggParam; let JsonAggParam; let aggParam; @@ -13,7 +13,7 @@ module.exports = describe('JSON', function () { function initAggParam(config) { config = config || {}; - var defaults = { + let defaults = { name: paramName, type: 'json' }; @@ -57,7 +57,7 @@ module.exports = describe('JSON', function () { }); it('should append param when valid JSON', function () { - var jsonData = JSON.stringify({ + let jsonData = JSON.stringify({ new_param: 'should exist in output' }); @@ -73,7 +73,7 @@ module.exports = describe('JSON', function () { }); it('should not overwrite existing params', function () { - var jsonData = JSON.stringify({ + let jsonData = JSON.stringify({ new_param: 'should exist in output', existing: 'should be used' }); @@ -86,7 +86,7 @@ module.exports = describe('JSON', function () { }); it('should drop nulled params', function () { - var jsonData = JSON.stringify({ + let jsonData = JSON.stringify({ new_param: 'should exist in output', field: null }); diff --git a/src/ui/public/agg_types/__tests__/param_types/_regex.js b/src/ui/public/agg_types/__tests__/param_types/_regex.js index 188e0331c2245..f0fda0a6479fc 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_regex.js +++ b/src/ui/public/agg_types/__tests__/param_types/_regex.js @@ -1,7 +1,7 @@ describe('Regex', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let BaseAggParam; let RegexAggParam; @@ -19,7 +19,7 @@ describe('Regex', function () { describe('constructor', function () { it('should be an instance of BaseAggParam', function () { - var aggParam = new RegexAggParam({ + let aggParam = new RegexAggParam({ name: 'some_param', type: 'regex' }); @@ -32,11 +32,11 @@ describe('Regex', function () { describe('write results', function () { let aggParam; let aggConfig; - var output = { params: {} }; - var paramName = 'exclude'; + let output = { params: {} }; + let paramName = 'exclude'; beforeEach(function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'terms', schema: 'split', params: { field: 'extension' }}, diff --git a/src/ui/public/agg_types/__tests__/param_types/_string.js b/src/ui/public/agg_types/__tests__/param_types/_string.js index 14c236dcfa0fd..af538d5abe002 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_string.js +++ b/src/ui/public/agg_types/__tests__/param_types/_string.js @@ -1,9 +1,9 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); module.exports = describe('String', function () { - var paramName = 'json_test'; + let paramName = 'json_test'; let BaseAggParam; let StringAggParam; let aggParam; @@ -12,7 +12,7 @@ module.exports = describe('String', function () { function initAggParam(config) { config = config || {}; - var defaults = { + let defaults = { name: paramName, type: 'string' }; @@ -40,8 +40,8 @@ module.exports = describe('String', function () { describe('write', function () { it('should append param by name', function () { - var paramName = 'testing'; - var params = {}; + let paramName = 'testing'; + let params = {}; params[paramName] = 'some input'; initAggParam({ name: paramName }); @@ -53,8 +53,8 @@ module.exports = describe('String', function () { }); it('should not be in output with empty input', function () { - var paramName = 'more_testing'; - var params = {}; + let paramName = 'more_testing'; + let params = {}; params[paramName] = ''; initAggParam({ name: paramName }); diff --git a/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js b/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js index 7848556f10aef..348ee66c7d4a9 100644 --- a/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js +++ b/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js @@ -1,8 +1,8 @@ -var _ = require('lodash'); -var sinon = require('auto-release-sinon'); +let _ = require('lodash'); +let sinon = require('auto-release-sinon'); function ParamClassStub(parent, body) { - var stub = sinon.spy(body || function () { + let stub = sinon.spy(body || function () { stub.Super && stub.Super.call(this); }); if (parent) _.class(stub).inherits(parent); @@ -14,7 +14,7 @@ function ParamClassStub(parent, body) { * This method should be passed directly to ngMock.inject(); * * ```js - * var stubParamClasses = require('./utils/_stub_agg_params'); + * let stubParamClasses = require('./utils/_stub_agg_params'); * describe('something', function () { * beforeEach(ngMock.inject(stubParamClasses)); * }) @@ -24,7 +24,7 @@ function ParamClassStub(parent, body) { * @return {undefined} */ module.exports = function stubParamClasses(Private) { - var BaseAggParam = Private.stub( + let BaseAggParam = Private.stub( require('ui/agg_types/param_types/base'), new ParamClassStub(null, function (config) { _.assign(this, config); diff --git a/src/ui/public/bind/__tests__/bind.js b/src/ui/public/bind/__tests__/bind.js index 7e4b0ef76dd5e..da3f49636dcdd 100644 --- a/src/ui/public/bind/__tests__/bind.js +++ b/src/ui/public/bind/__tests__/bind.js @@ -1,7 +1,7 @@ describe('$scope.$bind', function () { - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let $rootScope; let $scope; @@ -16,7 +16,7 @@ describe('$scope.$bind', function () { expect($rootScope.$bind).to.be.a('function'); expect($scope).to.have.property('$bind', $rootScope.$bind); - var $isoScope = $scope.$new(true); + let $isoScope = $scope.$new(true); expect($isoScope).to.have.property('$bind', $rootScope.$bind); }); @@ -33,7 +33,7 @@ describe('$scope.$bind', function () { }); it('sets up a binding from the child to the parent scope', function () { - var stub = sinon.stub(); + let stub = sinon.stub(); $rootScope.val = 'foo'; $scope.$bind('localVal', 'val'); @@ -47,8 +47,8 @@ describe('$scope.$bind', function () { }); it('pulls from the scopes $parent by default', function () { - var $parent = $rootScope.$new(); - var $self = $parent.$new(); + let $parent = $rootScope.$new(); + let $self = $parent.$new(); $parent.val = 'foo'; $self.val = 'bar'; @@ -58,8 +58,8 @@ describe('$scope.$bind', function () { }); it('accepts an alternate scope to read from', function () { - var $parent = $rootScope.$new(); - var $self = $parent.$new(); + let $parent = $rootScope.$new(); + let $self = $parent.$new(); $parent.val = 'foo'; $self.val = 'bar'; diff --git a/src/ui/public/chrome/__tests__/nav_controls.js b/src/ui/public/chrome/__tests__/nav_controls.js index b4d61a813b969..f9a513b81ccb5 100644 --- a/src/ui/public/chrome/__tests__/nav_controls.js +++ b/src/ui/public/chrome/__tests__/nav_controls.js @@ -36,7 +36,7 @@ describe('chrome nav controls', function () { }; }); - var $el = compile(); + let $el = compile(); expect($el.find('#testTemplateEl')).to.have.length(1); }); @@ -63,7 +63,7 @@ describe('chrome nav controls', function () { }; }); - var $el = compile(); + let $el = compile(); expect( $el.find('.testControl') .toArray() diff --git a/src/ui/public/chrome/directives/app_switcher/__tests__/app_switcher.js b/src/ui/public/chrome/directives/app_switcher/__tests__/app_switcher.js index 91063d48b20d0..68c7d53bd3ef6 100644 --- a/src/ui/public/chrome/directives/app_switcher/__tests__/app_switcher.js +++ b/src/ui/public/chrome/directives/app_switcher/__tests__/app_switcher.js @@ -1,15 +1,15 @@ -var sinon = require('auto-release-sinon'); -var ngMock = require('ngMock'); -var $ = require('jquery'); -var expect = require('expect.js'); -var constant = require('lodash').constant; -var set = require('lodash').set; -var cloneDeep = require('lodash').cloneDeep; -var indexBy = require('lodash').indexBy; +let sinon = require('auto-release-sinon'); +let ngMock = require('ngMock'); +let $ = require('jquery'); +let expect = require('expect.js'); +let constant = require('lodash').constant; +let set = require('lodash').set; +let cloneDeep = require('lodash').cloneDeep; +let indexBy = require('lodash').indexBy; require('ui/chrome'); require('../app_switcher'); -var DomLocationProvider = require('ui/domLocation'); +let DomLocationProvider = require('ui/domLocation'); describe('appSwitcher directive', function () { let env; @@ -18,7 +18,7 @@ describe('appSwitcher directive', function () { function setup(href, links) { return ngMock.inject(function ($window, $rootScope, $compile, Private) { - var domLocation = Private(DomLocationProvider); + let domLocation = Private(DomLocationProvider); $rootScope.chrome = { getNavLinks: constant(cloneDeep(links)), @@ -46,14 +46,14 @@ describe('appSwitcher directive', function () { } context('when one link is for the active app', function () { - var myLink = { + let myLink = { active: true, title: 'myLink', url: 'http://localhost:555/app/myApp', lastSubUrl: 'http://localhost:555/app/myApp#/lastSubUrl' }; - var notMyLink = { + let notMyLink = { active: false, title: 'notMyLink', url: 'http://localhost:555/app/notMyApp', @@ -63,27 +63,27 @@ describe('appSwitcher directive', function () { beforeEach(setup('http://localhost:5555/app/myApp/', [myLink, notMyLink])); it('links to the inactive apps base url', function () { - var $myLink = env.$el.findTestSubject('appLink').eq(0); + let $myLink = env.$el.findTestSubject('appLink').eq(0); expect($myLink.prop('href')).to.be(myLink.url); expect($myLink.prop('href')).to.not.be(myLink.lastSubUrl); }); it('links to the inactive apps last sub url', function () { - var $notMyLink = env.$el.findTestSubject('appLink').eq(1); + let $notMyLink = env.$el.findTestSubject('appLink').eq(1); expect($notMyLink.prop('href')).to.be(notMyLink.lastSubUrl); expect($notMyLink.prop('href')).to.not.be(notMyLink.url); }); }); context('when none of the links are for the active app', function () { - var myLink = { + let myLink = { active: false, title: 'myLink', url: 'http://localhost:555/app/myApp', lastSubUrl: 'http://localhost:555/app/myApp#/lastSubUrl' }; - var notMyLink = { + let notMyLink = { active: false, title: 'notMyLink', url: 'http://localhost:555/app/notMyApp', @@ -93,9 +93,9 @@ describe('appSwitcher directive', function () { beforeEach(setup('http://localhost:5555/app/myApp/', [myLink, notMyLink])); it('links to the lastSubUrl for each', function () { - var $links = env.$el.findTestSubject('appLink'); - var $myLink = $links.eq(0); - var $notMyLink = $links.eq(1); + let $links = env.$el.findTestSubject('appLink'); + let $myLink = $links.eq(0); + let $notMyLink = $links.eq(1); expect($myLink.prop('href')).to.be(myLink.lastSubUrl); expect($myLink.prop('href')).to.not.be(myLink.url); @@ -106,19 +106,19 @@ describe('appSwitcher directive', function () { }); context('clicking a link with matching href but missing hash', function () { - var url = 'http://localhost:555/app/myApp?query=1'; + let url = 'http://localhost:555/app/myApp?query=1'; beforeEach(setup(url + '#/lastSubUrl', [ { url: url } ])); it('just prevents propogation (no reload)', function () { - var event = new $.Event('click'); + let event = new $.Event('click'); expect(env.location.reload.callCount).to.be(0); expect(event.isDefaultPrevented()).to.be(false); expect(event.isPropagationStopped()).to.be(false); - var $link = env.$el.findTestSubject('appLink'); + let $link = env.$el.findTestSubject('appLink'); expect($link.prop('href')).to.be(url); $link.trigger(event); @@ -129,19 +129,19 @@ describe('appSwitcher directive', function () { }); context('clicking a link that matches entire url', function () { - var url = 'http://localhost:555/app/myApp#/lastSubUrl'; + let url = 'http://localhost:555/app/myApp#/lastSubUrl'; beforeEach(setup(url, [ { url: url } ])); it('calls window.location.reload and prevents propogation', function () { - var event = new $.Event('click'); + let event = new $.Event('click'); expect(env.location.reload.callCount).to.be(0); expect(event.isDefaultPrevented()).to.be(false); expect(event.isPropagationStopped()).to.be(false); - var $link = env.$el.findTestSubject('appLink'); + let $link = env.$el.findTestSubject('appLink'); expect($link.prop('href')).to.be(env.currentHref); $link.trigger(event); @@ -152,21 +152,21 @@ describe('appSwitcher directive', function () { }); context('clicking a link with matching href but changed hash', function () { - var rootUrl = 'http://localhost:555/app/myApp?query=1'; - var url = rootUrl + '#/lastSubUrl2'; + let rootUrl = 'http://localhost:555/app/myApp?query=1'; + let url = rootUrl + '#/lastSubUrl2'; beforeEach(setup(url + '#/lastSubUrl', [ { url: url } ])); it('calls window.location.reload and prevents propogation', function () { - var event = new $.Event('click'); + let event = new $.Event('click'); expect(env.location.reload.callCount).to.be(0); expect(event.isDefaultPrevented()).to.be(false); expect(event.isPropagationStopped()).to.be(false); - var $link = env.$el.findTestSubject('appLink'); + let $link = env.$el.findTestSubject('appLink'); expect($link.prop('href')).to.be(url); $link.trigger(event); @@ -185,7 +185,7 @@ describe('appSwitcher directive', function () { ])); it('allows click through', function () { - var event = new $.Event('click'); + let event = new $.Event('click'); expect(env.location.reload.callCount).to.be(0); expect(event.isPropagationStopped()).to.be(false); @@ -206,7 +206,7 @@ describe('appSwitcher directive', function () { ])); it('allows click through', function () { - var event = new $.Event('click'); + let event = new $.Event('click'); expect(env.location.reload.callCount).to.be(0); expect(event.isPropagationStopped()).to.be(false); diff --git a/src/ui/public/config/__tests__/config.js b/src/ui/public/config/__tests__/config.js index ba8e267a8b28c..2a47b55c95d27 100644 --- a/src/ui/public/config/__tests__/config.js +++ b/src/ui/public/config/__tests__/config.js @@ -2,8 +2,8 @@ describe('config component', function () { let $scope; let config; let defaults; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function ($injector, Private) { @@ -19,8 +19,8 @@ describe('config component', function () { }); it('reads from the defaults', function () { - var initial = config.get('dateFormat'); - var newDefault = initial + '- new'; + let initial = config.get('dateFormat'); + let newDefault = initial + '- new'; defaults.dateFormat.value = newDefault; expect(config.get('dateFormat')).to.be(newDefault); }); @@ -30,7 +30,7 @@ describe('config component', function () { describe('#set', function () { it('stores a value in the config val set', function () { - var initial = config.get('dateFormat'); + let initial = config.get('dateFormat'); config.set('dateFormat', 'notaformat'); expect(config.get('dateFormat')).to.be('notaformat'); }); @@ -40,21 +40,21 @@ describe('config component', function () { describe('#$bind', function () { it('binds a config key to a $scope property', function () { - var dateFormat = config.get('dateFormat'); + let dateFormat = config.get('dateFormat'); config.$bind($scope, 'dateFormat'); expect($scope).to.have.property('dateFormat', dateFormat); }); it('alows overriding the property name', function () { - var dateFormat = config.get('dateFormat'); + let dateFormat = config.get('dateFormat'); config.$bind($scope, 'dateFormat', 'defaultDateFormat'); expect($scope).to.not.have.property('dateFormat'); expect($scope).to.have.property('defaultDateFormat', dateFormat); }); it('keeps the property up to date', function () { - var dateFormat = config.get('dateFormat'); - var newDateFormat = dateFormat + ' NEW NEW NEW!'; + let dateFormat = config.get('dateFormat'); + let newDateFormat = dateFormat + ' NEW NEW NEW!'; config.$bind($scope, 'dateFormat'); expect($scope).to.have.property('dateFormat', dateFormat); diff --git a/src/ui/public/courier/data_source/__tests__/decorate_query.js b/src/ui/public/courier/data_source/__tests__/decorate_query.js index cdd8cc2140f18..9967f086234d9 100644 --- a/src/ui/public/courier/data_source/__tests__/decorate_query.js +++ b/src/ui/public/courier/data_source/__tests__/decorate_query.js @@ -1,10 +1,10 @@ -var moment = require('moment'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let moment = require('moment'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Query decorator', function () { - var _ = require('lodash'); + let _ = require('lodash'); let config; let indexPattern; @@ -17,7 +17,7 @@ describe('Query decorator', function () { function ($provide) { // Super simple config stub $provide.service('config', function () { - var keys = {}; + let keys = {}; return { get: function (key) { return keys[key]; }, set: function (key, value) { keys[key] = value; } diff --git a/src/ui/public/courier/data_source/__tests__/normalize_sort_request.js b/src/ui/public/courier/data_source/__tests__/normalize_sort_request.js index c647e3898875b..80e922fd3e02a 100644 --- a/src/ui/public/courier/data_source/__tests__/normalize_sort_request.js +++ b/src/ui/public/courier/data_source/__tests__/normalize_sort_request.js @@ -2,8 +2,8 @@ describe('SearchSource#normalizeSortRequest', function () { require('ui/private'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let normalizeSortRequest; let indexPattern; @@ -23,8 +23,8 @@ describe('SearchSource#normalizeSortRequest', function () { })); it('should return an array', function () { - var sortable = { someField: 'desc'}; - var result = normalizeSortRequest(sortable, indexPattern); + let sortable = { someField: 'desc'}; + let result = normalizeSortRequest(sortable, indexPattern); expect(result).to.be.an(Array); expect(result).to.eql(normalizedSort); // ensure object passed in is not mutated @@ -33,27 +33,27 @@ describe('SearchSource#normalizeSortRequest', function () { }); it('should make plain string sort into the more verbose format', function () { - var result = normalizeSortRequest([{ someField: 'desc'}], indexPattern); + let result = normalizeSortRequest([{ someField: 'desc'}], indexPattern); expect(result).to.eql(normalizedSort); }); it('should append default sort options', function () { - var sortState = [{ + let sortState = [{ someField: { order: 'desc', unmapped_type: 'boolean' } }]; - var result = normalizeSortRequest(sortState, indexPattern); + let result = normalizeSortRequest(sortState, indexPattern); expect(result).to.eql(normalizedSort); }); it('should enable script based sorting', function () { - var fieldName = 'script string'; - var direction = 'desc'; - var indexField = indexPattern.fields.byName[fieldName]; + let fieldName = 'script string'; + let direction = 'desc'; + let indexField = indexPattern.fields.byName[fieldName]; - var sortState = {}; + let sortState = {}; sortState[fieldName] = direction; normalizedSort = { _script: { @@ -63,7 +63,7 @@ describe('SearchSource#normalizeSortRequest', function () { } }; - var result = normalizeSortRequest(sortState, indexPattern); + let result = normalizeSortRequest(sortState, indexPattern); expect(result).to.eql([normalizedSort]); sortState[fieldName] = { order: direction }; @@ -72,18 +72,18 @@ describe('SearchSource#normalizeSortRequest', function () { }); it('should use script based sorting only on sortable types', function () { - var fieldName = 'script murmur3'; - var direction = 'asc'; - var indexField = indexPattern.fields.byName[fieldName]; + let fieldName = 'script murmur3'; + let direction = 'asc'; + let indexField = indexPattern.fields.byName[fieldName]; - var sortState = {}; + let sortState = {}; sortState[fieldName] = direction; normalizedSort = {}; normalizedSort[fieldName] = { order: direction, unmapped_type: 'boolean' }; - var result = normalizeSortRequest([sortState], indexPattern); + let result = normalizeSortRequest([sortState], indexPattern); expect(result).to.eql([normalizedSort]); }); diff --git a/src/ui/public/courier/fetch/__tests__/doc.js b/src/ui/public/courier/fetch/__tests__/doc.js index bc225fdaba6cc..3c1195b843bab 100644 --- a/src/ui/public/courier/fetch/__tests__/doc.js +++ b/src/ui/public/courier/fetch/__tests__/doc.js @@ -1,8 +1,8 @@ describe('Courier DocFetchRequest class', function () { - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let storage; let source; @@ -13,8 +13,8 @@ describe('Courier DocFetchRequest class', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, Promise, $injector) { - var DocSource = Private(require('ui/courier/data_source/doc_source')); - var DocFetchRequest = Private(require('ui/courier/fetch/request/doc')); + let DocSource = Private(require('ui/courier/data_source/doc_source')); + let DocFetchRequest = Private(require('ui/courier/fetch/request/doc')); storage = $injector.get('localStorage').store = diff --git a/src/ui/public/courier/fetch/request/__tests__/segmented_create_queue.js b/src/ui/public/courier/fetch/request/__tests__/segmented_create_queue.js index 65057932a350a..c2fd182e41add 100644 --- a/src/ui/public/courier/fetch/request/__tests__/segmented_create_queue.js +++ b/src/ui/public/courier/fetch/request/__tests__/segmented_create_queue.js @@ -28,7 +28,7 @@ describe('ui/courier/fetch/request/segmented/_createQueue', () => { const req = new SegmentedReq(new MockSource()); req._queueCreated = null; - var promise = req._createQueue(); + let promise = req._createQueue(); expect(req._queueCreated).to.be(false); await promise; expect(req._queueCreated).to.be(true); diff --git a/src/ui/public/debounce/__tests__/debounce.js b/src/ui/public/debounce/__tests__/debounce.js index 24b88ebe5baef..6c12ed22c6981 100644 --- a/src/ui/public/debounce/__tests__/debounce.js +++ b/src/ui/public/debounce/__tests__/debounce.js @@ -1,7 +1,7 @@ -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let debounce; let $timeout; @@ -27,14 +27,14 @@ describe('debounce service', function () { describe('API', function () { it('should have a cancel method', function () { - var bouncer = debounce(function () {}, 100); + let bouncer = debounce(function () {}, 100); expect(bouncer).to.have.property('cancel'); }); }); describe('delayed execution', function () { it('should delay execution', function () { - var bouncer = debounce(spy, 100); + let bouncer = debounce(spy, 100); bouncer(); expect(spy.callCount).to.be(0); $timeout.flush(); @@ -42,7 +42,7 @@ describe('debounce service', function () { }); it('should fire on leading edge', function () { - var bouncer = debounce(spy, 100, { leading: true }); + let bouncer = debounce(spy, 100, { leading: true }); bouncer(); expect(spy.callCount).to.be(1); $timeout.flush(); @@ -50,7 +50,7 @@ describe('debounce service', function () { }); it('should only fire on leading edge', function () { - var bouncer = debounce(spy, 100, { leading: true, trailing: false }); + let bouncer = debounce(spy, 100, { leading: true, trailing: false }); bouncer(); expect(spy.callCount).to.be(1); $timeout.flush(); @@ -58,8 +58,8 @@ describe('debounce service', function () { }); it('should reset delayed execution', function (done) { - var cancelSpy = sinon.spy($timeout, 'cancel'); - var bouncer = debounce(spy, 100); + let cancelSpy = sinon.spy($timeout, 'cancel'); + let bouncer = debounce(spy, 100); bouncer(); setTimeout(function () { bouncer(); @@ -74,8 +74,8 @@ describe('debounce service', function () { describe('cancel', function () { it('should cancel the $timeout', function () { - var cancelSpy = sinon.spy($timeout, 'cancel'); - var bouncer = debounce(spy, 100); + let cancelSpy = sinon.spy($timeout, 'cancel'); + let bouncer = debounce(spy, 100); bouncer(); bouncer.cancel(); expect(cancelSpy.callCount).to.be(1); diff --git a/src/ui/public/directives/__tests__/auto_select_if_only_one.js b/src/ui/public/directives/__tests__/auto_select_if_only_one.js index af309bbfcd1be..4d79e96a5aa45 100644 --- a/src/ui/public/directives/__tests__/auto_select_if_only_one.js +++ b/src/ui/public/directives/__tests__/auto_select_if_only_one.js @@ -1,22 +1,22 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/auto_select_if_only_one'); describe('Auto-select if only one directive', function () { let $compile; let $rootScope; - var zeroOptions = []; - var oneOption = [{label: 'foo'}]; - var multiOptions = [{label: 'foo'}, {label: 'bar'}]; + let zeroOptions = []; + let oneOption = [{label: 'foo'}]; + let multiOptions = [{label: 'foo'}, {label: 'bar'}]; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (_$compile_, _$rootScope_) { $compile = _$compile_; $rootScope = _$rootScope_; - var html = ''; + let html = ''; $compile(html)($rootScope); $rootScope.value = null; })); @@ -41,7 +41,7 @@ describe('Auto-select if only one directive', function () { it('should still auto select if the collection contains 2 items but is filtered to 1', function () { $rootScope.options = multiOptions; - var html = ''; $compile(html)($rootScope); $rootScope.value = null; diff --git a/src/ui/public/directives/__tests__/config.js b/src/ui/public/directives/__tests__/config.js index ba587e6d3ae9b..b0c5d39c2fdb6 100644 --- a/src/ui/public/directives/__tests__/config.js +++ b/src/ui/public/directives/__tests__/config.js @@ -1,14 +1,14 @@ -var ngMock = require('ngMock'); -var $ = require('jquery'); -var assign = require('lodash').assign; -var expect = require('expect.js'); +let ngMock = require('ngMock'); +let $ = require('jquery'); +let assign = require('lodash').assign; +let expect = require('expect.js'); describe('Config Directive', function () { - var build = function () {}; + let build = function () {}; beforeEach(ngMock.module('kibana', function ($compileProvider) { - var renderCount = 0; + let renderCount = 0; $compileProvider.directive('renderCounter', function () { return { link: function ($scope, $el) { @@ -21,8 +21,8 @@ describe('Config Directive', function () { beforeEach(ngMock.inject(function ($compile, $rootScope) { build = function (attrs, scopeVars) { - var $el = $('').attr(attrs); - var $scope = $rootScope.$new(); + let $el = $('').attr(attrs); + let $scope = $rootScope.$new(); assign($scope, scopeVars || {}); $compile($el)($scope); $scope.$digest(); @@ -32,12 +32,12 @@ describe('Config Directive', function () { })); it('renders it\'s config template', function () { - var $config = build({ 'config-template': '""' }); + let $config = build({ 'config-template': '""' }); expect($config.find('uniqel').size()).to.be(1); }); it('exposes an object a config object using it\'s name', function () { - var $config = build( + let $config = build( { 'config-template': '"{{ controller.name }}"', 'config-object': 'controller', @@ -53,7 +53,7 @@ describe('Config Directive', function () { }); it('only renders the config-template once', function () { - var $config = build({ 'config-template': '"
"' }); + let $config = build({ 'config-template': '"
"' }); expect($config.find('[render-counter]').text()).to.be('1'); }); }); diff --git a/src/ui/public/directives/__tests__/confirm-click.js b/src/ui/public/directives/__tests__/confirm-click.js index 0e45723937ac2..8f104db3613e9 100644 --- a/src/ui/public/directives/__tests__/confirm-click.js +++ b/src/ui/public/directives/__tests__/confirm-click.js @@ -1,8 +1,8 @@ -var angular = require('angular'); -var $ = require('jquery'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let $ = require('jquery'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/confirm_click'); require('plugins/kibana/discover/index'); @@ -13,7 +13,7 @@ let $scope; let $elem; -var init = function (text) { +let init = function (text) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/directives/__tests__/css_truncate.js b/src/ui/public/directives/__tests__/css_truncate.js index 3fe32b98ca3db..310f4f8a5badc 100644 --- a/src/ui/public/directives/__tests__/css_truncate.js +++ b/src/ui/public/directives/__tests__/css_truncate.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var $ = require('jquery'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let $ = require('jquery'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); let $parentScope; @@ -10,7 +10,7 @@ let $scope; let $elem; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/directives/__tests__/fixedScroll.js b/src/ui/public/directives/__tests__/fixedScroll.js index 254166b4a804b..431ba3f041738 100644 --- a/src/ui/public/directives/__tests__/fixedScroll.js +++ b/src/ui/public/directives/__tests__/fixedScroll.js @@ -1,15 +1,15 @@ require('ui/fixedScroll'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('FixedScroll directive', function () { - var $ = require('jquery'); - var sinon = require('auto-release-sinon'); - var Promise = require('bluebird'); + let $ = require('jquery'); + let sinon = require('auto-release-sinon'); + let Promise = require('bluebird'); let compile; - var trash = []; + let trash = []; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function ($compile, $rootScope) { @@ -19,7 +19,7 @@ describe('FixedScroll directive', function () { // since the directive works at the sibling level we create a // parent for everything to happen in - var $parent = $('
').css({ + let $parent = $('
').css({ position: 'fixed', top: 0, left: 0, @@ -30,12 +30,12 @@ describe('FixedScroll directive', function () { $parent.appendTo(document.body); trash.push($parent); - var $el = $('
').css({ + let $el = $('
').css({ 'overflow-x': 'auto', 'width': $parent.width() }).appendTo($parent); - var $content = $('
').css({ + let $content = $('
').css({ width: $parent.width() * ratioX, height: $parent.height() * ratioY }).appendTo($el); @@ -59,7 +59,7 @@ describe('FixedScroll directive', function () { }); it('does nothing when not needed', function () { - var els = compile(0.5, 1.5); + let els = compile(0.5, 1.5); expect(els.$scroller).to.have.length(0); els = compile(1.5, 0.5); @@ -67,26 +67,26 @@ describe('FixedScroll directive', function () { }); it('attaches a scroller below the element when the content is larger then the container', function () { - var els = compile(1.5); + let els = compile(1.5); expect(els.$scroller).to.have.length(1); }); it('copies the width of the container', function () { - var els = compile(1.5); + let els = compile(1.5); expect(els.$scroller.width()).to.be(els.$container.width()); }); it('mimics the scrollWidth of the element', function () { - var els = compile(1.5); + let els = compile(1.5); expect(els.$scroller.prop('scrollWidth')).to.be(els.$container.prop('scrollWidth')); }); describe('scroll event handling / tug of war prevention', function () { it('listens when needed, unlistens when not needed', function () { - var on = sinon.spy($.fn, 'on'); - var off = sinon.spy($.fn, 'off'); + let on = sinon.spy($.fn, 'on'); + let off = sinon.spy($.fn, 'off'); - var els = compile(1.5); + let els = compile(1.5); expect(on.callCount).to.be(2); checkThisVals('$.fn.on', on); @@ -130,12 +130,12 @@ describe('FixedScroll directive', function () { expect(spy.callCount).to.be(2); // first call should read the scrollLeft from the $container - var firstCall = spy.getCall(0); + let firstCall = spy.getCall(0); expect(firstCall.thisValue.is($from)).to.be(true); expect(firstCall.args).to.eql([]); // second call should be setting the scrollLeft on the $scroller - var secondCall = spy.getCall(1); + let secondCall = spy.getCall(1); expect(secondCall.thisValue.is($to)).to.be(true); expect(secondCall.args).to.eql([firstCall.returnValue]); }); diff --git a/src/ui/public/directives/__tests__/inequality.js b/src/ui/public/directives/__tests__/inequality.js index c1672d2539d66..f005f0c842429 100644 --- a/src/ui/public/directives/__tests__/inequality.js +++ b/src/ui/public/directives/__tests__/inequality.js @@ -1,6 +1,6 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/inequality'); describe('greater_than model validator directive', function () { diff --git a/src/ui/public/directives/__tests__/input_focus.js b/src/ui/public/directives/__tests__/input_focus.js index 4a670e846fefb..8955454b016d0 100644 --- a/src/ui/public/directives/__tests__/input_focus.js +++ b/src/ui/public/directives/__tests__/input_focus.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var $ = require('jquery'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let $ = require('jquery'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/input_focus'); describe('Input focus directive', function () { @@ -12,7 +12,7 @@ describe('Input focus directive', function () { let $el; let selectedEl; let selectedText; - var inputValue = 'Input Text Value'; + let inputValue = 'Input Text Value'; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (_$compile_, _$rootScope_, _$timeout_) { diff --git a/src/ui/public/directives/__tests__/input_whole_number.js b/src/ui/public/directives/__tests__/input_whole_number.js index d6892da71f7f2..a69389a2f5c8d 100644 --- a/src/ui/public/directives/__tests__/input_whole_number.js +++ b/src/ui/public/directives/__tests__/input_whole_number.js @@ -1,12 +1,12 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/input_whole_number'); describe('Whole number input directive', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; beforeEach(ngMock.module('kibana')); @@ -16,7 +16,7 @@ describe('Whole number input directive', function () { })); it('should allow whole numbers', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = '123'; $rootScope.$digest(); @@ -32,7 +32,7 @@ describe('Whole number input directive', function () { }); it('should disallow numbers with decimals', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = '123.0'; $rootScope.$digest(); diff --git a/src/ui/public/directives/__tests__/json_input.js b/src/ui/public/directives/__tests__/json_input.js index 014d267e6c90b..4bf3920c85e9e 100644 --- a/src/ui/public/directives/__tests__/json_input.js +++ b/src/ui/public/directives/__tests__/json_input.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/json_input'); describe('JSON input validation', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; let element; beforeEach(ngMock.module('kibana')); @@ -28,8 +28,8 @@ describe('JSON input validation', function () { }); it('should be able to not require keys', function () { - var html = ''; - var element = $compile(html)($rootScope); + let html = ''; + let element = $compile(html)($rootScope); element.val('{}'); element.trigger('input'); diff --git a/src/ui/public/directives/__tests__/parse_query.js b/src/ui/public/directives/__tests__/parse_query.js index c1c7c85cc5aa1..799cd7c8ce38a 100644 --- a/src/ui/public/directives/__tests__/parse_query.js +++ b/src/ui/public/directives/__tests__/parse_query.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); // Load the kibana app dependencies. require('ui/parse_query'); @@ -15,12 +15,12 @@ let config; let $elemScope; let $elem; -var cycleIndex = 0; -var markup = ''; +let cycleIndex = 0; +let markup = ''; let fromUser; -var toUser = require('ui/parse_query/lib/to_user'); +let toUser = require('ui/parse_query/lib/to_user'); -var init = function () { +let init = function () { // Load the application ngMock.module('kibana'); @@ -40,7 +40,7 @@ var init = function () { }); }; -var compile = function () { +let compile = function () { $rootScope.mockModel = 'cycle' + cycleIndex++; $rootScope.mockQueryInput = undefined; diff --git a/src/ui/public/directives/__tests__/spinner.js b/src/ui/public/directives/__tests__/spinner.js index b879bbb9b6fdf..6f561b4cf2d55 100644 --- a/src/ui/public/directives/__tests__/spinner.js +++ b/src/ui/public/directives/__tests__/spinner.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var $ = require('jquery'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let $ = require('jquery'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); @@ -11,7 +11,7 @@ let $scope; let $elem; -var init = function () { +let init = function () { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/directives/__tests__/timepicker.js b/src/ui/public/directives/__tests__/timepicker.js index e0f2bf75ee463..65c8293707336 100644 --- a/src/ui/public/directives/__tests__/timepicker.js +++ b/src/ui/public/directives/__tests__/timepicker.js @@ -1,10 +1,10 @@ -var angular = require('angular'); -var moment = require('moment'); -var expect = require('expect.js'); -var _ = require('lodash'); -var $ = require('jquery'); -var sinon = require('auto-release-sinon'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let moment = require('moment'); +let expect = require('expect.js'); +let _ = require('lodash'); +let $ = require('jquery'); +let sinon = require('auto-release-sinon'); +let ngMock = require('ngMock'); require('plugins/kibana/visualize/index'); require('plugins/kibana/dashboard/index'); @@ -17,10 +17,10 @@ let $parentScope; let $scope; let $elem; -var anchor = '2014-01-01T06:06:06.666Z'; +let anchor = '2014-01-01T06:06:06.666Z'; let clock; -var init = function () { +let init = function () { // Load the application ngMock.module('kibana'); @@ -34,7 +34,7 @@ var init = function () { $parentScope = $rootScope; // Add some parameters to it - var timefilter = { + let timefilter = { time : { from: moment().subtract(15, 'minutes'), to: moment(), @@ -174,7 +174,7 @@ describe('timepicker directive', function () { expect($elem.find('.kbn-timepicker-modes .active').text().trim()).to.be('quick'); // Each of the 3 modes - var modes = ['absolute', 'relative', 'quick']; + let modes = ['absolute', 'relative', 'quick']; _.each(modes, function (mode) { $scope.setMode(mode); $scope.$digest(); @@ -215,7 +215,7 @@ describe('timepicker directive', function () { }); it('has a preview of the "from" input', function (done) { - var preview = $elem.find('.kbn-timepicker-section span[ng-show="relative.preview"]'); + let preview = $elem.find('.kbn-timepicker-section span[ng-show="relative.preview"]'); expect(preview.text()).to.be(moment().subtract(15, 'minutes').format($scope.format)); done(); }); @@ -226,7 +226,7 @@ describe('timepicker directive', function () { }); it('has a submit handler', function (done) { - var form = $elem.find('form[ng-submit="applyRelative()"]'); + let form = $elem.find('form[ng-submit="applyRelative()"]'); expect(form.length).to.be(1); done(); }); @@ -247,7 +247,7 @@ describe('timepicker directive', function () { }); it('has a dropdown bound to relative.unit that contains all of the intervals', function (done) { - var select = $elem.find('.kbn-timepicker-section select[ng-model="relative.unit"]'); + let select = $elem.find('.kbn-timepicker-section select[ng-model="relative.unit"]'); expect(select.length).to.be(1); expect(select.find('option').length).to.be(7); @@ -259,7 +259,7 @@ describe('timepicker directive', function () { }); it('has a checkbox that is checked when rounding is enabled', function (done) { - var checkbox = $elem.find('.kbn-timepicker-section input[ng-model="relative.round"]'); + let checkbox = $elem.find('.kbn-timepicker-section input[ng-model="relative.round"]'); expect(checkbox.length).to.be(1); // Rounding is disabled by default @@ -335,8 +335,8 @@ describe('timepicker directive', function () { }); it('updates the input fields when the scope variables are changed', function (done) { - var input = $elem.find('.kbn-timepicker-section input[ng-model="relative.count"]'); - var select = $elem.find('.kbn-timepicker-section select[ng-model="relative.unit"]'); + let input = $elem.find('.kbn-timepicker-section input[ng-model="relative.count"]'); + let select = $elem.find('.kbn-timepicker-section select[ng-model="relative.unit"]'); $scope.relative.count = 5; $scope.$digest(); diff --git a/src/ui/public/directives/__tests__/truncate.js b/src/ui/public/directives/__tests__/truncate.js index d75d073aa975b..bd09e09befdd3 100644 --- a/src/ui/public/directives/__tests__/truncate.js +++ b/src/ui/public/directives/__tests__/truncate.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var $ = require('jquery'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let $ = require('jquery'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); @@ -11,7 +11,7 @@ let $scope; let $elem; -var init = function (text) { +let init = function (text) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/directives/__tests__/typeahead.js b/src/ui/public/directives/__tests__/typeahead.js index b60664b03976e..331e9300ce41b 100644 --- a/src/ui/public/directives/__tests__/typeahead.js +++ b/src/ui/public/directives/__tests__/typeahead.js @@ -1,14 +1,14 @@ -var angular = require('angular'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/typeahead'); // TODO: This should not be needed, timefilter is only included here, it should move require('plugins/kibana/discover/index'); -var typeaheadHistoryCount = 10; -var typeaheadName = 'unittest'; +let typeaheadHistoryCount = 10; +let typeaheadName = 'unittest'; let $parentScope; let $typeaheadScope; let $elem; @@ -16,13 +16,13 @@ let $typeaheadInputScope; let typeaheadCtrl; let PersistedLog; -var markup = '
' + +let markup = '
' + '' + '' + '
'; -var typeaheadItems = ['abc', 'def', 'ghi']; +let typeaheadItems = ['abc', 'def', 'ghi']; -var init = function () { +let init = function () { // Load the application ngMock.module('kibana'); @@ -64,7 +64,7 @@ var init = function () { describe('typeahead directive', function () { describe('typeahead requirements', function () { describe('missing input', function () { - var goodMarkup = markup; + let goodMarkup = markup; before(function () { markup = '
' + @@ -99,9 +99,9 @@ describe('typeahead directive', function () { }); it('should not save empty entries', function () { - var entries = typeaheadItems.slice(0); + let entries = typeaheadItems.slice(0); entries.push('', 'jkl'); - for (var i = 0; i < entries.length; i++) { + for (let i = 0; i < entries.length; i++) { $typeaheadScope.inputModel.$setViewValue(entries[i]); typeaheadCtrl.persistEntry(); } @@ -129,14 +129,14 @@ describe('typeahead directive', function () { }); it('should order fitlered results', function () { - var entries = ['ac/dc', 'anthrax', 'abba', 'phantogram', 'skrillex']; - var allEntries = typeaheadItems.concat(entries); - var startMatches = allEntries.filter(function (item) { + let entries = ['ac/dc', 'anthrax', 'abba', 'phantogram', 'skrillex']; + let allEntries = typeaheadItems.concat(entries); + let startMatches = allEntries.filter(function (item) { return /^a/.test(item); }); typeaheadCtrl.history.add.returns(allEntries); - for (var i = 0; i < entries.length; i++) { + for (let i = 0; i < entries.length; i++) { $typeaheadScope.inputModel.$setViewValue(entries[i]); typeaheadCtrl.persistEntry(); } @@ -144,7 +144,7 @@ describe('typeahead directive', function () { typeaheadCtrl.filterItemsByQuery('a'); expect($typeaheadScope.filteredItems).to.contain('phantogram'); - var nonStarterIndex = $typeaheadScope.filteredItems.indexOf('phantogram'); + let nonStarterIndex = $typeaheadScope.filteredItems.indexOf('phantogram'); startMatches.forEach(function (item) { expect($typeaheadScope.filteredItems).to.contain(item); diff --git a/src/ui/public/directives/__tests__/validate_cidr_mask.js b/src/ui/public/directives/__tests__/validate_cidr_mask.js index 48781616804d3..6b37b972907ce 100644 --- a/src/ui/public/directives/__tests__/validate_cidr_mask.js +++ b/src/ui/public/directives/__tests__/validate_cidr_mask.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/validate_cidr_mask'); describe('Validate CIDR mask directive', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; beforeEach(ngMock.module('kibana')); @@ -17,7 +17,7 @@ describe('Validate CIDR mask directive', function () { })); it('should allow empty input', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = ''; $rootScope.$digest(); @@ -33,7 +33,7 @@ describe('Validate CIDR mask directive', function () { }); it('should allow valid CIDR masks', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = '0.0.0.0/1'; $rootScope.$digest(); @@ -53,7 +53,7 @@ describe('Validate CIDR mask directive', function () { }); it('should disallow invalid CIDR masks', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = 'hello, world'; $rootScope.$digest(); diff --git a/src/ui/public/directives/__tests__/validate_date_math.js b/src/ui/public/directives/__tests__/validate_date_math.js index 3242bf3223416..fdd3805bcf984 100644 --- a/src/ui/public/directives/__tests__/validate_date_math.js +++ b/src/ui/public/directives/__tests__/validate_date_math.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/validate_date_math'); describe('Validate date math directive', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; beforeEach(ngMock.module('kibana')); @@ -17,7 +17,7 @@ describe('Validate date math directive', function () { })); it('should allow valid date math', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = 'now'; $rootScope.$digest(); @@ -41,7 +41,7 @@ describe('Validate date math directive', function () { }); it('should disallow invalid date math', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = 'hello, world'; $rootScope.$digest(); @@ -61,7 +61,7 @@ describe('Validate date math directive', function () { }); it('should allow empty values', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = ''; $rootScope.$digest(); diff --git a/src/ui/public/directives/__tests__/validate_index_name.js b/src/ui/public/directives/__tests__/validate_index_name.js index dddec37e88308..d658b1b03a9a8 100644 --- a/src/ui/public/directives/__tests__/validate_index_name.js +++ b/src/ui/public/directives/__tests__/validate_index_name.js @@ -1,6 +1,6 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); // Load the kibana app dependencies. require('ui/directives/validate_index_name'); @@ -8,7 +8,7 @@ require('ui/directives/validate_index_name'); describe('Validate index name directive', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; beforeEach(ngMock.module('kibana')); @@ -19,12 +19,12 @@ describe('Validate index name directive', function () { function checkPattern(input) { $rootScope.indexName = input; - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.$digest(); return element; } - var badPatterns = [ + let badPatterns = [ null, undefined, '', @@ -41,7 +41,7 @@ describe('Validate index name directive', function () { 'foo,bar', ]; - var goodPatterns = [ + let goodPatterns = [ '...', 'foo', 'foo.bar', @@ -53,7 +53,7 @@ describe('Validate index name directive', function () { badPatterns.forEach(function (pattern) { it('should not accept index pattern: ' + pattern, function () { - var element = checkPattern(pattern); + let element = checkPattern(pattern); expect(element.hasClass('ng-invalid')).to.be(true); expect(element.hasClass('ng-valid')).to.not.be(true); }); @@ -61,7 +61,7 @@ describe('Validate index name directive', function () { goodPatterns.forEach(function (pattern) { it('should accept index pattern: ' + pattern, function () { - var element = checkPattern(pattern); + let element = checkPattern(pattern); expect(element.hasClass('ng-invalid')).to.not.be(true); expect(element.hasClass('ng-valid')).to.be(true); }); diff --git a/src/ui/public/directives/__tests__/validate_ip.js b/src/ui/public/directives/__tests__/validate_ip.js index 1cda22fc5b6b2..018ba99ce08ff 100644 --- a/src/ui/public/directives/__tests__/validate_ip.js +++ b/src/ui/public/directives/__tests__/validate_ip.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/directives/validate_ip'); describe('Validate IP directive', function () { let $compile; let $rootScope; - var html = ''; + let html = ''; beforeEach(ngMock.module('kibana')); @@ -17,7 +17,7 @@ describe('Validate IP directive', function () { })); it('should allow empty input', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = ''; $rootScope.$digest(); @@ -33,7 +33,7 @@ describe('Validate IP directive', function () { }); it('should allow valid IP addresses', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = '0.0.0.0'; $rootScope.$digest(); @@ -53,7 +53,7 @@ describe('Validate IP directive', function () { }); it('should disallow invalid IP addresses', function () { - var element = $compile(html)($rootScope); + let element = $compile(html)($rootScope); $rootScope.value = 'hello, world'; $rootScope.$digest(); diff --git a/src/ui/public/directives/__tests__/validate_json.js b/src/ui/public/directives/__tests__/validate_json.js index fa04a204b6f70..e7c217895fc1e 100644 --- a/src/ui/public/directives/__tests__/validate_json.js +++ b/src/ui/public/directives/__tests__/validate_json.js @@ -1,6 +1,6 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); // Load the kibana app dependencies. require('ui/directives/validate_json'); @@ -8,23 +8,23 @@ require('ui/directives/validate_json'); let $parentScope; let $elemScope; let $elem; -var mockScope = ''; +let mockScope = ''; -var input = { +let input = { valid: '{ "test": "json input" }', invalid: 'strings are not json' }; -var markup = { +let markup = { textarea: '', input: '' }; -var init = function (type) { +let init = function (type) { // Load the application ngMock.module('kibana'); type = type || 'input'; - var elMarkup = markup[type]; + let elMarkup = markup[type]; // Create the scope ngMock.inject(function ($injector, $rootScope, $compile) { @@ -39,7 +39,7 @@ var init = function (type) { }; describe('validate-json directive', function () { - var checkValid = function (inputVal, className) { + let checkValid = function (inputVal, className) { $parentScope.mockModel = inputVal; $elem.scope().$digest(); expect($elem.hasClass(className)).to.be(true); diff --git a/src/ui/public/doc_table/__tests__/doc_table.js b/src/ui/public/doc_table/__tests__/doc_table.js index b982f20d36851..edabaf924d9df 100644 --- a/src/ui/public/doc_table/__tests__/doc_table.js +++ b/src/ui/public/doc_table/__tests__/doc_table.js @@ -1,10 +1,10 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var $ = require('jquery'); -var _ = require('lodash'); -var sinon = require('auto-release-sinon'); -var searchResponse = require('fixtures/search_response'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let $ = require('jquery'); +let _ = require('lodash'); +let sinon = require('auto-release-sinon'); +let searchResponse = require('fixtures/search_response'); +let ngMock = require('ngMock'); // Load the kibana app dependencies. require('ui/private'); @@ -22,7 +22,7 @@ let $timeout; let searchSource; -var init = function ($elem, props) { +let init = function ($elem, props) { ngMock.inject(function ($rootScope, $compile, _$timeout_) { $timeout = _$timeout_; $parentScope = $rootScope; @@ -40,7 +40,7 @@ var init = function ($elem, props) { }); }; -var destroy = function () { +let destroy = function () { $scope.$destroy(); $parentScope.$destroy(); }; diff --git a/src/ui/public/doc_table/__tests__/lib/get_sort.js b/src/ui/public/doc_table/__tests__/lib/get_sort.js index 9c83ad57bf069..956314dad3171 100644 --- a/src/ui/public/doc_table/__tests__/lib/get_sort.js +++ b/src/ui/public/doc_table/__tests__/lib/get_sort.js @@ -1,7 +1,7 @@ -var getSort = require('ui/doc_table/lib/get_sort'); -var defaultSort = {time: 'desc'}; -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let getSort = require('ui/doc_table/lib/get_sort'); +let defaultSort = {time: 'desc'}; +let expect = require('expect.js'); +let ngMock = require('ngMock'); let indexPattern; describe('docTable', function () { diff --git a/src/ui/public/doc_table/__tests__/lib/rows_headers.js b/src/ui/public/doc_table/__tests__/lib/rows_headers.js index d57ce171ff13e..75b5a2a7e7930 100644 --- a/src/ui/public/doc_table/__tests__/lib/rows_headers.js +++ b/src/ui/public/doc_table/__tests__/lib/rows_headers.js @@ -1,10 +1,10 @@ -var angular = require('angular'); -var $ = require('jquery'); -var _ = require('lodash'); -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var getFakeRow = require('fixtures/fake_row'); +let angular = require('angular'); +let $ = require('jquery'); +let _ = require('lodash'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let getFakeRow = require('fixtures/fake_row'); describe('Doc Table', function () { require('plugins/kibana/discover/index'); @@ -27,7 +27,7 @@ describe('Doc Table', function () { })); // Sets up the directive, take an element, and a list of properties to attach to the parent scope. - var init = function ($elem, props) { + let init = function ($elem, props) { ngMock.inject(function ($compile) { _.assign($parentScope, props); $compile($elem)($parentScope); @@ -36,17 +36,17 @@ describe('Doc Table', function () { }); }; - var destroy = function () { + let destroy = function () { $scope.$destroy(); $parentScope.$destroy(); }; // For testing column removing/adding for the header and the rows // - var columnTests = function (elemType, parentElem) { + let columnTests = function (elemType, parentElem) { it('should create a time column if the timefield is defined', function (done) { - var childElems = parentElem.find(elemType); + let childElems = parentElem.find(elemType); expect(childElems.length).to.be(2); done(); }); @@ -78,7 +78,7 @@ describe('Doc Table', function () { delete parentElem.scope().indexPattern.timeFieldName; parentElem.scope().$digest(); - var childElems = parentElem.find(elemType); + let childElems = parentElem.find(elemType); expect(childElems.length).to.be(1); done(); }); @@ -88,7 +88,7 @@ describe('Doc Table', function () { describe('kbnTableHeader', function () { - var $elem = angular.element( + let $elem = angular.element( '' ); @@ -119,7 +119,7 @@ describe('Doc Table', function () { }); it('should sort asc by default, then by desc if already sorting', function (done) { - var fields = ['bytes', '@timestamp']; + let fields = ['bytes', '@timestamp']; // Should not be sorted at first expect($scope.sorting).to.eql(undefined); @@ -200,7 +200,7 @@ describe('Doc Table', function () { }); describe('kbnTableRow', function () { - var $elem = angular.element( + let $elem = angular.element( '=', gt: '>', lte: '<=', lt: '<'}, function (operator, key) { - var params = {}; + let params = {}; params[key] = 5; - var filter = fn(indexPattern.fields.byName['script number'], params, indexPattern); + let filter = fn(indexPattern.fields.byName['script number'], params, indexPattern); expect(filter.script.script).to.be('(' + indexPattern.fields.byName['script number'].script + ')' + operator + key); expect(filter.script.params[key]).to.be(5); diff --git a/src/ui/public/filters/__tests__/commaList.js b/src/ui/public/filters/__tests__/commaList.js index c005c5333d97b..a6a491a491c61 100644 --- a/src/ui/public/filters/__tests__/commaList.js +++ b/src/ui/public/filters/__tests__/commaList.js @@ -1,6 +1,6 @@ require('ui/filters/commaList'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Comma-List filter', function () { diff --git a/src/ui/public/filters/__tests__/field_type.js b/src/ui/public/filters/__tests__/field_type.js index 7799270465172..c6b6cf2475907 100644 --- a/src/ui/public/filters/__tests__/field_type.js +++ b/src/ui/public/filters/__tests__/field_type.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var _ = require('lodash'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let _ = require('lodash'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); require('ui/filters/field_type'); @@ -9,7 +9,7 @@ let filter; let types; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); @@ -59,7 +59,7 @@ describe('fieldType array filter', function () { }); it('should allow negation', function () { - var resultNames = _.pluck(filter(types, '!string'), 'name'); + let resultNames = _.pluck(filter(types, '!string'), 'name'); expect(resultNames).to.eql(['n1', 'n2', 'i1', 'd1']); }); }); diff --git a/src/ui/public/filters/__tests__/label.js b/src/ui/public/filters/__tests__/label.js index 717e9de75c1a3..2d5946f0b6f1a 100644 --- a/src/ui/public/filters/__tests__/label.js +++ b/src/ui/public/filters/__tests__/label.js @@ -1,15 +1,15 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var _ = require('lodash'); -var faker = require('faker'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let _ = require('lodash'); +let faker = require('faker'); +let ngMock = require('ngMock'); // Load kibana and its applications require('plugins/kibana/discover/index'); let filter; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/filters/__tests__/moment.js b/src/ui/public/filters/__tests__/moment.js index ff720aba35d34..48260c0f14f40 100644 --- a/src/ui/public/filters/__tests__/moment.js +++ b/src/ui/public/filters/__tests__/moment.js @@ -1,18 +1,18 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var sinon = require('auto-release-sinon'); -var moment = require('moment'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let sinon = require('auto-release-sinon'); +let moment = require('moment'); +let ngMock = require('ngMock'); require('ui/filters/moment'); let filter; let config; -var anchor = '2014-01-01T06:06:06.666'; +let anchor = '2014-01-01T06:06:06.666'; let clock; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/filters/__tests__/rison.js b/src/ui/public/filters/__tests__/rison.js index fb3732ad2bd24..6ac1b76a577b8 100644 --- a/src/ui/public/filters/__tests__/rison.js +++ b/src/ui/public/filters/__tests__/rison.js @@ -1,6 +1,6 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); // Load kibana and its applications require('plugins/kibana/discover/index'); @@ -8,7 +8,7 @@ require('plugins/kibana/discover/index'); let rison; let risonDecode; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); @@ -20,13 +20,13 @@ var init = function (expandable) { }; describe('rison filters', function () { - var testObj = { + let testObj = { time: { from: 'now-15m', to: 'now' } }; - var testRison = '(time:(from:now-15m,to:now))'; + let testRison = '(time:(from:now-15m,to:now))'; beforeEach(function () { init(); diff --git a/src/ui/public/filters/__tests__/short_dots.js b/src/ui/public/filters/__tests__/short_dots.js index 568ac8227297f..ad069fc99f3ee 100644 --- a/src/ui/public/filters/__tests__/short_dots.js +++ b/src/ui/public/filters/__tests__/short_dots.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var _ = require('lodash'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let _ = require('lodash'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); require('ui/filters/short_dots'); @@ -10,7 +10,7 @@ let filter; let config; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/filters/__tests__/start_from.js b/src/ui/public/filters/__tests__/start_from.js index baea1d67c2efe..90d6f7da98a60 100644 --- a/src/ui/public/filters/__tests__/start_from.js +++ b/src/ui/public/filters/__tests__/start_from.js @@ -1,12 +1,12 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/filters/start_from'); let filter; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/filters/__tests__/uriescape.js b/src/ui/public/filters/__tests__/uriescape.js index acb32e9f76fb2..149395e9be725 100644 --- a/src/ui/public/filters/__tests__/uriescape.js +++ b/src/ui/public/filters/__tests__/uriescape.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var _ = require('lodash'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let _ = require('lodash'); +let ngMock = require('ngMock'); require('plugins/kibana/discover/index'); let filter; -var init = function (expandable) { +let init = function (expandable) { // Load the application ngMock.module('kibana'); diff --git a/src/ui/public/highlight/__tests__/highlight.js b/src/ui/public/highlight/__tests__/highlight.js index 594e5f41e292c..38a455ef588bd 100644 --- a/src/ui/public/highlight/__tests__/highlight.js +++ b/src/ui/public/highlight/__tests__/highlight.js @@ -1,8 +1,8 @@ describe('Highlight', function () { - var angular = require('angular'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let angular = require('angular'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); require('ui/highlight'); let filter; @@ -15,7 +15,7 @@ describe('Highlight', function () { tags = highlightTags; })); - var text = '' + + let text = '' + 'Bacon ipsum dolor amet pork loin pork cow pig beef chuck ground round shankle sirloin landjaeger kevin ' + 'venison sausage ribeye tongue. Chicken bacon ball tip pork. Brisket pork capicola spare ribs pastrami rump ' + 'sirloin, t-bone ham shoulder jerky turducken bresaola. Chicken cow beef picanha. Picanha hamburger alcatra ' + @@ -28,27 +28,27 @@ describe('Highlight', function () { }); it('should highlight a single result', function () { - var highlights = [ + let highlights = [ tags.pre + 'hamburger' + tags.post + ' alcatra cupim. Salami capicola boudin pork belly shank picanha.' ]; - var result = filter(text, highlights); + let result = filter(text, highlights); expect(result.indexOf('hamburger')).to.be.greaterThan(-1); expect(result.split('hamburger').length).to.be(text.split('hamburger').length); }); it('should highlight multiple results', function () { - var highlights = [ + let highlights = [ 'kevin venison sausage ribeye tongue. ' + tags.pre + 'Chicken' + tags.post + ' bacon ball tip pork. Brisket ' + 'pork capicola spare ribs pastrami rump sirloin, t-bone ham shoulder jerky turducken bresaola. ' + tags.pre + 'Chicken' + tags.post + ' cow beef picanha. Picanha' ]; - var result = filter(text, highlights); + let result = filter(text, highlights); expect(result.indexOf('Chicken')).to.be.greaterThan(-1); expect(result.split('Chicken').length).to.be(text.split('Chicken').length); }); it('should highlight multiple hits in a result', function () { - var highlights = [ + let highlights = [ 'Bacon ipsum dolor amet ' + tags.pre + 'pork' + tags.post + ' loin ' + '' + tags.pre + 'pork' + tags.post + ' cow pig beef chuck ground round shankle ' + 'sirloin landjaeger', @@ -58,14 +58,14 @@ describe('Highlight', function () { 'hamburger alcatra cupim. Salami capicola boudin ' + tags.pre + 'pork' + tags.post + ' ' + 'belly shank picanha.' ]; - var result = filter(text, highlights); + let result = filter(text, highlights); expect(result.indexOf('pork')).to.be.greaterThan(-1); expect(result.split('pork').length).to.be(text.split('pork').length); }); it('should accept an object and return a string containing its properties', function () { - var obj = {foo: 1, bar: 2}; - var result = filter(obj, null); + let obj = {foo: 1, bar: 2}; + let result = filter(obj, null); expect(result.indexOf('' + obj)).to.be(-1); expect(result.indexOf('foo')).to.be.greaterThan(-1); expect(result.indexOf('bar')).to.be.greaterThan(-1); diff --git a/src/ui/public/index_patterns/__tests__/_FieldFormat.js b/src/ui/public/index_patterns/__tests__/_FieldFormat.js index 7c20cba922cce..c42386550a232 100644 --- a/src/ui/public/index_patterns/__tests__/_FieldFormat.js +++ b/src/ui/public/index_patterns/__tests__/_FieldFormat.js @@ -1,7 +1,7 @@ describe('FieldFormat class', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let FieldFormat; let TestFormat; @@ -23,14 +23,14 @@ describe('FieldFormat class', function () { describe('params', function () { it('accepts its params via the constructor', function () { - var f = new TestFormat({ foo: 'bar' }); + let f = new TestFormat({ foo: 'bar' }); expect(f.param('foo')).to.be('bar'); }); it('allows reading a clone of the params', function () { - var params = { foo: 'bar' }; - var f = new TestFormat(params); - var output = f.params(); + let params = { foo: 'bar' }; + let f = new TestFormat(params); + let output = f.params(); expect(output).to.eql(params); expect(output).to.not.be(params); }); @@ -38,29 +38,29 @@ describe('FieldFormat class', function () { describe('type', function () { it('links the constructor class to instances as the `type`', function () { - var f = new TestFormat(); + let f = new TestFormat(); expect(f.type).to.be(TestFormat); }); }); describe('toJSON', function () { it('serializes to a version a basic id and param pair', function () { - var f = new TestFormat({ foo: 'bar' }); - var ser = JSON.parse(JSON.stringify(f)); + let f = new TestFormat({ foo: 'bar' }); + let ser = JSON.parse(JSON.stringify(f)); expect(ser).to.eql({ id: 'test-format', params: { foo: 'bar' } }); }); it('removes param values that match the defaults', function () { TestFormat.paramDefaults = { foo: 'bar' }; - var f = new TestFormat({ foo: 'bar', baz: 'bar' }); - var ser = JSON.parse(JSON.stringify(f)); + let f = new TestFormat({ foo: 'bar', baz: 'bar' }); + let ser = JSON.parse(JSON.stringify(f)); expect(ser.params).to.eql({ baz: 'bar' }); }); it('removes the params entirely if they are empty', function () { - var f = new TestFormat(); - var ser = JSON.parse(JSON.stringify(f)); + let f = new TestFormat(); + let ser = JSON.parse(JSON.stringify(f)); expect(ser).to.not.have.property('params'); }); }); @@ -68,7 +68,7 @@ describe('FieldFormat class', function () { describe('converters', function () { describe('#getConverterFor', function () { it('returns a converter for a specific content type', function () { - var f = new TestFormat(); + let f = new TestFormat(); expect(f.getConverterFor('html')()).to.be.a('string'); expect(f.getConverterFor('text')()).to.be.a('string'); }); @@ -80,9 +80,9 @@ describe('FieldFormat class', function () { return 'formatted'; }; - var f = new TestFormat(); - var text = f.getConverterFor('text'); - var html = f.getConverterFor('html'); + let f = new TestFormat(); + let text = f.getConverterFor('text'); + let html = f.getConverterFor('html'); expect(text).to.not.be(html); expect(text()).to.be('formatted'); expect(html()).to.be('formatted'); @@ -94,9 +94,9 @@ describe('FieldFormat class', function () { html: _.constant('formatted html'), }; - var f = new TestFormat(); - var text = f.getConverterFor('text'); - var html = f.getConverterFor('html'); + let f = new TestFormat(); + let text = f.getConverterFor('text'); + let html = f.getConverterFor('html'); expect(text).to.not.be(html); expect(text()).to.be('formatted text'); expect(html()).to.be('formatted html'); @@ -104,13 +104,13 @@ describe('FieldFormat class', function () { it('does not escape the output of the text converter', function () { TestFormat.prototype._convert = _.constant(''); - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('', 'text')).to.contain('<'); }); it('does escape the output of the text converter if used in an html context', function () { TestFormat.prototype._convert = _.constant(''); - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('', 'html')).to.not.contain('<'); }); @@ -120,7 +120,7 @@ describe('FieldFormat class', function () { html: _.constant(''), }; - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('', 'text')).to.be(''); expect(f.convert('', 'html')).to.be(''); }); @@ -133,7 +133,7 @@ describe('FieldFormat class', function () { html: _.constant('html'), }; - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('val')).to.be('text'); }); @@ -143,7 +143,7 @@ describe('FieldFormat class', function () { html: _.constant('html'), }; - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('val', 'html')).to.be('html'); }); }); diff --git a/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js b/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js index 3960b34ddc325..06dedda19c2a7 100644 --- a/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js +++ b/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js @@ -1,7 +1,7 @@ describe('type normalizer (castMappingType)', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); let fn; let fields; @@ -19,7 +19,7 @@ describe('type normalizer (castMappingType)', function () { }); it('should cast numeric types to "number"', function () { - var types = [ + let types = [ 'float', 'double', 'integer', @@ -35,7 +35,7 @@ describe('type normalizer (castMappingType)', function () { }); it('should treat non-numeric known types as what they are', function () { - var types = [ + let types = [ 'date', 'boolean', 'ip', diff --git a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js index 1ff4607121cba..a54dd44e550b9 100644 --- a/src/ui/public/index_patterns/__tests__/_get_computed_fields.js +++ b/src/ui/public/index_patterns/__tests__/_get_computed_fields.js @@ -1,7 +1,7 @@ describe('get computed fields', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let indexPattern; diff --git a/src/ui/public/index_patterns/__tests__/_index_pattern.js b/src/ui/public/index_patterns/__tests__/_index_pattern.js index a196d51452ba5..6f394b903df31 100644 --- a/src/ui/public/index_patterns/__tests__/_index_pattern.js +++ b/src/ui/public/index_patterns/__tests__/_index_pattern.js @@ -1,11 +1,11 @@ describe('index pattern', function () { - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var Promise = require('bluebird'); - var errors = require('ui/errors'); - var IndexedArray = require('ui/IndexedArray'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let Promise = require('bluebird'); + let errors = require('ui/errors'); + let IndexedArray = require('ui/IndexedArray'); let IndexPattern; let mapper; let mappingSetup; @@ -13,7 +13,7 @@ describe('index pattern', function () { let DocSource; let config; let docSourceResponse; - var indexPatternId = 'test-pattern'; + let indexPatternId = 'test-pattern'; let indexPattern; let calculateIndices; let $rootScope; @@ -70,7 +70,7 @@ describe('index pattern', function () { // helper function to create index patterns function create(id, payload) { - var indexPattern = new IndexPattern(id); + let indexPattern = new IndexPattern(id); DocSource.prototype.doIndex.returns(Promise.resolve(id)); payload = _.defaults(payload || {}, docSourceResponse(id)); setDocsourcePayload(payload); @@ -123,16 +123,16 @@ describe('index pattern', function () { describe('getScriptedFields', function () { it('should return all scripted fields', function () { - var scriptedNames = _(mockLogstashFields).where({ scripted: true }).pluck('name').value(); - var respNames = _.pluck(indexPattern.getScriptedFields(), 'name'); + let scriptedNames = _(mockLogstashFields).where({ scripted: true }).pluck('name').value(); + let respNames = _.pluck(indexPattern.getScriptedFields(), 'name'); expect(respNames).to.eql(scriptedNames); }); }); describe('getNonScriptedFields', function () { it('should return all non-scripted fields', function () { - var notScriptedNames = _(mockLogstashFields).where({ scripted: false }).pluck('name').value(); - var respNames = _.pluck(indexPattern.getNonScriptedFields(), 'name'); + let notScriptedNames = _(mockLogstashFields).where({ scripted: false }).pluck('name').value(); + let respNames = _.pluck(indexPattern.getNonScriptedFields(), 'name'); expect(respNames).to.eql(notScriptedNames); }); @@ -141,7 +141,7 @@ describe('index pattern', function () { describe('refresh fields', function () { // override the default indexPattern, with a truncated field list require('testUtils/noDigestPromises').activateForSuite(); - var indexPatternId = 'test-pattern'; + let indexPatternId = 'test-pattern'; let indexPattern; let fieldLength; let truncatedFields; @@ -175,8 +175,8 @@ describe('index pattern', function () { indexPattern.refreshFields(), ]) .then(function (data) { - var expected = data[0]; // just the fields in the index - var fields = indexPattern.getNonScriptedFields(); // get all but scripted fields + let expected = data[0]; // just the fields in the index + let fields = indexPattern.getNonScriptedFields(); // get all but scripted fields expect(_.pluck(fields, 'name')).to.eql(_.pluck(expected, 'name')); }); @@ -187,15 +187,15 @@ describe('index pattern', function () { setDocsourcePayload(docSourceResponse(indexPatternId)); // add spy to indexPattern.getScriptedFields - var scriptedFieldsSpy = sinon.spy(indexPattern, 'getScriptedFields'); + let scriptedFieldsSpy = sinon.spy(indexPattern, 'getScriptedFields'); // refresh fields, which will fetch return indexPattern.refreshFields().then(function () { // called to append scripted fields to the response from mapper.getFieldsForIndexPattern expect(scriptedFieldsSpy.callCount).to.equal(1); - var scripted = _.where(mockLogstashFields, { scripted: true }); - var expected = _.filter(indexPattern.fields, { scripted: true }); + let scripted = _.where(mockLogstashFields, { scripted: true }); + let expected = _.filter(indexPattern.fields, { scripted: true }); expect(_.pluck(expected, 'name')).to.eql(_.pluck(scripted, 'name')); }); }); @@ -204,11 +204,11 @@ describe('index pattern', function () { describe('add and remove scripted fields', function () { it('should append the scripted field', function () { // keep a copy of the current scripted field count - var saveSpy = sinon.spy(indexPattern, 'save'); - var oldCount = indexPattern.getScriptedFields().length; + let saveSpy = sinon.spy(indexPattern, 'save'); + let oldCount = indexPattern.getScriptedFields().length; // add a new scripted field - var scriptedField = { + let scriptedField = { name: 'new scripted field', script: 'false', type: 'boolean' @@ -216,17 +216,17 @@ describe('index pattern', function () { indexPattern.addScriptedField(scriptedField.name, scriptedField.script, scriptedField.type); indexPattern._indexFields(); // normally triggered by docSource.onUpdate() - var scriptedFields = indexPattern.getScriptedFields(); + let scriptedFields = indexPattern.getScriptedFields(); expect(saveSpy.callCount).to.equal(1); expect(scriptedFields).to.have.length(oldCount + 1); expect(indexPattern.fields.byName[scriptedField.name].displayName).to.equal(scriptedField.name); }); it('should remove scripted field, by name', function () { - var saveSpy = sinon.spy(indexPattern, 'save'); - var scriptedFields = indexPattern.getScriptedFields(); - var oldCount = scriptedFields.length; - var scriptedField = _.last(scriptedFields); + let saveSpy = sinon.spy(indexPattern, 'save'); + let scriptedFields = indexPattern.getScriptedFields(); + let oldCount = scriptedFields.length; + let scriptedField = _.last(scriptedFields); indexPattern.removeScriptedField(scriptedField.name); @@ -236,8 +236,8 @@ describe('index pattern', function () { }); it('should not allow duplicate names', function () { - var scriptedFields = indexPattern.getScriptedFields(); - var scriptedField = _.last(scriptedFields); + let scriptedFields = indexPattern.getScriptedFields(); + let scriptedField = _.last(scriptedFields); expect(function () { indexPattern.addScriptedField(scriptedField.name, '\'new script\'', 'string'); }).to.throwError(function (e) { @@ -248,9 +248,9 @@ describe('index pattern', function () { describe('popularizeField', function () { it('should increment the poplarity count by default', function () { - var saveSpy = sinon.stub(indexPattern, 'save'); + let saveSpy = sinon.stub(indexPattern, 'save'); indexPattern.fields.forEach(function (field, i) { - var oldCount = field.count; + let oldCount = field.count; indexPattern.popularizeField(field.name); @@ -260,10 +260,10 @@ describe('index pattern', function () { }); it('should increment the poplarity count', function () { - var saveSpy = sinon.stub(indexPattern, 'save'); + let saveSpy = sinon.stub(indexPattern, 'save'); indexPattern.fields.forEach(function (field, i) { - var oldCount = field.count; - var incrementAmount = 4; + let oldCount = field.count; + let incrementAmount = 4; indexPattern.popularizeField(field.name, incrementAmount); @@ -274,9 +274,9 @@ describe('index pattern', function () { it('should decrement the poplarity count', function () { indexPattern.fields.forEach(function (field, i) { - var oldCount = field.count; - var incrementAmount = 4; - var decrementAmount = -2; + let oldCount = field.count; + let incrementAmount = 4; + let decrementAmount = -2; indexPattern.popularizeField(field.name, incrementAmount); indexPattern.popularizeField(field.name, decrementAmount); @@ -287,7 +287,7 @@ describe('index pattern', function () { it('should not go below 0', function () { indexPattern.fields.forEach(function (field) { - var decrementAmount = -Number.MAX_VALUE; + let decrementAmount = -Number.MAX_VALUE; indexPattern.popularizeField(field.name, decrementAmount); expect(field.count).to.equal(0); }); @@ -305,11 +305,11 @@ describe('index pattern', function () { it('invokes interval toDetailedIndexList with given start/stop times', async function () { await indexPattern.toDetailedIndexList(1, 2); - var id = indexPattern.id; + let id = indexPattern.id; expect(intervals.toIndexList.calledWith(id, interval, 1, 2)).to.be(true); }); it('is fulfilled by the result of interval toDetailedIndexList', async function () { - var indexList = await indexPattern.toDetailedIndexList(); + let indexList = await indexPattern.toDetailedIndexList(); expect(indexList[0].index).to.equal('foo'); expect(indexList[1].index).to.equal('bar'); }); @@ -334,13 +334,13 @@ describe('index pattern', function () { it('invokes calculateIndices with given start/stop times and sortOrder', async function () { await indexPattern.toDetailedIndexList(1, 2, 'sortOrder'); - var id = indexPattern.id; - var field = indexPattern.timeFieldName; + let id = indexPattern.id; + let field = indexPattern.timeFieldName; expect(calculateIndices.calledWith(id, field, 1, 2, 'sortOrder')).to.be(true); }); it('is fulfilled by the result of calculateIndices', async function () { - var indexList = await indexPattern.toDetailedIndexList(); + let indexList = await indexPattern.toDetailedIndexList(); expect(indexList[0].index).to.equal('foo'); expect(indexList[1].index).to.equal('bar'); }); @@ -355,7 +355,7 @@ describe('index pattern', function () { }); it('is fulfilled by id', async function () { - var indexList = await indexPattern.toDetailedIndexList(); + let indexList = await indexPattern.toDetailedIndexList(); expect(indexList.index).to.equal(indexPattern.id); }); }); @@ -366,7 +366,7 @@ describe('index pattern', function () { }); it('is fulfilled by id', async function () { - var indexList = await indexPattern.toDetailedIndexList(); + let indexList = await indexPattern.toDetailedIndexList(); expect(indexList.index).to.equal(indexPattern.id); }); }); @@ -384,11 +384,11 @@ describe('index pattern', function () { it('invokes interval toIndexList with given start/stop times', async function () { await indexPattern.toIndexList(1, 2); - var id = indexPattern.id; + let id = indexPattern.id; expect(intervals.toIndexList.calledWith(id, interval, 1, 2)).to.be(true); }); it('is fulfilled by the result of interval toIndexList', async function () { - var indexList = await indexPattern.toIndexList(); + let indexList = await indexPattern.toIndexList(); expect(indexList[0]).to.equal('foo'); expect(indexList[1]).to.equal('bar'); }); @@ -414,13 +414,13 @@ describe('index pattern', function () { it('invokes calculateIndices with given start/stop times and sortOrder', async function () { await indexPattern.toIndexList(1, 2, 'sortOrder'); - var id = indexPattern.id; - var field = indexPattern.timeFieldName; + let id = indexPattern.id; + let field = indexPattern.timeFieldName; expect(calculateIndices.calledWith(id, field, 1, 2, 'sortOrder')).to.be(true); }); it('is fulfilled by the result of calculateIndices', async function () { - var indexList = await indexPattern.toIndexList(); + let indexList = await indexPattern.toIndexList(); expect(indexList[0]).to.equal('foo'); expect(indexList[1]).to.equal('bar'); }); @@ -436,7 +436,7 @@ describe('index pattern', function () { }); it('is fulfilled by id', async function () { - var indexList = await indexPattern.toIndexList(); + let indexList = await indexPattern.toIndexList(); expect(indexList).to.equal(indexPattern.id); }); }); diff --git a/src/ui/public/index_patterns/__tests__/_map_field.js b/src/ui/public/index_patterns/__tests__/_map_field.js index 3fe5461c8dc6d..4f2c4c65904a4 100644 --- a/src/ui/public/index_patterns/__tests__/_map_field.js +++ b/src/ui/public/index_patterns/__tests__/_map_field.js @@ -1,7 +1,7 @@ describe('field mapping normalizer (mapField)', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let fn; let fields; @@ -17,31 +17,31 @@ describe('field mapping normalizer (mapField)', function () { }); it('should return a modified copy of the object, not modify the original', function () { - var pristine = _.cloneDeep(fields['foo.bar']); - var mapped = fn(fields['foo.bar'], 'foo.bar'); + let pristine = _.cloneDeep(fields['foo.bar']); + let mapped = fn(fields['foo.bar'], 'foo.bar'); expect(fields['foo.bar']).to.not.eql(mapped); expect(fields['foo.bar']).to.eql(pristine); }); it('should not consider _id indexed unless it is', function () { - var mapped = fn(fields._id, '_id'); + let mapped = fn(fields._id, '_id'); expect(mapped.indexed).to.be(false); - var mapping = _.cloneDeep(fields._id); + let mapping = _.cloneDeep(fields._id); mapping.mapping._id.index = 'not_analyzed'; - var mapped2 = fn(mapping, '_id'); + let mapped2 = fn(mapping, '_id'); expect(mapped2.indexed).to.be(true); }); it('should always consider _timestamp to be an indexed date', function () { - var mapped = fn(fields._timestamp, '_timestamp'); + let mapped = fn(fields._timestamp, '_timestamp'); expect(mapped.indexed).to.be(true); expect(mapped.type).to.be('date'); }); it('should treat falsy and no as false for index', function () { - var mapped = fn(fields.index_no_field, 'index_no_field'); + let mapped = fn(fields.index_no_field, 'index_no_field'); expect(mapped.indexed).to.be(false); fields.index_no_field.index = false; @@ -50,7 +50,7 @@ describe('field mapping normalizer (mapField)', function () { }); it('should treat other values for index as true', function () { - var mapped = fn(fields.not_analyzed_field, 'not_analyzed_field'); + let mapped = fn(fields.not_analyzed_field, 'not_analyzed_field'); expect(mapped.indexed).to.be(true); }); diff --git a/src/ui/public/index_patterns/__tests__/_pattern_to_wildcard.js b/src/ui/public/index_patterns/__tests__/_pattern_to_wildcard.js index 7450de671725d..4f67defbb5f1c 100644 --- a/src/ui/public/index_patterns/__tests__/_pattern_to_wildcard.js +++ b/src/ui/public/index_patterns/__tests__/_pattern_to_wildcard.js @@ -1,7 +1,7 @@ describe('Index pattern to wildcard', function () { - var fn = require('ui/index_patterns/_pattern_to_wildcard')(); - var expect = require('expect.js'); + let fn = require('ui/index_patterns/_pattern_to_wildcard')(); + let expect = require('expect.js'); it('should be a function', function () { diff --git a/src/ui/public/index_patterns/__tests__/flatten_hit.js b/src/ui/public/index_patterns/__tests__/flatten_hit.js index 533f440bf2340..0bd445ec21176 100644 --- a/src/ui/public/index_patterns/__tests__/flatten_hit.js +++ b/src/ui/public/index_patterns/__tests__/flatten_hit.js @@ -1,9 +1,9 @@ describe('IndexPattern#flattenHit()', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let flattenHit; let config; @@ -12,7 +12,7 @@ describe('IndexPattern#flattenHit()', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - var indexPattern = { + let indexPattern = { fields: { byName: { 'message': { type: 'string' }, diff --git a/src/ui/public/index_patterns/__tests__/intervals.js b/src/ui/public/index_patterns/__tests__/intervals.js index 77983787ca9e5..899552aef3850 100644 --- a/src/ui/public/index_patterns/__tests__/intervals.js +++ b/src/ui/public/index_patterns/__tests__/intervals.js @@ -1,10 +1,10 @@ -var pluck = require('lodash').pluck; -var moment = require('moment'); +let pluck = require('lodash').pluck; +let moment = require('moment'); describe('Index Patterns', function () { describe('interval.toIndexList()', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let intervals; beforeEach(ngMock.module('kibana')); @@ -13,10 +13,10 @@ describe('Index Patterns', function () { })); it('should return correct indices for hourly [logstash-]YYYY.MM.DD.HH', function () { - var start = moment.utc('2014-01-01T07:00:00Z'); - var end = moment.utc('2014-01-01T08:30:00Z'); - var interval = { name: 'hours', startOf: 'hour', display: 'Hourly' }; - var list = intervals.toIndexList('[logstash-]YYYY.MM.DD.HH', interval, start, end); + let start = moment.utc('2014-01-01T07:00:00Z'); + let end = moment.utc('2014-01-01T08:30:00Z'); + let interval = { name: 'hours', startOf: 'hour', display: 'Hourly' }; + let list = intervals.toIndexList('[logstash-]YYYY.MM.DD.HH', interval, start, end); expect(list).to.eql([ { index: 'logstash-2014.01.01.07', @@ -32,10 +32,10 @@ describe('Index Patterns', function () { }); it('should return correct indices for daily [logstash-]YYYY.MM.DD', function () { - var start = moment(1418244231248); - var end = moment(1418849261281); - var interval = { name: 'days', startOf: 'day', display: 'Daily' }; - var list = intervals.toIndexList('[logstash-]YYYY.MM.DD', interval, start, end); + let start = moment(1418244231248); + let end = moment(1418849261281); + let interval = { name: 'days', startOf: 'day', display: 'Daily' }; + let list = intervals.toIndexList('[logstash-]YYYY.MM.DD', interval, start, end); expect(list).to.eql([ { index: 'logstash-2014.12.10', @@ -81,10 +81,10 @@ describe('Index Patterns', function () { }); it('should return correct indices for monthly [logstash-]YYYY.MM', function () { - var start = moment.utc('2014-12-01'); - var end = moment.utc('2015-02-01'); - var interval = { name: 'months', startOf: 'month', display: 'Monthly' }; - var list = intervals.toIndexList('[logstash-]YYYY.MM', interval, start, end); + let start = moment.utc('2014-12-01'); + let end = moment.utc('2015-02-01'); + let interval = { name: 'months', startOf: 'month', display: 'Monthly' }; + let list = intervals.toIndexList('[logstash-]YYYY.MM', interval, start, end); expect(list).to.eql([ { index: 'logstash-2014.12', @@ -105,10 +105,10 @@ describe('Index Patterns', function () { }); it('should return correct indices for yearly [logstash-]YYYY', function () { - var start = moment.utc('2014-12-01'); - var end = moment.utc('2015-02-01'); - var interval = { name: 'years', startOf: 'year', display: 'Yearly' }; - var list = intervals.toIndexList('[logstash-]YYYY', interval, start, end); + let start = moment.utc('2014-12-01'); + let end = moment.utc('2015-02-01'); + let interval = { name: 'years', startOf: 'year', display: 'Yearly' }; + let list = intervals.toIndexList('[logstash-]YYYY', interval, start, end); expect(list).to.eql([ { index: 'logstash-2014', @@ -125,10 +125,10 @@ describe('Index Patterns', function () { context('with sortDirection=asc', function () { it('returns values in ascending order', function () { - var start = moment.utc('2014-12-01'); - var end = moment.utc('2015-02-01'); - var interval = { name: 'years', startOf: 'year', display: 'Yearly' }; - var list = intervals.toIndexList('[logstash-]YYYY', interval, start, end, 'asc'); + let start = moment.utc('2014-12-01'); + let end = moment.utc('2015-02-01'); + let interval = { name: 'years', startOf: 'year', display: 'Yearly' }; + let list = intervals.toIndexList('[logstash-]YYYY', interval, start, end, 'asc'); expect(list).to.eql([ { index: 'logstash-2014', @@ -146,10 +146,10 @@ describe('Index Patterns', function () { context('with sortDirection=desc', function () { it('returns values in descending order', function () { - var start = moment.utc('2014-12-01'); - var end = moment.utc('2015-02-01'); - var interval = { name: 'years', startOf: 'year', display: 'Yearly' }; - var list = intervals.toIndexList('[logstash-]YYYY', interval, start, end, 'desc'); + let start = moment.utc('2014-12-01'); + let end = moment.utc('2015-02-01'); + let interval = { name: 'years', startOf: 'year', display: 'Yearly' }; + let list = intervals.toIndexList('[logstash-]YYYY', interval, start, end, 'desc'); expect(list).to.eql([ { index: 'logstash-2015', diff --git a/src/ui/public/jquery/__tests__/findTestSubject.js b/src/ui/public/jquery/__tests__/findTestSubject.js index 891dbdd81a95d..048e8680138a5 100644 --- a/src/ui/public/jquery/__tests__/findTestSubject.js +++ b/src/ui/public/jquery/__tests__/findTestSubject.js @@ -1,5 +1,5 @@ -var $ = require('jquery'); -var expect = require('expect.js'); +let $ = require('jquery'); +let expect = require('expect.js'); function $make(subject) { return $('
').attr('data-test-subj', subject); @@ -7,42 +7,42 @@ function $make(subject) { describe('jQuery.findTestSubject', function () { it('finds all of the element with a subject', function () { - var $container = $('
'); - var $match = $make('subject').appendTo($container); - var $noMatch = $make('notSubject').appendTo($container); + let $container = $('
'); + let $match = $make('subject').appendTo($container); + let $noMatch = $make('notSubject').appendTo($container); - var $found = $container.findTestSubject('subject'); + let $found = $container.findTestSubject('subject'); expect($found.is($match)).to.be(true); expect($found.is($noMatch)).to.be(false); }); it('finds multiple elements with a subject', function () { - var $container = $('
'); - var $match = $make('subject').appendTo($container); - var $otherMatch = $make('subject').appendTo($container); + let $container = $('
'); + let $match = $make('subject').appendTo($container); + let $otherMatch = $make('subject').appendTo($container); - var $found = $container.findTestSubject('subject'); + let $found = $container.findTestSubject('subject'); expect($found.filter($match).size()).to.be(1); expect($found.filter($otherMatch).size()).to.be(1); }); it('finds all of the elements with either subject', function () { - var $container = $('
'); - var $match1 = $make('subject').appendTo($container); - var $match2 = $make('alsoSubject').appendTo($container); - var $noMatch = $make('notSubject').appendTo($container); + let $container = $('
'); + let $match1 = $make('subject').appendTo($container); + let $match2 = $make('alsoSubject').appendTo($container); + let $noMatch = $make('notSubject').appendTo($container); - var $found = $container.findTestSubject('subject', 'alsoSubject'); + let $found = $container.findTestSubject('subject', 'alsoSubject'); expect($found.filter($match1).size()).to.be(1); expect($found.filter($match2).size()).to.be(1); expect($found.filter($noMatch).size()).to.be(0); }); it('finds all of the elements with a decendant selector', function () { - var $container = $('
'); - var $parent = $make('foo name').appendTo($container); - var $bar = $make('bar othername').appendTo($parent); - var $baz = $make('baz third name').appendTo($parent); + let $container = $('
'); + let $parent = $make('foo name').appendTo($container); + let $bar = $make('bar othername').appendTo($parent); + let $baz = $make('baz third name').appendTo($parent); expect($container.findTestSubject('foo bar').is($bar)).to.be(true); expect($container.findTestSubject('foo bar').is($baz)).to.be(false); @@ -52,9 +52,9 @@ describe('jQuery.findTestSubject', function () { }); it('finds elements with compound subjects', function () { - var $container = $('
'); - var $bar = $make('button bar').appendTo($container); - var $baz = $make('button baz').appendTo($container); + let $container = $('
'); + let $bar = $make('button bar').appendTo($container); + let $baz = $make('button baz').appendTo($container); expect($container.findTestSubject('button&bar').is($bar)).to.be(true); expect($container.findTestSubject('button& bar').is($bar)).to.be(true); diff --git a/src/ui/public/listen/__tests__/listen.js b/src/ui/public/listen/__tests__/listen.js index 70ff8aa6ef079..5dfa598acabee 100644 --- a/src/ui/public/listen/__tests__/listen.js +++ b/src/ui/public/listen/__tests__/listen.js @@ -1,8 +1,8 @@ describe('listen component', function () { - var sinon = require('auto-release-sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let sinon = require('auto-release-sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let $rootScope; let Events; @@ -21,8 +21,8 @@ describe('listen component', function () { }); it('binds to an event emitter', function () { - var emitter = new Events(); - var $scope = $rootScope.$new(); + let emitter = new Events(); + let $scope = $rootScope.$new(); function handler() {} $scope.$listen(emitter, 'hello', handler); @@ -32,8 +32,8 @@ describe('listen component', function () { }); it('binds to $scope, waiting for the destroy event', function () { - var emitter = new Events(); - var $scope = $rootScope.$new(); + let emitter = new Events(); + let $scope = $rootScope.$new(); sinon.stub($scope, '$on'); sinon.stub($rootScope, '$on'); @@ -44,14 +44,14 @@ describe('listen component', function () { expect($rootScope.$on).to.have.property('callCount', 0); expect($scope.$on).to.have.property('callCount', 1); - var call = $scope.$on.firstCall; + let call = $scope.$on.firstCall; expect(call.args[0]).to.be('$destroy'); expect(call.args[1]).to.be.a('function'); }); it('unbinds the event handler when $destroy is triggered', function () { - var emitter = new Events(); - var $scope = $rootScope.$new(); + let emitter = new Events(); + let $scope = $rootScope.$new(); sinon.stub($scope, '$on'); sinon.stub(emitter, 'off'); @@ -61,7 +61,7 @@ describe('listen component', function () { $scope.$listen(emitter, 'hello', handler); // get the unbinder that was registered to $scope - var unbinder = $scope.$on.firstCall.args[1]; + let unbinder = $scope.$on.firstCall.args[1]; // call the unbinder expect(emitter.off).to.have.property('callCount', 0); @@ -69,7 +69,7 @@ describe('listen component', function () { expect(emitter.off).to.have.property('callCount', 1); // check that the off args were as expected - var call = emitter.off.firstCall; + let call = emitter.off.firstCall; expect(call.args[0]).to.be('hello'); expect(call.args[1]).to.be(handler); }); diff --git a/src/ui/public/notify/__tests__/lib/_format_es_msg.js b/src/ui/public/notify/__tests__/lib/_format_es_msg.js index 6a2668332692d..5a91514b4ba1e 100644 --- a/src/ui/public/notify/__tests__/lib/_format_es_msg.js +++ b/src/ui/public/notify/__tests__/lib/_format_es_msg.js @@ -1,25 +1,25 @@ describe('formatESMsg', function () { - var formatESMsg = require('ui/notify/lib/_format_es_msg'); - var expect = require('expect.js'); + let formatESMsg = require('ui/notify/lib/_format_es_msg'); + let expect = require('expect.js'); it('should return undefined if passed a basic error', function () { - var err = new Error('This is a normal error'); + let err = new Error('This is a normal error'); - var actual = formatESMsg(err); + let actual = formatESMsg(err); expect(actual).to.be(undefined); }); it('should return undefined if passed a string', function () { - var err = 'This is a error string'; + let err = 'This is a error string'; - var actual = formatESMsg(err); + let actual = formatESMsg(err); expect(actual).to.be(undefined); }); it('should return the root_cause if passed an extended elasticsearch', function () { - var err = new Error('This is an elasticsearch error'); + let err = new Error('This is an elasticsearch error'); err.resp = { error : { root_cause : [ @@ -30,13 +30,13 @@ describe('formatESMsg', function () { } }; - var actual = formatESMsg(err); + let actual = formatESMsg(err); expect(actual).to.equal('I am the detailed message'); }); it('should combine the reason messages if more than one is returned.', function () { - var err = new Error('This is an elasticsearch error'); + let err = new Error('This is an elasticsearch error'); err.resp = { error : { root_cause : [ @@ -50,7 +50,7 @@ describe('formatESMsg', function () { } }; - var actual = formatESMsg(err); + let actual = formatESMsg(err); expect(actual).to.equal('I am the detailed message 1\nI am the detailed message 2'); }); diff --git a/src/ui/public/notify/__tests__/lib/_format_msg.js b/src/ui/public/notify/__tests__/lib/_format_msg.js index 8961509db5acc..1bb74d353631e 100644 --- a/src/ui/public/notify/__tests__/lib/_format_msg.js +++ b/src/ui/public/notify/__tests__/lib/_format_msg.js @@ -1,28 +1,28 @@ describe('formatMsg', function () { - var formatMsg = require('ui/notify/lib/_format_msg'); - var expect = require('expect.js'); + let formatMsg = require('ui/notify/lib/_format_msg'); + let expect = require('expect.js'); it('should prepend the second argument to result', function () { - var actual = formatMsg('error message', 'unit_test'); + let actual = formatMsg('error message', 'unit_test'); expect(actual).to.equal('unit_test: error message'); }); it('should handle a simple string', function () { - var actual = formatMsg('error message'); + let actual = formatMsg('error message'); expect(actual).to.equal('error message'); }); it('should handle a simple Error object', function () { - var err = new Error('error message'); - var actual = formatMsg(err); + let err = new Error('error message'); + let actual = formatMsg(err); expect(actual).to.equal('error message'); }); it('should handle a simple Angular $http error object', function () { - var err = { + let err = { data: { statusCode: 403, error: 'Forbidden', @@ -32,13 +32,13 @@ describe('formatMsg', function () { config: {}, statusText: 'Forbidden' }; - var actual = formatMsg(err); + let actual = formatMsg(err); expect(actual).to.equal('Error 403 Forbidden: [security_exception] action [indices:data/read/mget] is unauthorized for user [user]'); }); it('should handle an extended elasticsearch error', function () { - var err = { + let err = { resp : { error : { root_cause : [ @@ -50,7 +50,7 @@ describe('formatMsg', function () { } }; - var actual = formatMsg(err); + let actual = formatMsg(err); expect(actual).to.equal('I am the detailed message'); }); diff --git a/src/ui/public/notify/__tests__/notifier.js b/src/ui/public/notify/__tests__/notifier.js index f2c084b2c4579..1d0e5290c9120 100644 --- a/src/ui/public/notify/__tests__/notifier.js +++ b/src/ui/public/notify/__tests__/notifier.js @@ -1,14 +1,14 @@ describe('Notifier', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var Notifier = require('ui/notify/notifier'); + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let Notifier = require('ui/notify/notifier'); - var message = 'Oh, the humanity!'; + let message = 'Oh, the humanity!'; let notifier; let params; - var version = window.__KBN__.version; - var buildNum = window.__KBN__.buildNum; + let version = window.__KBN__.version; + let buildNum = window.__KBN__.buildNum; beforeEach(ngMock.module('kibana')); @@ -48,12 +48,12 @@ describe('Notifier', function () { }); it('allows reporting', function () { - var includesReport = _.includes(notify('error').actions, 'report'); + let includesReport = _.includes(notify('error').actions, 'report'); expect(includesReport).to.true; }); it('allows accepting', function () { - var includesAccept = _.includes(notify('error').actions, 'accept'); + let includesAccept = _.includes(notify('error').actions, 'accept'); expect(includesAccept).to.true; }); @@ -86,12 +86,12 @@ describe('Notifier', function () { }); it('does not allow reporting', function () { - var includesReport = _.includes(notify('warning').actions, 'report'); + let includesReport = _.includes(notify('warning').actions, 'report'); expect(includesReport).to.false; }); it('allows accepting', function () { - var includesAccept = _.includes(notify('warning').actions, 'accept'); + let includesAccept = _.includes(notify('warning').actions, 'accept'); expect(includesAccept).to.true; }); @@ -124,12 +124,12 @@ describe('Notifier', function () { }); it('does not allow reporting', function () { - var includesReport = _.includes(notify('info').actions, 'report'); + let includesReport = _.includes(notify('info').actions, 'report'); expect(includesReport).to.false; }); it('allows accepting', function () { - var includesAccept = _.includes(notify('info').actions, 'accept'); + let includesAccept = _.includes(notify('info').actions, 'accept'); expect(includesAccept).to.true; }); @@ -150,13 +150,13 @@ describe('Notifier', function () { function testVersionInfo(fnName) { context('when version is configured', function () { it('adds version to notification', function () { - var notification = notify(fnName); + let notification = notify(fnName); expect(notification.info.version).to.equal(version); }); }); context('when build number is configured', function () { it('adds buildNum to notification', function () { - var notification = notify(fnName); + let notification = notify(fnName); expect(notification.info.buildNum).to.equal(buildNum); }); }); diff --git a/src/ui/public/paginated_table/__tests__/index.js b/src/ui/public/paginated_table/__tests__/index.js index 34feb6982a436..a89ab8ad283ef 100644 --- a/src/ui/public/paginated_table/__tests__/index.js +++ b/src/ui/public/paginated_table/__tests__/index.js @@ -1,10 +1,10 @@ require('ui/paginated_table'); -var _ = require('lodash'); -var $ = require('jquery'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('paginated table', function () { let $el; @@ -13,11 +13,11 @@ describe('paginated table', function () { let $scope; let $elScope; let $orderBy; - var defaultPerPage = 10; + let defaultPerPage = 10; - var makeData = function (colCount, rowCount) { - var columns = []; - var rows = []; + let makeData = function (colCount, rowCount) { + let columns = []; + let rows = []; if (_.isNumber(colCount)) { _.times(colCount, function (i) { @@ -29,7 +29,7 @@ describe('paginated table', function () { if (_.isNumber(rowCount)) { _.times(rowCount, function (col) { - var rowItems = []; + let rowItems = []; _.times(columns.length, function (row) { rowItems.push('item' + col + row); @@ -47,7 +47,7 @@ describe('paginated table', function () { }; }; - var renderTable = function (cols, rows, perPage) { + let renderTable = function (cols, rows, perPage) { $scope.cols = cols || []; $scope.rows = rows || []; $scope.perPage = perPage || defaultPerPage; @@ -67,23 +67,23 @@ describe('paginated table', function () { describe('rendering', function () { it('should not display without rows', function () { - var cols = [{ + let cols = [{ title: 'test1' }]; - var rows = []; + let rows = []; renderTable(cols, rows); expect($el.children().size()).to.be(0); }); it('should render columns and rows', function () { - var data = makeData(2, 2); - var cols = data.columns; - var rows = data.rows; + let data = makeData(2, 2); + let cols = data.columns; + let rows = data.rows; renderTable(cols, rows); expect($el.children().size()).to.be(1); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); // should pad rows expect(tableRows.size()).to.be(defaultPerPage); // should contain the row data @@ -95,13 +95,13 @@ describe('paginated table', function () { it('should paginate rows', function () { // note: paginate truncates pages, so don't make too many - var rowCount = _.random(16, 24); - var perPageCount = _.random(5, 8); - var data = makeData(3, rowCount); - var pageCount = Math.ceil(rowCount / perPageCount); + let rowCount = _.random(16, 24); + let perPageCount = _.random(5, 8); + let data = makeData(3, rowCount); + let pageCount = Math.ceil(rowCount / perPageCount); renderTable(data.columns, data.rows, perPageCount); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.size()).to.be(perPageCount); // add 2 for the first and last page links expect($el.find('paginate-controls a').size()).to.be(pageCount + 2); @@ -131,7 +131,7 @@ describe('paginated table', function () { // }); it('should not sort by default', function () { - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be(data.rows[0][0]); expect(tableRows.eq(lastRowIndex).find('td').eq(0).text()).to.be(data.rows[lastRowIndex][0]); }); @@ -141,7 +141,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(999); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('bbbb'); expect(tableRows.eq(0).find('td').eq(1).text()).to.be('aaaa'); expect(tableRows.eq(0).find('td').eq(2).text()).to.be('zzzz'); @@ -154,7 +154,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(0); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('bbbb'); expect(tableRows.eq(0).find('td').eq(1).text()).to.be('aaaa'); expect(tableRows.eq(0).find('td').eq(2).text()).to.be('zzzz'); @@ -165,7 +165,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(0); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('aaaa'); expect(tableRows.eq(lastRowIndex).find('td').eq(0).text()).to.be('zzzz'); }); @@ -176,7 +176,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(0); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('zzzz'); expect(tableRows.eq(lastRowIndex).find('td').eq(0).text()).to.be('aaaa'); }); @@ -188,7 +188,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(0); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be(data.rows[0][0]); expect(tableRows.eq(lastRowIndex).find('td').eq(0).text()).to.be('aaaa'); }); @@ -202,7 +202,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(1); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(1).text()).to.be('aaaa'); expect(tableRows.eq(lastRowIndex).find('td').eq(1).text()).to.be('zzzz'); }); @@ -212,15 +212,15 @@ describe('paginated table', function () { describe('sorting duplicate columns', function () { let data; let paginatedTable; - var colText = 'test row'; + let colText = 'test row'; beforeEach(function () { - var cols = [ + let cols = [ { title: colText }, { title: colText }, { title: colText } ]; - var rows = [ + let rows = [ ['bbbb', 'aaaa', 'zzzz'], ['cccc', 'cccc', 'aaaa'], ['zzzz', 'bbbb', 'bbbb'], @@ -233,7 +233,7 @@ describe('paginated table', function () { }); it('should have duplicate column titles', function () { - var columns = $el.find('thead th span'); + let columns = $el.find('thead th span'); columns.each(function () { expect($(this).text()).to.be(colText); }); @@ -244,7 +244,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(2); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('cccc'); expect(tableRows.eq(0).find('td').eq(1).text()).to.be('cccc'); expect(tableRows.eq(0).find('td').eq(2).text()).to.be('aaaa'); @@ -258,7 +258,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(2); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('td').eq(0).text()).to.be('cccc'); expect(tableRows.eq(0).find('td').eq(1).text()).to.be('cccc'); expect(tableRows.eq(0).find('td').eq(2).text()).to.be('aaaa'); @@ -281,7 +281,7 @@ describe('paginated table', function () { paginatedTable.sortColumn(1); $scope.$digest(); - var sorters = $el.find('thead th i'); + let sorters = $el.find('thead th i'); expect(sorters.eq(0).hasClass('fa-sort')).to.be(true); expect(sorters.eq(1).hasClass('fa-sort')).to.be(false); expect(sorters.eq(2).hasClass('fa-sort')).to.be(true); @@ -311,7 +311,7 @@ describe('paginated table', function () { // TODO: This is failing randomly it('should allow custom sorting handler', function () { - var columnIndex = 1; + let columnIndex = 1; paginatedTable.sortColumn(columnIndex); $scope.$digest(); expect(sortHandler.callCount).to.be(1); @@ -341,7 +341,7 @@ describe('paginated table', function () { }); it('should append object markup', function () { - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('h1').size()).to.be(0); expect(tableRows.eq(1).find('h1').size()).to.be(1); expect(tableRows.eq(2).find('h1').size()).to.be(0); @@ -350,7 +350,7 @@ describe('paginated table', function () { it('should sort using object value', function () { paginatedTable.sortColumn(0); $scope.$digest(); - var tableRows = $el.find('tbody tr'); + let tableRows = $el.find('tbody tr'); expect(tableRows.eq(0).find('h1').size()).to.be(0); expect(tableRows.eq(1).find('h1').size()).to.be(0); // html row should be the last row diff --git a/src/ui/public/persisted_log/__tests__/persisted_log.js b/src/ui/public/persisted_log/__tests__/persisted_log.js index 535844649f75d..d62cbfbbf5435 100644 --- a/src/ui/public/persisted_log/__tests__/persisted_log.js +++ b/src/ui/public/persisted_log/__tests__/persisted_log.js @@ -1,15 +1,15 @@ -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let storage; let config; let PersistedLog; -var historyName = 'testHistory'; -var historyLimit = 10; -var payload = [ +let historyName = 'testHistory'; +let historyLimit = 10; +let payload = [ { first: 'clark', last: 'kent' }, { first: 'peter', last: 'parker' }, { first: 'bruce', last: 'wayne' } @@ -41,7 +41,7 @@ describe('PersistedLog', function () { describe('expected API', function () { it('has expected methods', function () { - var log = new PersistedLog(historyName); + let log = new PersistedLog(historyName); expect(log.add).to.be.a('function'); expect(log.get).to.be.a('function'); @@ -50,17 +50,17 @@ describe('PersistedLog', function () { describe('internal functionality', function () { it('reads from storage', function () { - var log = new PersistedLog(historyName); + let log = new PersistedLog(historyName); expect(storage.get.calledOnce).to.be(true); expect(storage.get.calledWith(historyName)).to.be(true); }); it('writes to storage', function () { - var log = new PersistedLog(historyName); - var newItem = { first: 'diana', last: 'prince' }; + let log = new PersistedLog(historyName); + let newItem = { first: 'diana', last: 'prince' }; - var data = log.add(newItem); + let data = log.add(newItem); expect(storage.set.calledOnce).to.be(true); expect(data).to.eql([newItem]); @@ -70,19 +70,19 @@ describe('PersistedLog', function () { describe('persisting data', function () { it('fetches records from storage', function () { storage.get.returns(payload); - var log = new PersistedLog(historyName); + let log = new PersistedLog(historyName); - var items = log.get(); + let items = log.get(); expect(items.length).to.equal(3); expect(items).to.eql(payload); }); it('prepends new records', function () { storage.get.returns(payload.slice(0)); - var log = new PersistedLog(historyName); - var newItem = { first: 'selina', last: 'kyle' }; + let log = new PersistedLog(historyName); + let newItem = { first: 'selina', last: 'kyle' }; - var items = log.add(newItem); + let items = log.add(newItem); expect(items.length).to.equal(payload.length + 1); expect(items[0]).to.eql(newItem); }); @@ -90,26 +90,26 @@ describe('PersistedLog', function () { describe('stack options', function () { it('should observe the maxLength option', function () { - var bulkData = []; + let bulkData = []; - for (var i = 0; i < historyLimit; i++) { + for (let i = 0; i < historyLimit; i++) { bulkData.push(['record ' + i]); } storage.get.returns(bulkData); - var log = new PersistedLog(historyName, { maxLength: historyLimit }); + let log = new PersistedLog(historyName, { maxLength: historyLimit }); log.add(['new array 1']); - var items = log.add(['new array 2']); + let items = log.add(['new array 2']); expect(items.length).to.equal(historyLimit); }); it('should observe the filterDuplicates option', function () { storage.get.returns(payload.slice(0)); - var log = new PersistedLog(historyName, { filterDuplicates: true }); - var newItem = payload[1]; + let log = new PersistedLog(historyName, { filterDuplicates: true }); + let newItem = payload[1]; - var items = log.add(newItem); + let items = log.add(newItem); expect(items.length).to.equal(payload.length); }); diff --git a/src/ui/public/persisted_state/__tests__/persisted_state.js b/src/ui/public/persisted_state/__tests__/persisted_state.js index 0820f5b1f244a..a03761bb21507 100644 --- a/src/ui/public/persisted_state/__tests__/persisted_state.js +++ b/src/ui/public/persisted_state/__tests__/persisted_state.js @@ -1,9 +1,9 @@ -var _ = require('lodash'); -var sinon = require('auto-release-sinon'); -var noDigestPromises = require('testUtils/noDigestPromises'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); -var errors = require('ui/errors'); +let _ = require('lodash'); +let sinon = require('auto-release-sinon'); +let noDigestPromises = require('testUtils/noDigestPromises'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); +let errors = require('ui/errors'); let PersistedState; let Events; @@ -34,7 +34,7 @@ describe('Persisted State', function () { }); it('should create a state instance with data', function () { - var val = { red: 'blue' }; + let val = { red: 'blue' }; persistedState = new PersistedState(val); expect(persistedState.get()).to.eql(val); @@ -43,7 +43,7 @@ describe('Persisted State', function () { }); it('should create a copy of the state passed in', function () { - var val = { red: 'blue' }; + let val = { red: 'blue' }; persistedState = new PersistedState(val); expect(persistedState.get()).to.eql(val); @@ -51,10 +51,10 @@ describe('Persisted State', function () { }); it('should not throw if creating valid child object', function () { - var run = function () { - var val = { red: 'blue' }; - var path = ['test.path']; - var parent = new PersistedState(); + let run = function () { + let val = { red: 'blue' }; + let path = ['test.path']; + let parent = new PersistedState(); new PersistedState(val, path, parent); }; @@ -62,8 +62,8 @@ describe('Persisted State', function () { }); it('should throw if given an invalid value', function () { - var run = function () { - var val = 'bananas'; + let run = function () { + let val = 'bananas'; new PersistedState(val); }; @@ -73,10 +73,10 @@ describe('Persisted State', function () { }); it('should not throw if given primitive to child', function () { - var run = function () { - var val = 'bananas'; - var path = ['test.path']; - var parent = new PersistedState(); + let run = function () { + let val = 'bananas'; + let path = ['test.path']; + let parent = new PersistedState(); new PersistedState(val, path, parent); }; @@ -84,10 +84,10 @@ describe('Persisted State', function () { }); it('should throw if given an invalid parent object', function () { - var run = function () { - var val = { red: 'blue' }; - var path = ['test.path']; - var parent = {}; + let run = function () { + let val = { red: 'blue' }; + let path = ['test.path']; + let parent = {}; new PersistedState(val, path, parent); }; @@ -97,10 +97,10 @@ describe('Persisted State', function () { }); it('should throw if given a parent without a path', function () { - var run = function () { - var val = { red: 'blue' }; + let run = function () { + let val = { red: 'blue' }; let path; - var parent = new PersistedState(); + let parent = new PersistedState(); new PersistedState(val, path, parent); }; @@ -115,8 +115,8 @@ describe('Persisted State', function () { let childState; it('should not append the child state to the parent, without parent value', function () { - var childIndex = 'i can haz child'; - var persistedState = new PersistedState(); + let childIndex = 'i can haz child'; + let persistedState = new PersistedState(); childState = persistedState.createChild(childIndex); // parent state should not contain the child state @@ -125,9 +125,9 @@ describe('Persisted State', function () { }); it('should not append the child state to the parent, with parent value', function () { - var childIndex = 'i can haz child'; - var persistedStateValue = { original: true }; - var persistedState = new PersistedState(persistedStateValue); + let childIndex = 'i can haz child'; + let persistedStateValue = { original: true }; + let persistedState = new PersistedState(persistedStateValue); childState = persistedState.createChild(childIndex); // child state should be empty, we didn't give it any default data @@ -139,14 +139,14 @@ describe('Persisted State', function () { }); it('should append the child state to the parent, with parent and child values', function () { - var childIndex = 'i can haz child'; - var childStateValue = { tacos: 'yes please' }; - var persistedStateValue = { original: true }; - var persistedState = new PersistedState(persistedStateValue); + let childIndex = 'i can haz child'; + let childStateValue = { tacos: 'yes please' }; + let persistedStateValue = { original: true }; + let persistedState = new PersistedState(persistedStateValue); childState = persistedState.createChild(childIndex, childStateValue); // parent state should contain the child and its original state value - var parentState = persistedState.get(); + let parentState = persistedState.get(); expect(parentState).to.have.property('original', true); expect(parentState).to.have.property(childIndex); expect(parentState[childIndex]).to.eql(childStateValue); @@ -155,15 +155,15 @@ describe('Persisted State', function () { describe('deep child state creation', function () { it('should delegate get/set calls to parent state', function () { - var children = [{ + let children = [{ path: 'first*child', value: { first: true, second: false } }, { path: 'second child', value: { first: false, second: true } }]; - var persistedStateValue = { original: true }; - var persistedState = new PersistedState(persistedStateValue); + let persistedStateValue = { original: true }; + let persistedState = new PersistedState(persistedStateValue); // first child is a child of the parent persistedState children[0].instance = persistedState.createChild(children[0].path, children[0].value); @@ -174,7 +174,7 @@ describe('Persisted State', function () { expect(children[1].instance.get()).to.eql(children[1].value); // parent should contain original props and first child path, but not the second child path - var parentState = persistedState.get(); + let parentState = persistedState.get(); _.keys(persistedStateValue).forEach(function (key) { expect(parentState).to.have.property(key); }); @@ -182,28 +182,28 @@ describe('Persisted State', function () { expect(parentState).to.not.have.property(children[1].path); // second child path should be inside the first child - var firstChildState = children[0].instance.get(); + let firstChildState = children[0].instance.get(); expect(firstChildState).to.have.property(children[1].path); expect(firstChildState[children[1].path]).to.eql(children[1].value); // check that the second child is still accessible from the parent instance - var firstChild = persistedState.get(children[0].path); + let firstChild = persistedState.get(children[0].path); expect(firstChild).to.have.property(children[1].path); }); }); describe('child state removal', function () { it('should clear path from parent state', function () { - var persistedState = new PersistedState(); - var childState = persistedState.createChild('child', { userId: 1234 }); + let persistedState = new PersistedState(); + let childState = persistedState.createChild('child', { userId: 1234 }); expect(persistedState.get()).to.eql({ child: { userId: 1234 }}); persistedState.removeChild('child'); expect(persistedState.get()).to.eql({}); }); it('should reset original parent value at path', function () { - var persistedState = new PersistedState({ user: 1234 }); - var childState = persistedState.createChild('user', { id: 5678 }); + let persistedState = new PersistedState({ user: 1234 }); + let childState = persistedState.createChild('user', { id: 5678 }); expect(persistedState.get()).to.eql({ user: { id: 5678 }}); persistedState.removeChild('user'); @@ -211,8 +211,8 @@ describe('Persisted State', function () { }); it('should clear changedState', function () { - var persistedState = new PersistedState({ user: 1234 }); - var childState = persistedState.createChild('user'); + let persistedState = new PersistedState({ user: 1234 }); + let childState = persistedState.createChild('user'); childState.set('name', 'user name'); expect(persistedState.getChanges()).to.eql({ user: { name: 'user name' }}); @@ -223,16 +223,16 @@ describe('Persisted State', function () { describe('deep child state removal', function () { it('should clear path from parent state', function () { - var persistedState = new PersistedState(); - var childState = persistedState.createChild('child.state', { userId: 1234 }); + let persistedState = new PersistedState(); + let childState = persistedState.createChild('child.state', { userId: 1234 }); expect(persistedState.get()).to.eql({ child: { state: { userId: 1234 }}}); persistedState.removeChild('child.state'); expect(persistedState.get()).to.eql({}); }); it('should reset original parent value at path', function () { - var persistedState = new PersistedState({ user: { id: 1234 }}); - var childState = persistedState.createChild('user.id', 5678); + let persistedState = new PersistedState({ user: { id: 1234 }}); + let childState = persistedState.createChild('user.id', 5678); expect(persistedState.get()).to.eql({ user: { id: 5678 }}); persistedState.removeChild('user.id'); @@ -240,8 +240,8 @@ describe('Persisted State', function () { }); it('should reset original parent other values at path', function () { - var persistedState = new PersistedState({ user: { name: 'user' }}); - var childState = persistedState.createChild('user.id', 5678); + let persistedState = new PersistedState({ user: { name: 'user' }}); + let childState = persistedState.createChild('user.id', 5678); expect(persistedState.get()).to.eql({ user: { name: 'user', id: 5678 }}); persistedState.removeChild('user.id'); @@ -249,8 +249,8 @@ describe('Persisted State', function () { }); it('should clear the changed state', function () { - var persistedState = new PersistedState({ user: { id: 1234 }}); - var childState = persistedState.createChild('user.name'); + let persistedState = new PersistedState({ user: { id: 1234 }}); + let childState = persistedState.createChild('user.name'); childState.set('user name'); expect(persistedState.getChanges()).to.eql({ user: { name: 'user name' }}); @@ -262,8 +262,8 @@ describe('Persisted State', function () { describe('child state conditions', function () { it('should be merged with the parent state', function () { - var parent = new PersistedState({ name: 'test' }); - var child = parent.createChild('child', 'value'); + let parent = new PersistedState({ name: 'test' }); + let child = parent.createChild('child', 'value'); expect(parent.get()).to.eql({ name: 'test', child: 'value' @@ -283,8 +283,8 @@ describe('Persisted State', function () { }); it('should give child state precedence', function () { - var parent = new PersistedState({ user: { id: 1234, name: 'test' }}); - var child = parent.createChild('user', { name: 'child test' }); + let parent = new PersistedState({ user: { id: 1234, name: 'test' }}); + let child = parent.createChild('user', { name: 'child test' }); expect(parent.get()).to.eql({ user: { id: 1234, @@ -297,8 +297,8 @@ describe('Persisted State', function () { }); it('should be cleaned up with removeChild', function () { - var parent = new PersistedState({ name: 'test' }); - var child = parent.createChild('child', 'value'); + let parent = new PersistedState({ name: 'test' }); + let child = parent.createChild('child', 'value'); expect(parent.get()).to.eql({ name: 'test', child: 'value' @@ -313,16 +313,16 @@ describe('Persisted State', function () { describe('colliding child paths and parent state values', function () { it('should not change the child path value by default', function () { - var childIndex = 'childTest'; - var persistedStateValue = {}; + let childIndex = 'childTest'; + let persistedStateValue = {}; persistedStateValue[childIndex] = { overlapping_index: true }; - var persistedState = new PersistedState(persistedStateValue); - var state = persistedState.get(); + let persistedState = new PersistedState(persistedStateValue); + let state = persistedState.get(); expect(state).to.have.property(childIndex); expect(state[childIndex]).to.eql(persistedStateValue[childIndex]); - var childState = persistedState.createChild(childIndex); + let childState = persistedState.createChild(childIndex); expect(childState.get()).to.eql(persistedStateValue[childIndex]); // make sure the parent state is still the same @@ -332,21 +332,21 @@ describe('Persisted State', function () { }); it('should merge default child state', function () { - var childIndex = 'childTest'; - var childStateValue = { child_index: false }; - var persistedStateValue = {}; + let childIndex = 'childTest'; + let childStateValue = { child_index: false }; + let persistedStateValue = {}; persistedStateValue[childIndex] = { parent_index: true }; - var persistedState = new PersistedState(persistedStateValue); - var state = persistedState.get(); + let persistedState = new PersistedState(persistedStateValue); + let state = persistedState.get(); expect(state).to.have.property(childIndex); expect(state[childIndex]).to.eql(persistedStateValue[childIndex]); // pass in child state value - var childState = persistedState.createChild(childIndex, childStateValue); + let childState = persistedState.createChild(childIndex, childStateValue); // parent's default state is merged with child state - var compare = _.merge({}, childStateValue, persistedStateValue[childIndex]); + let compare = _.merge({}, childStateValue, persistedStateValue[childIndex]); expect(childState.get()).to.eql(compare); state = persistedState.get(); expect(state).to.have.property(childIndex); @@ -356,11 +356,11 @@ describe('Persisted State', function () { describe('mutation', function () { it('should not mutate the internal object', function () { - var persistedStateValue = { hello: 'world' }; - var insertedObj = { farewell: 'cruel world' }; - var persistedState = new PersistedState(persistedStateValue); + let persistedStateValue = { hello: 'world' }; + let insertedObj = { farewell: 'cruel world' }; + let persistedState = new PersistedState(persistedStateValue); - var obj = persistedState.get(); + let obj = persistedState.get(); _.assign(obj, insertedObj); expect(obj).to.have.property('farewell'); @@ -377,38 +377,38 @@ describe('Persisted State', function () { describe('exporting state to JSON', function () { it('should return the full JSON representation', function () { - var persistedState = new PersistedState(persistedStateValue); + let persistedState = new PersistedState(persistedStateValue); - var json = persistedState.toJSON(); + let json = persistedState.toJSON(); expect(json).to.eql(persistedStateValue); }); it('should return the JSON representation of the child state', function () { - var persistedState = new PersistedState(persistedStateValue); - var childState = persistedState.createChild('awesome', { pants: false }); + let persistedState = new PersistedState(persistedStateValue); + let childState = persistedState.createChild('awesome', { pants: false }); expect(childState.toJSON()).to.eql({ pants: false }); // verify JSON output of the parent state - var parentCompare = _.assign({ awesome: { pants: false }}, persistedStateValue); + let parentCompare = _.assign({ awesome: { pants: false }}, persistedStateValue); expect(persistedState.toJSON()).to.eql(parentCompare); }); it('should export stringified version of state', function () { - var persistedState = new PersistedState(persistedStateValue); - var childState = persistedState.createChild('awesome', { pants: false }); + let persistedState = new PersistedState(persistedStateValue); + let childState = persistedState.createChild('awesome', { pants: false }); - var data = childState.toString(); + let data = childState.toString(); expect(JSON.parse(data)).to.eql({ pants: false }); // verify JSON output of the parent state - var parentCompare = _.assign({ awesome: { pants: false }}, persistedStateValue); + let parentCompare = _.assign({ awesome: { pants: false }}, persistedStateValue); expect(JSON.parse(persistedState.toString())).to.eql(parentCompare); }); }); describe('importing state from JSON string (hydration)', function () { it('should set the state from JSON string input', function () { - var stateJSON = JSON.stringify(persistedStateValue); - var persistedState = new PersistedState(); + let stateJSON = JSON.stringify(persistedStateValue); + let persistedState = new PersistedState(); expect(persistedState.get()).to.eql({}); persistedState.fromString(stateJSON); @@ -419,7 +419,7 @@ describe('Persisted State', function () { describe('get state', function () { it('should perform deep gets with various formats', function () { - var obj = { + let obj = { red: { green: { blue: 'yellow' @@ -430,7 +430,7 @@ describe('Persisted State', function () { violet: '' } }; - var persistedState = new PersistedState(obj); + let persistedState = new PersistedState(obj); expect(persistedState.get()).to.eql(obj); expect(persistedState.get('red')).to.eql({ green: { blue: 'yellow' } }); @@ -449,7 +449,7 @@ describe('Persisted State', function () { }); it('should perform deep gets with arrays', function () { - var persistedState = new PersistedState({ hello: { nouns: ['world', 'humans', 'everyone'] } }); + let persistedState = new PersistedState({ hello: { nouns: ['world', 'humans', 'everyone'] } }); expect(persistedState.get()).to.eql({ hello: { nouns: ['world', 'humans', 'everyone'] } }); expect(persistedState.get('hello')).to.eql({ nouns: ['world', 'humans', 'everyone'] }); @@ -457,9 +457,9 @@ describe('Persisted State', function () { }); it('should pass defaults to parent delegation', function () { - var persistedState = new PersistedState({ parent: true }); - var childState = persistedState.createChild('child', { account: { name: 'first child' }}); - var defaultValue = 'i have no data'; + let persistedState = new PersistedState({ parent: true }); + let childState = persistedState.createChild('child', { account: { name: 'first child' }}); + let defaultValue = 'i have no data'; expect(childState.get('account.name', defaultValue)).to.eql('first child'); expect(childState.get('account.age', defaultValue)).to.eql(defaultValue); @@ -469,25 +469,25 @@ describe('Persisted State', function () { describe('set state', function () { describe('path format support', function () { it('should create deep objects from dot notation', function () { - var persistedState = new PersistedState(); + let persistedState = new PersistedState(); persistedState.set('one.two.three', 4); expect(persistedState.get()).to.eql({ one: { two: { three: 4 } } }); }); it('should create deep objects from array notation', function () { - var persistedState = new PersistedState(); + let persistedState = new PersistedState(); persistedState.set('one[two][three]', 4); expect(persistedState.get()).to.eql({ one: { two: { three: 4 } } }); }); it('should create deep objects from arrays', function () { - var persistedState = new PersistedState(); + let persistedState = new PersistedState(); persistedState.set(['one', 'two', 'three'], 4); expect(persistedState.get()).to.eql({ one: { two: { three: 4 } } }); }); it('should create deep objects with an existing path', function () { - var persistedState = new PersistedState({}, 'deep.path'); + let persistedState = new PersistedState({}, 'deep.path'); persistedState.set('green[red].blue', 4); expect(persistedState.get()).to.eql({ green: { red: { blue: 4 } }}); }); @@ -553,19 +553,19 @@ describe('Persisted State', function () { describe('internal state tracking', function () { it('should be an empty object', function () { - var persistedState = new PersistedState(); + let persistedState = new PersistedState(); expect(persistedState._defaultState).to.eql({}); }); it('should store the default state value', function () { - var val = { one: 1, two: 2 }; - var persistedState = new PersistedState(val); + let val = { one: 1, two: 2 }; + let persistedState = new PersistedState(val); expect(persistedState._defaultState).to.eql(val); }); it('should keep track of changes', function () { - var val = { one: 1, two: 2 }; - var persistedState = new PersistedState(val); + let val = { one: 1, two: 2 }; + let persistedState = new PersistedState(val); persistedState.set('two', 22); expect(persistedState._defaultState).to.eql(val); @@ -577,14 +577,14 @@ describe('Persisted State', function () { let persistedState; let emitter; - var getByType = function (type, spy) { + let getByType = function (type, spy) { spy = spy || emitter; return spy.getCalls().filter(function (call) { return call.args[0] === type; }); }; - var watchEmitter = function (state) { + let watchEmitter = function (state) { return sinon.spy(state, 'emit'); }; @@ -665,7 +665,7 @@ describe('Persisted State', function () { }); it('should emit on parent and child instances', function (done) { - var child = persistedState.createChild('checker'); + let child = persistedState.createChild('checker'); expect(getByType('change')).to.have.length(0); // parent and child should emit, set up listener to test diff --git a/src/ui/public/private/__tests__/private.js b/src/ui/public/private/__tests__/private.js index 230daf98f874d..f467d512a3c3e 100644 --- a/src/ui/public/private/__tests__/private.js +++ b/src/ui/public/private/__tests__/private.js @@ -2,8 +2,8 @@ describe('Private module loader', function () { let Private; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function ($injector) { @@ -11,12 +11,12 @@ describe('Private module loader', function () { })); it('accepts a provider that will be called to init a module', function () { - var football = {}; + let football = {}; function Provider() { return football; } - var instance = Private(Provider); + let instance = Private(Provider); expect(instance).to.be(football); }); @@ -25,25 +25,25 @@ describe('Private module loader', function () { return Private; } - var instance = Private(Provider); + let instance = Private(Provider); expect(instance).to.be(Private); }); it('detects circular dependencies', function () { expect(function () { function Provider1() { - var p3 = Private(Provider3); + let p3 = Private(Provider3); } function Provider2() { - var p3 = Private(Provider3); + let p3 = Private(Provider3); } function Provider3() { - var p1 = Private(Provider3); + let p1 = Private(Provider3); } - var p1 = Private(Provider1); + let p1 = Private(Provider1); }).to.throwException(/circular/i); }); @@ -57,24 +57,24 @@ describe('Private module loader', function () { describe('#stub', function () { it('accepts a replacement instance for a Provider', function () { - var replaced = {}; - var replacement = {}; + let replaced = {}; + let replacement = {}; function Provider() { return replaced; } - var instance = Private(Provider); + let instance = Private(Provider); expect(instance).to.be(replaced); Private.stub(Provider, replacement); - var instance2 = Private(Provider); + let instance2 = Private(Provider); expect(instance2).to.be(replacement); Private.stub(Provider, replaced); - var instance3 = Private(Provider); + let instance3 = Private(Provider); expect(instance3).to.be(replaced); }); }); @@ -89,18 +89,18 @@ describe('Private module loader', function () { return {}; } - var instance1 = Private(Provider1); + let instance1 = Private(Provider1); expect(instance1).to.be.an('object'); Private.swap(Provider1, Provider2); - var instance2 = Private(Provider1); + let instance2 = Private(Provider1); expect(instance2).to.be.an('object'); expect(instance2).to.not.be(instance1); Private.swap(Provider1, Provider1); - var instance3 = Private(Provider1); + let instance3 = Private(Provider1); expect(instance3).to.be(instance1); }); }); diff --git a/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js b/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js index f10426ded09c2..d2381b707f6f6 100644 --- a/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js +++ b/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js @@ -1,16 +1,16 @@ describe('Reflow watcher', function () { require('angular'); - var $ = require('jquery'); - var _ = require('lodash'); - var expect = require('expect.js'); - var sinon = require('auto-release-sinon'); - var ngMock = require('ngMock'); + let $ = require('jquery'); + let _ = require('lodash'); + let expect = require('expect.js'); + let sinon = require('auto-release-sinon'); + let ngMock = require('ngMock'); - var $body = $(document.body); - var $window = $(window); - var expectStubbedEventAndEl = function (stub, event, $el) { + let $body = $(document.body); + let $window = $(window); + let expectStubbedEventAndEl = function (stub, event, $el) { expect(stub.getCalls().some(function (call) { - var events = call.args[0].split(' '); + let events = call.args[0].split(' '); return _.contains(events, event) && $el.is(call.thisValue); })).to.be(true); }; @@ -67,7 +67,7 @@ describe('Reflow watcher', function () { }); it('triggers the "reflow" event within a new angular tick', function () { - var stub = sinon.stub(); + let stub = sinon.stub(); reflowWatcher.on('reflow', stub); reflowWatcher.trigger(); diff --git a/src/ui/public/registry/__tests__/index.js b/src/ui/public/registry/__tests__/index.js index e0e6ab585e30b..0a749c43c0660 100644 --- a/src/ui/public/registry/__tests__/index.js +++ b/src/ui/public/registry/__tests__/index.js @@ -1,9 +1,9 @@ describe('Registry', function () { - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); - var registry = require('ui/registry/_registry'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); + let registry = require('ui/registry/_registry'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let Private; let IndexedArray; @@ -13,14 +13,14 @@ describe('Registry', function () { })); it('is technically a function', function () { - var reg = registry(); + let reg = registry(); expect(reg).to.be.a('function'); }); describe('#register', function () { it('accepts a Private module', function () { - var reg = registry(); - var mod = function SomePrivateModule() {}; + let reg = registry(); + let mod = function SomePrivateModule() {}; reg.register(mod); // modules are not exposed, so this is the most that we can test @@ -29,13 +29,13 @@ describe('Registry', function () { describe('as a module', function () { it('exposes the list of registered modules', function () { - var reg = registry(); - var mod = function SomePrivateModule(Private) { + let reg = registry(); + let mod = function SomePrivateModule(Private) { this.PrivateModuleLoader = Private; }; reg.register(mod); - var modules = Private(reg); + let modules = Private(reg); expect(modules).to.have.length(1); expect(modules[0]).to.have.property('PrivateModuleLoader', Private); }); @@ -43,16 +43,16 @@ describe('Registry', function () { describe('spec', function () { it('executes with the module list as "this", and can override it', function () { - var i = 0; + let i = 0; let self; - var reg = registry({ + let reg = registry({ constructor: function () { return { mods: (self = this) }; } }); - var modules = Private(reg); + let modules = Private(reg); expect(modules).to.be.an('object'); expect(modules).to.have.property('mods', self); }); @@ -60,7 +60,7 @@ describe('Registry', function () { describe('spec.name', function () { it('sets the displayName of the registry and the name param on the final instance', function () { - var reg = registry({ + let reg = registry({ name: 'visTypes' }); @@ -71,28 +71,28 @@ describe('Registry', function () { describe('spec.constructor', function () { it('executes before the modules are returned', function () { - var i = 0; - var reg = registry({ + let i = 0; + let reg = registry({ constructor: function () { i = i + 1; } }); - var modules = Private(reg); + let modules = Private(reg); expect(i).to.be(1); }); it('executes with the module list as "this", and can override it', function () { - var i = 0; + let i = 0; let self; - var reg = registry({ + let reg = registry({ constructor: function () { return { mods: (self = this) }; } }); - var modules = Private(reg); + let modules = Private(reg); expect(modules).to.be.an('object'); expect(modules).to.have.property('mods', self); }); @@ -100,13 +100,13 @@ describe('Registry', function () { describe('spec[any]', function () { it('mixes the extra properties into the module list', function () { - var reg = registry({ + let reg = registry({ someMethod: function () { return this; } }); - var modules = Private(reg); + let modules = Private(reg); expect(modules).to.have.property('someMethod'); expect(modules.someMethod()).to.be(modules); }); diff --git a/src/ui/public/routes/__tests__/_RouteManager.js b/src/ui/public/routes/__tests__/_RouteManager.js index 568023723562b..060674d5a1e82 100644 --- a/src/ui/public/routes/__tests__/_RouteManager.js +++ b/src/ui/public/routes/__tests__/_RouteManager.js @@ -1,11 +1,11 @@ -var _ = require('lodash'); -var ngMock = require('ngMock'); -var sinon = require('auto-release-sinon'); -var RouteManager = require('ui/routes/RouteManager'); -var expect = require('expect.js'); +let _ = require('lodash'); +let ngMock = require('ngMock'); +let sinon = require('auto-release-sinon'); +let RouteManager = require('ui/routes/RouteManager'); +let expect = require('expect.js'); let routes; // will contain an new instance of RouteManager for each test -var chainableMethods = [ +let chainableMethods = [ { name: 'when', args: ['', {}] }, { name: 'otherwise', args: [{}] }, { name: 'defaults', args: [/regexp/, {}] } @@ -31,7 +31,7 @@ describe('routes/RouteManager', function () { describe('#otherwise', function () { it('should forward the last otherwise route', function () { - var otherRoute = {}; + let otherRoute = {}; routes.otherwise({}); routes.otherwise(otherRoute); @@ -68,7 +68,7 @@ describe('routes/RouteManager', function () { describe('#config', function () { it('should add defined routes to the global $routeProvider service in order', function () { - var args = [ + let args = [ ['/one', {}], ['/two', {}] ]; @@ -81,8 +81,8 @@ describe('routes/RouteManager', function () { expect($rp.when.callCount).to.be(args.length); _.times(args.length, function (i) { - var call = $rp.when.getCall(i); - var a = args.shift(); + let call = $rp.when.getCall(i); + let a = args.shift(); expect(call.args[0]).to.be(a[0]); expect(call.args[1]).to.be(a[1]); diff --git a/src/ui/public/routes/__tests__/_WorkQueue.js b/src/ui/public/routes/__tests__/_WorkQueue.js index 1c55c8162ba9d..2d5c115ab5ec2 100644 --- a/src/ui/public/routes/__tests__/_WorkQueue.js +++ b/src/ui/public/routes/__tests__/_WorkQueue.js @@ -1,8 +1,8 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var WorkQueue = require('ui/routes/WorkQueue'); -var sinon = require('auto-release-sinon'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let WorkQueue = require('ui/routes/WorkQueue'); +let sinon = require('auto-release-sinon'); require('ui/promises'); describe('work queue', function () { @@ -25,10 +25,10 @@ describe('work queue', function () { describe('#resolveWhenFull', function () { it('resolves requests waiting for the queue to fill when appropriate', function () { - var size = _.random(5, 50); + let size = _.random(5, 50); queue.limit = size; - var whenFull = Promise.defer(); + let whenFull = Promise.defer(); sinon.stub(whenFull, 'resolve'); queue.resolveWhenFull(whenFull); @@ -53,11 +53,11 @@ describe('work queue', function () { * can manipulate the filled queue */ function fillWithStubs(then) { - var size = _.random(5, 50); - var stub = sinon.stub(); + let size = _.random(5, 50); + let stub = sinon.stub(); _.times(size, function () { - var d = Promise.defer(); + let d = Promise.defer(); // overwrite the defer methods with the stub d.resolve = stub; d.reject = stub; diff --git a/src/ui/public/routes/__tests__/_wrapRouteWithPrep.js b/src/ui/public/routes/__tests__/_wrapRouteWithPrep.js index 2355f863ad965..76d545ba0400c 100644 --- a/src/ui/public/routes/__tests__/_wrapRouteWithPrep.js +++ b/src/ui/public/routes/__tests__/_wrapRouteWithPrep.js @@ -1,11 +1,11 @@ -var RouteManager = require('ui/routes/RouteManager'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let RouteManager = require('ui/routes/RouteManager'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); -var wrapRouteWithPrep = require('ui/routes/wrapRouteWithPrep'); -var Promise = require('bluebird'); -var _ = require('lodash'); -var stub = require('auto-release-sinon').stub; +let wrapRouteWithPrep = require('ui/routes/wrapRouteWithPrep'); +let Promise = require('bluebird'); +let _ = require('lodash'); +let stub = require('auto-release-sinon').stub; require('ui/private'); @@ -18,16 +18,16 @@ describe('wrapRouteWithPrep fn', function () { routes = new RouteManager(); }); - var SchedulingTest = function (opts) { + let SchedulingTest = function (opts) { opts = opts || {}; - var delaySetup = opts.delayUserWork ? 0 : 50; - var delayUserWork = opts.delayUserWork ? 50 : 0; + let delaySetup = opts.delayUserWork ? 0 : 50; + let delayUserWork = opts.delayUserWork ? 50 : 0; return function () { ngMock.module('kibana', 'kibana/notify'); - var setupComplete = false; - var userWorkComplete = false; + let setupComplete = false; + let userWorkComplete = false; let route; let Private; let Promise; diff --git a/src/ui/public/safe_confirm/__tests__/safe_confirm.js b/src/ui/public/safe_confirm/__tests__/safe_confirm.js index cea7886d565b7..0c17cd413d657 100644 --- a/src/ui/public/safe_confirm/__tests__/safe_confirm.js +++ b/src/ui/public/safe_confirm/__tests__/safe_confirm.js @@ -1,7 +1,7 @@ describe('ui/safe_confirm', function () { - var sinon = require('sinon'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let sinon = require('sinon'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let $rootScope; let $window; @@ -34,7 +34,7 @@ describe('ui/safe_confirm', function () { expect($window.confirm.called).to.be(false); }); it('returned promise is not resolved', function () { - var isResolved = false; + let isResolved = false; function markAsResolved() { isResolved = true; } diff --git a/src/ui/public/state_management/__tests__/app_state.js b/src/ui/public/state_management/__tests__/app_state.js index 075c8c75fc756..d57abbc835d15 100644 --- a/src/ui/public/state_management/__tests__/app_state.js +++ b/src/ui/public/state_management/__tests__/app_state.js @@ -1,6 +1,6 @@ -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/state_management/app_state'); describe('State Management', function () { @@ -26,7 +26,7 @@ describe('State Management', function () { }); it('should use passed in params', function () { - var params = { + let params = { test: true, mock: false }; @@ -45,8 +45,8 @@ describe('State Management', function () { }); it('should be destroyed on $routeChangeStart', function () { - var destroySpy = sinon.spy(appState, 'destroy'); - var url = '/test/path'; + let destroySpy = sinon.spy(appState, 'destroy'); + let url = '/test/path'; $rootScope.$emit('$routeChangeStart'); diff --git a/src/ui/public/state_management/__tests__/global_state.js b/src/ui/public/state_management/__tests__/global_state.js index 28b5a9914f58a..3a13c9b3dec33 100644 --- a/src/ui/public/state_management/__tests__/global_state.js +++ b/src/ui/public/state_management/__tests__/global_state.js @@ -1,7 +1,7 @@ -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/state_management/global_state'); describe('State Management', function () { diff --git a/src/ui/public/state_management/__tests__/state.js b/src/ui/public/state_management/__tests__/state.js index c1a762d27c665..e4b9ab4785eaa 100644 --- a/src/ui/public/state_management/__tests__/state.js +++ b/src/ui/public/state_management/__tests__/state.js @@ -1,8 +1,8 @@ -var _ = require('lodash'); -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); require('ui/private'); describe('State Management', function () { @@ -21,26 +21,26 @@ describe('State Management', function () { describe('Provider', function () { it('should reset the state to the defaults', function () { - var state = new State('_s', { message: ['test'] }); + let state = new State('_s', { message: ['test'] }); state.reset(); - var search = $location.search(); + let search = $location.search(); expect(search).to.have.property('_s'); expect(search._s).to.equal('(message:!(test))'); expect(state.message).to.eql(['test']); }); it('should apply the defaults upon initialization', function () { - var state = new State('_s', { message: 'test' }); + let state = new State('_s', { message: 'test' }); expect(state).to.have.property('message', 'test'); }); it('should inherit from Events', function () { - var state = new State(); + let state = new State(); expect(state).to.be.an(Events); }); it('should emit an event if reset with changes', function (done) { - var state = new State('_s', { message: 'test' }); + let state = new State('_s', { message: 'test' }); state.on('reset_with_changes', function (keys) { expect(keys).to.eql(['message']); done(); @@ -52,7 +52,7 @@ describe('State Management', function () { }); it('should not emit an event if reset without changes', function () { - var state = new State('_s', { message: 'test' }); + let state = new State('_s', { message: 'test' }); state.on('reset_with_changes', function () { expect().fail(); }); @@ -65,29 +65,29 @@ describe('State Management', function () { describe('Search', function () { it('should save to $location.search()', function () { - var state = new State('_s', { test: 'foo' }); + let state = new State('_s', { test: 'foo' }); state.save(); - var search = $location.search(); + let search = $location.search(); expect(search).to.have.property('_s'); expect(search._s).to.equal('(test:foo)'); }); it('should emit an event if changes are saved', function (done) { - var state = new State(); + let state = new State(); state.on('save_with_changes', function (keys) { expect(keys).to.eql(['test']); done(); }); state.test = 'foo'; state.save(); - var search = $location.search(); + let search = $location.search(); $rootScope.$apply(); }); }); describe('Fetch', function () { it('should emit an event if changes are fetched', function (done) { - var state = new State(); + let state = new State(); state.on('fetch_with_changes', function (keys) { expect(keys).to.eql(['foo']); done(); @@ -99,7 +99,7 @@ describe('State Management', function () { }); it('should have events that attach to scope', function (done) { - var state = new State(); + let state = new State(); state.on('test', function (message) { expect(message).to.equal('foo'); done(); @@ -109,7 +109,7 @@ describe('State Management', function () { }); it('should fire listeners for #onUpdate() on #fetch()', function (done) { - var state = new State(); + let state = new State(); state.on('fetch_with_changes', function (keys) { expect(keys).to.eql(['foo']); done(); @@ -121,7 +121,7 @@ describe('State Management', function () { }); it('should apply defaults to fetches', function () { - var state = new State('_s', { message: 'test' }); + let state = new State('_s', { message: 'test' }); $location.search({ _s: '(foo:bar)' }); state.fetch(); expect(state).to.have.property('foo', 'bar'); @@ -129,15 +129,15 @@ describe('State Management', function () { }); it('should call fetch when $routeUpdate is fired on $rootScope', function () { - var state = new State(); - var spy = sinon.spy(state, 'fetch'); + let state = new State(); + let spy = sinon.spy(state, 'fetch'); $rootScope.$emit('$routeUpdate', 'test'); sinon.assert.calledOnce(spy); }); it('should clear state when missing form URL', function () { let stateObj; - var state = new State(); + let state = new State(); // set satte via URL $location.search({ _s: '(foo:(bar:baz))' }); diff --git a/src/ui/public/storage/__tests__/storage.js b/src/ui/public/storage/__tests__/storage.js index ce1a19d7a9950..ff27a41ee38d6 100644 --- a/src/ui/public/storage/__tests__/storage.js +++ b/src/ui/public/storage/__tests__/storage.js @@ -1,10 +1,10 @@ -var sinon = require('sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let storage; let $window; -var payload = { first: 'john', last: 'smith' }; +let payload = { first: 'john', last: 'smith' }; require('ui/storage'); @@ -69,21 +69,21 @@ describe('StorageService', function () { describe('json data', function () { it('should parse JSON when reading from the store', function () { - var getItem = $window.localStorage.getItem; + let getItem = $window.localStorage.getItem; getItem.returns(JSON.stringify(payload)); - var data = storage.get('name'); + let data = storage.get('name'); expect(data).to.eql(payload); }); it('should write JSON string to the store', function () { - var setItem = $window.localStorage.setItem; - var key = 'name'; - var value = payload; + let setItem = $window.localStorage.setItem; + let key = 'name'; + let value = payload; storage.set(key, value); - var call = setItem.getCall(0); + let call = setItem.getCall(0); expect(call.args[0]).to.equal(key); expect(call.args[1]).to.equal(JSON.stringify(value)); }); @@ -91,15 +91,15 @@ describe('StorageService', function () { describe('expected responses', function () { it('should return null when not exists', function () { - var data = storage.get('notexists'); + let data = storage.get('notexists'); expect(data).to.equal(null); }); it('should return null when invalid JSON', function () { - var getItem = $window.localStorage.getItem; + let getItem = $window.localStorage.getItem; getItem.returns('not: json'); - var data = storage.get('name'); + let data = storage.get('name'); expect(data).to.equal(null); }); }); diff --git a/src/ui/public/stringify/__tests__/_color.js b/src/ui/public/stringify/__tests__/_color.js index 2be0de4443624..89cf548410062 100644 --- a/src/ui/public/stringify/__tests__/_color.js +++ b/src/ui/public/stringify/__tests__/_color.js @@ -1,8 +1,8 @@ describe('Color Format', function () { let fieldFormats; let ColorFormat; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -12,7 +12,7 @@ describe('Color Format', function () { })); it('should add colors if the value is in range', function () { - var colorer = new ColorFormat({ + let colorer = new ColorFormat({ colors: [{ range: '100:150', text: 'blue', @@ -26,7 +26,7 @@ describe('Color Format', function () { }); it('should not convert invalid ranges', function () { - var colorer = new ColorFormat({ + let colorer = new ColorFormat({ colors: [{ range: '100150', text: 'blue', diff --git a/src/ui/public/stringify/__tests__/_conformance.js b/src/ui/public/stringify/__tests__/_conformance.js index 89af762624782..e6acc4eb3fd4f 100644 --- a/src/ui/public/stringify/__tests__/_conformance.js +++ b/src/ui/public/stringify/__tests__/_conformance.js @@ -1,12 +1,12 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let fieldFormats; let FieldFormat; let config; -var formatIds = [ +let formatIds = [ 'bytes', 'date', 'ip', @@ -70,7 +70,7 @@ module.exports = describe('conformance', function () { basicPatternTests('number', require('numeral'))(); it('tries to parse strings', function () { - var number = new (fieldFormats.getType('number'))({ pattern: '0.0b' }); + let number = new (fieldFormats.getType('number'))({ pattern: '0.0b' }); expect(number.convert(123.456)).to.be('123.5B'); expect(number.convert('123.456')).to.be('123.5B'); }); @@ -78,11 +78,11 @@ module.exports = describe('conformance', function () { }); function basicPatternTests(id, lib) { - var confKey = id === 'date' ? 'dateFormat' : 'format:' + id + ':defaultPattern'; + let confKey = id === 'date' ? 'dateFormat' : 'format:' + id + ':defaultPattern'; return function () { it('converts using the format:' + id + ':defaultPattern config', function () { - var inst = fieldFormats.getInstance(id); + let inst = fieldFormats.getInstance(id); [ '0b', '0 b', @@ -90,22 +90,22 @@ module.exports = describe('conformance', function () { '0.[000]b', '0.[0]b' ].forEach(function (pattern) { - var num = _.random(-10000, 10000, true); + let num = _.random(-10000, 10000, true); config.set(confKey, pattern); expect(inst.convert(num)).to.be(lib(num).format(pattern)); }); }); it('uses the pattern param if available', function () { - var num = _.random(-10000, 10000, true); - var defFormat = '0b'; - var customFormat = '0.00000%'; + let num = _.random(-10000, 10000, true); + let defFormat = '0b'; + let customFormat = '0.00000%'; config.set(confKey, defFormat); - var defInst = fieldFormats.getInstance(id); + let defInst = fieldFormats.getInstance(id); - var Type = fieldFormats.getType(id); - var customInst = new Type({ pattern: customFormat }); + let Type = fieldFormats.getType(id); + let customInst = new Type({ pattern: customFormat }); expect(defInst.convert(num)).to.not.be(customInst.convert(num)); expect(defInst.convert(num)).to.be(lib(num).format(defFormat)); diff --git a/src/ui/public/stringify/__tests__/_date.js b/src/ui/public/stringify/__tests__/_date.js index 747c65aa60b4b..7c2bedd2f5083 100644 --- a/src/ui/public/stringify/__tests__/_date.js +++ b/src/ui/public/stringify/__tests__/_date.js @@ -1,7 +1,7 @@ describe('Date Format', function () { - var expect = require('expect.js'); - var ngMock = require('ngMock'); - var moment = require('moment-timezone'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); + let moment = require('moment-timezone'); let fieldFormats; let settings; let convert; @@ -14,8 +14,8 @@ describe('Date Format', function () { settings = config; fieldFormats = Private(require('ui/registry/field_formats')); - var DateFormat = fieldFormats.getType('date'); - var date = new DateFormat(); + let DateFormat = fieldFormats.getType('date'); + let date = new DateFormat(); convert = date.convert.bind(date); })); @@ -29,17 +29,17 @@ describe('Date Format', function () { function setDefaultTimezone() { moment.tz.setDefault(settings.get('dateFormat:tz')); } - var time = 1445027693942; + let time = 1445027693942; off = $scope.$on('change:config.dateFormat:tz', setDefaultTimezone); settings.set('dateFormat:tz', 'America/Chicago'); $scope.$digest(); - var chicagoTime = convert(time); + let chicagoTime = convert(time); settings.set('dateFormat:tz', 'America/Phoenix'); $scope.$digest(); - var phoenixTime = convert(time); + let phoenixTime = convert(time); expect(chicagoTime).not.to.equal(phoenixTime); off(); diff --git a/src/ui/public/stringify/__tests__/_ip.js b/src/ui/public/stringify/__tests__/_ip.js index 7d387ec492197..e8c07e9051c0b 100644 --- a/src/ui/public/stringify/__tests__/_ip.js +++ b/src/ui/public/stringify/__tests__/_ip.js @@ -1,7 +1,7 @@ describe('IP Address Format', function () { let fieldFormats; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -9,7 +9,7 @@ describe('IP Address Format', function () { })); it('convers a value from a decimal to a string', function () { - var ip = fieldFormats.getInstance('ip'); + let ip = fieldFormats.getInstance('ip'); expect(ip.convert(1186489492)).to.be('70.184.100.148'); }); diff --git a/src/ui/public/stringify/__tests__/_source.js b/src/ui/public/stringify/__tests__/_source.js index 28156d09b6f04..44cbddd885c2a 100644 --- a/src/ui/public/stringify/__tests__/_source.js +++ b/src/ui/public/stringify/__tests__/_source.js @@ -1,8 +1,8 @@ describe('_source formatting', function () { - var $ = require('jquery'); - var _ = require('lodash'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let $ = require('jquery'); + let _ = require('lodash'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let fieldFormats; @@ -25,8 +25,8 @@ describe('_source formatting', function () { })); it('uses the _source, field, and hit to create a
', function () { - var hit = _.first(hits); - var $dl = $(convertHtml(hit._source, indexPattern.fields.byName._source, hit)); + let hit = _.first(hits); + let $dl = $(convertHtml(hit._source, indexPattern.fields.byName._source, hit)); expect($dl.is('dl')).to.be.ok(); expect($dl.find('dt')).to.have.length(_.keys(indexPattern.flattenHit(hit)).length); }); diff --git a/src/ui/public/stringify/__tests__/_string.js b/src/ui/public/stringify/__tests__/_string.js index 12e89e99067aa..dbbaf0d86ac0f 100644 --- a/src/ui/public/stringify/__tests__/_string.js +++ b/src/ui/public/stringify/__tests__/_string.js @@ -1,7 +1,7 @@ describe('String Format', function () { let fieldFormats; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -9,8 +9,8 @@ describe('String Format', function () { })); it('decode a base64 string', function () { - var StringFormat = fieldFormats.getType('string'); - var string = new StringFormat({ + let StringFormat = fieldFormats.getType('string'); + let string = new StringFormat({ transform: 'base64' }); expect(string.convert('Zm9vYmFy')).to.be('foobar'); diff --git a/src/ui/public/stringify/__tests__/_truncate.js b/src/ui/public/stringify/__tests__/_truncate.js index e89a63abd1f03..3612413e8eb82 100644 --- a/src/ui/public/stringify/__tests__/_truncate.js +++ b/src/ui/public/stringify/__tests__/_truncate.js @@ -1,7 +1,7 @@ describe('String Truncate Format', function () { let fieldFormats; - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -9,29 +9,29 @@ describe('String Truncate Format', function () { })); it('truncate large string', function () { - var Truncate = fieldFormats.getType('truncate'); - var truncate = new Truncate({fieldLength: 4}); + let Truncate = fieldFormats.getType('truncate'); + let truncate = new Truncate({fieldLength: 4}); expect(truncate.convert('This is some text')).to.be('This...'); }); it('does not truncate large string when field length is not a string', function () { - var Truncate = fieldFormats.getType('truncate'); - var truncate = new Truncate({fieldLength: 'not number'}); + let Truncate = fieldFormats.getType('truncate'); + let truncate = new Truncate({fieldLength: 'not number'}); expect(truncate.convert('This is some text')).to.be('This is some text'); }); it('does not truncate large string when field length is null', function () { - var Truncate = fieldFormats.getType('truncate'); - var truncate = new Truncate({fieldLength: null}); + let Truncate = fieldFormats.getType('truncate'); + let truncate = new Truncate({fieldLength: null}); expect(truncate.convert('This is some text')).to.be('This is some text'); }); it('does not truncate large string when field length larger than the text', function () { - var Truncate = fieldFormats.getType('truncate'); - var truncate = new Truncate({fieldLength: 100000}); + let Truncate = fieldFormats.getType('truncate'); + let truncate = new Truncate({fieldLength: 100000}); expect(truncate.convert('This is some text')).to.be('This is some text'); }); diff --git a/src/ui/public/stringify/__tests__/_url.js b/src/ui/public/stringify/__tests__/_url.js index d14d8894f9cdb..472e87da2f865 100644 --- a/src/ui/public/stringify/__tests__/_url.js +++ b/src/ui/public/stringify/__tests__/_url.js @@ -1,7 +1,7 @@ describe('Url Format', function () { - var $ = require('jquery'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let $ = require('jquery'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let fieldFormats; @@ -18,9 +18,9 @@ describe('Url Format', function () { }); it('ouputs a simple tab by default', function () { - var url = new Url(); + let url = new Url(); - var $a = $(url.convert('http://elastic.co', 'html')); + let $a = $(url.convert('http://elastic.co', 'html')); expect($a.is('a')).to.be(true); expect($a.size()).to.be(1); expect($a.attr('href')).to.be('http://elastic.co'); @@ -29,17 +29,17 @@ describe('Url Format', function () { }); it('outputs an if type === "img"', function () { - var url = new Url({ type: 'img' }); + let url = new Url({ type: 'img' }); - var $img = $(url.convert('http://elastic.co', 'html')); + let $img = $(url.convert('http://elastic.co', 'html')); expect($img.is('img')).to.be(true); expect($img.attr('src')).to.be('http://elastic.co'); }); describe('url template', function () { it('accepts a template', function () { - var url = new Url({ urlTemplate: 'url: {{ value }}' }); - var $a = $(url.convert('url', 'html')); + let url = new Url({ urlTemplate: 'url: {{ value }}' }); + let $a = $(url.convert('url', 'html')); expect($a.is('a')).to.be(true); expect($a.size()).to.be(1); expect($a.attr('href')).to.be('url: url'); @@ -48,15 +48,15 @@ describe('Url Format', function () { }); it('only outputs the url if the contentType === "text"', function () { - var url = new Url(); + let url = new Url(); expect(url.convert('url', 'text')).to.be('url'); }); }); describe('label template', function () { it('accepts a template', function () { - var url = new Url({ labelTemplate: 'extension: {{ value }}' }); - var $a = $(url.convert('php', 'html')); + let url = new Url({ labelTemplate: 'extension: {{ value }}' }); + let $a = $(url.convert('php', 'html')); expect($a.is('a')).to.be(true); expect($a.size()).to.be(1); expect($a.attr('href')).to.be('php'); @@ -64,19 +64,19 @@ describe('Url Format', function () { }); it('uses the label template for text formating', function () { - var url = new Url({ labelTemplate: 'external {{value }}'}); + let url = new Url({ labelTemplate: 'external {{value }}'}); expect(url.convert('url', 'text')).to.be('external url'); }); it('can use the raw value', function () { - var url = new Url({ + let url = new Url({ labelTemplate: 'external {{value}}' }); expect(url.convert('url?', 'text')).to.be('external url?'); }); it('can use the url', function () { - var url = new Url({ + let url = new Url({ urlTemplate: 'http://google.com/{{value}}', labelTemplate: 'external {{url}}' }); @@ -86,19 +86,19 @@ describe('Url Format', function () { describe('templating', function () { it('ignores unknown variables', function () { - var url = new Url({ urlTemplate: '{{ not really a var }}' }); + let url = new Url({ urlTemplate: '{{ not really a var }}' }); expect(url.convert('url', 'text')).to.be(''); }); it('does not allow executing code in variable expressions', function () { window.SHOULD_NOT_BE_TRUE = false; - var url = new Url({ urlTemplate: '{{ (window.SHOULD_NOT_BE_TRUE = true) && value }}' }); + let url = new Url({ urlTemplate: '{{ (window.SHOULD_NOT_BE_TRUE = true) && value }}' }); expect(url.convert('url', 'text')).to.be(''); }); describe('', function () { it('does not get values from the prototype chain', function () { - var url = new Url({ urlTemplate: '{{ toString }}' }); + let url = new Url({ urlTemplate: '{{ toString }}' }); expect(url.convert('url', 'text')).to.be(''); }); }); diff --git a/src/ui/public/styleCompile/__tests__/styleCompile.js b/src/ui/public/styleCompile/__tests__/styleCompile.js index 2d72034ac586c..e7e77420949c9 100644 --- a/src/ui/public/styleCompile/__tests__/styleCompile.js +++ b/src/ui/public/styleCompile/__tests__/styleCompile.js @@ -1,7 +1,7 @@ describe('styleCompile directive', function () { - var $ = require('jquery'); - var expect = require('expect.js'); - var ngMock = require('ngMock'); + let $ = require('jquery'); + let expect = require('expect.js'); + let ngMock = require('ngMock'); let config; let $rootScope; @@ -13,7 +13,7 @@ describe('styleCompile directive', function () { })); it('exports a few config values as css', function () { - var $style = $('#style-compile'); + let $style = $('#style-compile'); config.set('truncate:maxHeight', 0); $rootScope.$apply(); diff --git a/src/ui/public/timefilter/__tests__/diff_interval.js b/src/ui/public/timefilter/__tests__/diff_interval.js index 8fd9f98c8f29e..9aeff5890ba09 100644 --- a/src/ui/public/timefilter/__tests__/diff_interval.js +++ b/src/ui/public/timefilter/__tests__/diff_interval.js @@ -1,6 +1,6 @@ -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Timefilter service', function () { describe('Refresh interval diff watcher', function () { diff --git a/src/ui/public/timefilter/__tests__/diff_time.js b/src/ui/public/timefilter/__tests__/diff_time.js index 5e0415ab8ba7a..b4ffce4ddd365 100644 --- a/src/ui/public/timefilter/__tests__/diff_time.js +++ b/src/ui/public/timefilter/__tests__/diff_time.js @@ -1,6 +1,6 @@ -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Timefilter service', function () { describe('time diff watcher', function () { diff --git a/src/ui/public/timefilter/__tests__/index.js b/src/ui/public/timefilter/__tests__/index.js index e0a348b4475eb..0582f9daa016f 100644 --- a/src/ui/public/timefilter/__tests__/index.js +++ b/src/ui/public/timefilter/__tests__/index.js @@ -1,4 +1,4 @@ -var modules = require('ui/modules'); +let modules = require('ui/modules'); modules.get('kibana').config(function ($provide) { $provide.decorator('timefilter', function ($delegate) { diff --git a/src/ui/public/url/__tests__/url.js b/src/ui/public/url/__tests__/url.js index 892a597591746..bac0d05773764 100644 --- a/src/ui/public/url/__tests__/url.js +++ b/src/ui/public/url/__tests__/url.js @@ -1,10 +1,10 @@ -var sinon = require('auto-release-sinon'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var faker = require('faker'); -var _ = require('lodash'); -var MockState = require('fixtures/mock_state'); +let sinon = require('auto-release-sinon'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let faker = require('faker'); +let _ = require('lodash'); +let MockState = require('fixtures/mock_state'); // global vars, injected and mocked in init() let kbnUrl; @@ -81,7 +81,7 @@ describe('kbnUrl', function () { } }; - var unbind = sinon.stub(); + let unbind = sinon.stub(); sinon.stub($rootScope, '$on').returns(unbind); $route.reload = sinon.stub(); @@ -89,7 +89,7 @@ describe('kbnUrl', function () { kbnUrl.change('/url'); expect($rootScope.$on.callCount).to.be(1); - var handler = $rootScope.$on.firstCall.args[1]; + let handler = $rootScope.$on.firstCall.args[1]; handler(); expect(unbind.callCount).to.be(1); expect($route.reload.callCount).to.be(1); @@ -151,9 +151,9 @@ describe('kbnUrl', function () { }); it('should uri encode replaced params', function () { - var url = '/some/path/'; - var params = { replace: faker.Lorem.words(3).join(' ') }; - var check = encodeURIComponent(params.replace); + let url = '/some/path/'; + let params = { replace: faker.Lorem.words(3).join(' ') }; + let check = encodeURIComponent(params.replace); sinon.stub($location, 'url'); kbnUrl.change(url + '{{replace}}', params); @@ -163,22 +163,22 @@ describe('kbnUrl', function () { it('should parse angular expression in substitutions and uri encode the results', function () { // build url by piecing together these parts - var urlParts = ['/', '/', '?', '&', '#']; + let urlParts = ['/', '/', '?', '&', '#']; // make sure it can parse templates with weird spacing - var wrappers = [ ['{{', '}}'], ['{{ ', ' }}'], ['{{', ' }}'], ['{{ ', '}}'], ['{{ ', ' }}']]; + let wrappers = [ ['{{', '}}'], ['{{ ', ' }}'], ['{{', ' }}'], ['{{ ', '}}'], ['{{ ', ' }}']]; // make sure filters are evaluated via angular expressions - var objIndex = 4; // used to case one replace as an object - var filters = ['', 'uppercase', '', 'uppercase', 'rison']; + let objIndex = 4; // used to case one replace as an object + let filters = ['', 'uppercase', '', 'uppercase', 'rison']; // the words (template keys) used must all be unique - var words = _.uniq(faker.Lorem.words(10)).slice(0, urlParts.length).map(function (word, i) { + let words = _.uniq(faker.Lorem.words(10)).slice(0, urlParts.length).map(function (word, i) { if (filters[i].length) { return word + '|' + filters[i]; } return word; }); - var replacements = faker.Lorem.words(urlParts.length).map(function (word, i) { + let replacements = faker.Lorem.words(urlParts.length).map(function (word, i) { // make selected replacement into an object if (i === objIndex) { return { replace: word }; @@ -188,19 +188,19 @@ describe('kbnUrl', function () { }); // build the url and test url - var url = ''; - var testUrl = ''; + let url = ''; + let testUrl = ''; urlParts.forEach(function (part, i) { url += part + wrappers[i][0] + words[i] + wrappers[i][1]; - var locals = {}; + let locals = {}; locals[words[i].split('|')[0]] = replacements[i]; testUrl += part + encodeURIComponent($rootScope.$eval(words[i], locals)); }); // create the locals replacement object - var params = {}; + let params = {}; replacements.forEach(function (replacement, i) { - var word = words[i].split('|')[0]; + let word = words[i].split('|')[0]; params[word] = replacement; }); @@ -213,7 +213,7 @@ describe('kbnUrl', function () { }); it('should handle dot notation', function () { - var url = '/some/thing/{{that.is.substituted}}'; + let url = '/some/thing/{{that.is.substituted}}'; kbnUrl.change(url, { that: { @@ -227,8 +227,8 @@ describe('kbnUrl', function () { }); it('should throw when params are missing', function () { - var url = '/{{replace_me}}'; - var params = {}; + let url = '/{{replace_me}}'; + let params = {}; try { kbnUrl.change(url, params); @@ -240,8 +240,8 @@ describe('kbnUrl', function () { }); it('should throw when filtered params are missing', function () { - var url = '/{{replace_me|number}}'; - var params = {}; + let url = '/{{replace_me|number}}'; + let params = {}; try { kbnUrl.change(url, params); @@ -253,10 +253,10 @@ describe('kbnUrl', function () { }); it('should change the entire url', function () { - var path = '/test/path'; - var search = {search: 'test'}; - var hash = 'hash'; - var newPath = '/new/location'; + let path = '/test/path'; + let search = {search: 'test'}; + let hash = 'hash'; + let newPath = '/new/location'; $location.path(path).search(search).hash(hash); @@ -276,10 +276,10 @@ describe('kbnUrl', function () { describe('changePath', function () { it('should change just the path', function () { - var path = '/test/path'; - var search = {search: 'test'}; - var hash = 'hash'; - var newPath = '/new/location'; + let path = '/test/path'; + let search = {search: 'test'}; + let hash = 'hash'; + let newPath = '/new/location'; $location.path(path).search(search).hash(hash); @@ -299,10 +299,10 @@ describe('kbnUrl', function () { describe('redirect', function () { it('should change the entire url', function () { - var path = '/test/path'; - var search = {search: 'test'}; - var hash = 'hash'; - var newPath = '/new/location'; + let path = '/test/path'; + let search = {search: 'test'}; + let hash = 'hash'; + let newPath = '/new/location'; $location.path(path).search(search).hash(hash); @@ -340,10 +340,10 @@ describe('kbnUrl', function () { describe('redirectPath', function () { it('should only change the path', function () { - var path = '/test/path'; - var search = {search: 'test'}; - var hash = 'hash'; - var newPath = '/new/location'; + let path = '/test/path'; + let search = {search: 'test'}; + let hash = 'hash'; + let newPath = '/new/location'; $location .path(path) diff --git a/src/ui/public/utils/__tests__/Ipv4Address.js b/src/ui/public/utils/__tests__/Ipv4Address.js index 80d93abebbb2c..40a5831c4c2b7 100644 --- a/src/ui/public/utils/__tests__/Ipv4Address.js +++ b/src/ui/public/utils/__tests__/Ipv4Address.js @@ -1,5 +1,5 @@ -var Ipv4Address = require('ui/utils/Ipv4Address'); -var expect = require('expect.js'); +let Ipv4Address = require('ui/utils/Ipv4Address'); +let expect = require('expect.js'); describe('Ipv4Address', function () { it('should throw errors with invalid IP addresses', function () { @@ -37,7 +37,7 @@ describe('Ipv4Address', function () { }); it('should correctly calculate the decimal representation of an IP address', function () { - var ipAddress = new Ipv4Address('0.0.0.0'); + let ipAddress = new Ipv4Address('0.0.0.0'); expect(ipAddress.valueOf()).to.be(0); ipAddress = new Ipv4Address('0.0.0.1'); @@ -48,7 +48,7 @@ describe('Ipv4Address', function () { }); it('toString()', function () { - var ipAddress = new Ipv4Address('0.000.00000.1'); + let ipAddress = new Ipv4Address('0.000.00000.1'); expect(ipAddress.toString()).to.be('0.0.0.1'); ipAddress = new Ipv4Address('123.123.123.123'); diff --git a/src/ui/public/utils/__tests__/ObjDefine.js b/src/ui/public/utils/__tests__/ObjDefine.js index 8b84f51cd7a35..ec4b15b1cda73 100644 --- a/src/ui/public/utils/__tests__/ObjDefine.js +++ b/src/ui/public/utils/__tests__/ObjDefine.js @@ -1,7 +1,7 @@ -var expect = require('expect.js'); +let expect = require('expect.js'); describe('ObjDefine Utility', function () { - var ObjDefine = require('ui/utils/ObjDefine'); + let ObjDefine = require('ui/utils/ObjDefine'); function flatten(obj) { return JSON.parse(JSON.stringify(obj)); @@ -9,10 +9,10 @@ describe('ObjDefine Utility', function () { describe('#writ', function () { it('creates writeable properties', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.writ('name', 'foo'); - var obj = def.create(); + let obj = def.create(); expect(obj).to.have.property('name', 'foo'); obj.name = 'bar'; @@ -20,13 +20,13 @@ describe('ObjDefine Utility', function () { }); it('exports the property to JSON', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.writ('name', 'foo'); expect(flatten(def.create())).to.have.property('name', 'foo'); }); it('does not export property to JSON it it\'s undefined or null', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.writ('name'); expect(flatten(def.create())).to.not.have.property('name'); @@ -35,10 +35,10 @@ describe('ObjDefine Utility', function () { }); it('switched to exporting if a value is written', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.writ('name'); - var obj = def.create(); + let obj = def.create(); expect(flatten(obj)).to.not.have.property('name'); obj.name = null; @@ -49,10 +49,10 @@ describe('ObjDefine Utility', function () { }); it('setting a writ value to null prevents it from exporting', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.writ('name', 'foo'); - var obj = def.create(); + let obj = def.create(); expect(flatten(obj)).to.have.property('name', 'foo'); obj.name = null; @@ -63,11 +63,11 @@ describe('ObjDefine Utility', function () { describe('#fact', function () { it('creates an immutable field', function () { - var def = new ObjDefine(); - var val = 'foo'; - var notval = 'bar'; + let def = new ObjDefine(); + let val = 'foo'; + let notval = 'bar'; def.fact('name', val); - var obj = def.create(); + let obj = def.create(); obj.name = notval; // UPDATE SHOULD BE IGNORED @@ -75,7 +75,7 @@ describe('ObjDefine Utility', function () { }); it('exports the fact to JSON', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.fact('name', 'foo'); expect(flatten(def.create())).to.have.property('name', 'foo'); }); @@ -83,11 +83,11 @@ describe('ObjDefine Utility', function () { describe('#comp', function () { it('creates an immutable field', function () { - var def = new ObjDefine(); - var val = 'foo'; - var notval = 'bar'; + let def = new ObjDefine(); + let val = 'foo'; + let notval = 'bar'; def.comp('name', val); - var obj = def.create(); + let obj = def.create(); expect(function () { 'use strict'; // eslint-disable-line strict @@ -97,7 +97,7 @@ describe('ObjDefine Utility', function () { }); it('does not export the computed value to JSON', function () { - var def = new ObjDefine(); + let def = new ObjDefine(); def.comp('name', 'foo'); expect(flatten(def.create())).to.not.have.property('name'); }); @@ -108,24 +108,24 @@ describe('ObjDefine Utility', function () { it('creates object that inherits from the prototype', function () { function SomeClass() {} - var def = new ObjDefine(null, SomeClass.prototype); - var obj = def.create(); + let def = new ObjDefine(null, SomeClass.prototype); + let obj = def.create(); expect(obj).to.be.a(SomeClass); }); it('uses the defaults for property values', function () { - var def = new ObjDefine({ name: 'bar' }); + let def = new ObjDefine({ name: 'bar' }); def.fact('name'); - var obj = def.create(); + let obj = def.create(); expect(obj).to.have.property('name', 'bar'); }); it('ignores default values that are not defined propertyes', function () { - var def = new ObjDefine({ name: 'foo', name2: 'bar' }); - var obj = def.create(); + let def = new ObjDefine({ name: 'foo', name2: 'bar' }); + let obj = def.create(); expect(obj).to.not.have.property('name'); expect(obj).to.not.have.property('name2'); diff --git a/src/ui/public/utils/__tests__/SimpleEmitter.js b/src/ui/public/utils/__tests__/SimpleEmitter.js index 65d9045f2dde8..7e14c0c84e530 100644 --- a/src/ui/public/utils/__tests__/SimpleEmitter.js +++ b/src/ui/public/utils/__tests__/SimpleEmitter.js @@ -1,7 +1,7 @@ describe('SimpleEmitter class', function () { - var SimpleEmitter = require('ui/utils/SimpleEmitter'); - var expect = require('expect.js'); - var sinon = require('auto-release-sinon'); + let SimpleEmitter = require('ui/utils/SimpleEmitter'); + let expect = require('expect.js'); + let sinon = require('auto-release-sinon'); let emitter; beforeEach(function () { @@ -40,7 +40,7 @@ describe('SimpleEmitter class', function () { describe('#on', function () { it('registers a handler', function () { - var handler = sinon.stub(); + let handler = sinon.stub(); emitter.on('a', handler); expect(emitter.listenerCount('a')).to.be(1); @@ -56,7 +56,7 @@ describe('SimpleEmitter class', function () { }); it('allows the same function to be registered multiple times', function () { - var handler = function () {}; + let handler = function () {}; emitter.on('a', handler); expect(emitter.listenerCount()).to.be(1); emitter.on('a', handler); @@ -66,7 +66,7 @@ describe('SimpleEmitter class', function () { describe('#off', function () { it('removes a listener if it was registered', function () { - var handler = sinon.stub(); + let handler = sinon.stub(); expect(emitter.listenerCount()).to.be(0); emitter.on('a', handler); expect(emitter.listenerCount('a')).to.be(1); @@ -93,12 +93,12 @@ describe('SimpleEmitter class', function () { describe('#emit', function () { it('calls the handlers in the order they were defined', function () { - var i = 0; - var incr = function () { return ++i; }; - var one = sinon.spy(incr); - var two = sinon.spy(incr); - var three = sinon.spy(incr); - var four = sinon.spy(incr); + let i = 0; + let incr = function () { return ++i; }; + let one = sinon.spy(incr); + let two = sinon.spy(incr); + let three = sinon.spy(incr); + let four = sinon.spy(incr); emitter .on('a', one) @@ -122,11 +122,11 @@ describe('SimpleEmitter class', function () { it('always emits the handlers that were initially registered', function () { - var destructive = sinon.spy(function () { + let destructive = sinon.spy(function () { emitter.removeAllListeners(); expect(emitter.listenerCount()).to.be(0); }); - var stub = sinon.stub(); + let stub = sinon.stub(); emitter.on('run', destructive).on('run', stub).emit('run'); diff --git a/src/ui/public/utils/__tests__/add_word_breaks.js b/src/ui/public/utils/__tests__/add_word_breaks.js index 798c5d6e54bde..b8e9ee82b824b 100644 --- a/src/ui/public/utils/__tests__/add_word_breaks.js +++ b/src/ui/public/utils/__tests__/add_word_breaks.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var addWordBreaks = require('ui/utils/add_word_breaks'); +let _ = require('lodash'); +let expect = require('expect.js'); +let addWordBreaks = require('ui/utils/add_word_breaks'); describe('addWordBreaks', function () { - var fixtures = [ + let fixtures = [ ['aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa'], ['aaaa aaaaaaaaaaaaaaa', 'aaaa aaaaaaaaaaaaaaa'], ['aaaa;aaaaaaaaaaaaaaa', 'aaaa;aaaaaaaaaaaaaaa'], @@ -16,9 +16,9 @@ describe('addWordBreaks', function () { ]; _.each(fixtures, function (fixture) { - var msg = 'should convert ' + fixture[0] + ' to ' + fixture[1]; + let msg = 'should convert ' + fixture[0] + ' to ' + fixture[1]; it(msg, function () { - var results = addWordBreaks(fixture[0], 10); + let results = addWordBreaks(fixture[0], 10); expect(results).to.be(fixture[1]); }); }); diff --git a/src/ui/public/utils/__tests__/cidr_mask.js b/src/ui/public/utils/__tests__/cidr_mask.js index 9644a3eef9401..846a289c2eff7 100644 --- a/src/ui/public/utils/__tests__/cidr_mask.js +++ b/src/ui/public/utils/__tests__/cidr_mask.js @@ -1,6 +1,6 @@ -var CidrMask = require('ui/utils/CidrMask'); -var expect = require('expect.js'); +let CidrMask = require('ui/utils/CidrMask'); +let expect = require('expect.js'); describe('CidrMask', function () { it('should throw errors with invalid CIDR masks', function () { @@ -42,7 +42,7 @@ describe('CidrMask', function () { }); it('should correctly grab IP address and prefix length', function () { - var mask = new CidrMask('0.0.0.0/1'); + let mask = new CidrMask('0.0.0.0/1'); expect(mask.initialAddress.toString()).to.be('0.0.0.0'); expect(mask.prefixLength).to.be(1); @@ -52,8 +52,8 @@ describe('CidrMask', function () { }); it('should calculate a range of IP addresses', function () { - var mask = new CidrMask('0.0.0.0/1'); - var range = mask.getRange(); + let mask = new CidrMask('0.0.0.0/1'); + let range = mask.getRange(); expect(range.from.toString()).to.be('0.0.0.0'); expect(range.to.toString()).to.be('127.255.255.255'); @@ -69,7 +69,7 @@ describe('CidrMask', function () { }); it('toString()', function () { - var mask = new CidrMask('.../1'); + let mask = new CidrMask('.../1'); expect(mask.toString()).to.be('0.0.0.0/1'); mask = new CidrMask('128.0.0.1/31'); diff --git a/src/ui/public/utils/__tests__/datemath.js b/src/ui/public/utils/__tests__/datemath.js index 1fed8755297b9..e8eab1aeff4b5 100644 --- a/src/ui/public/utils/__tests__/datemath.js +++ b/src/ui/public/utils/__tests__/datemath.js @@ -1,15 +1,15 @@ -var dateMath = require('ui/utils/dateMath'); -var expect = require('expect.js'); -var moment = require('moment'); -var _ = require('lodash'); -var sinon = require('auto-release-sinon'); +let dateMath = require('ui/utils/dateMath'); +let expect = require('expect.js'); +let moment = require('moment'); +let _ = require('lodash'); +let sinon = require('auto-release-sinon'); describe('dateMath', function () { // Test each of these intervals when testing relative time - var spans = ['s', 'm', 'h', 'd', 'w', 'M', 'y']; - var anchor = '2014-01-01T06:06:06.666Z'; - var unix = moment(anchor).valueOf(); - var format = 'YYYY-MM-DDTHH:mm:ss.SSSZ'; + let spans = ['s', 'm', 'h', 'd', 'w', 'M', 'y']; + let anchor = '2014-01-01T06:06:06.666Z'; + let unix = moment(anchor).valueOf(); + let format = 'YYYY-MM-DDTHH:mm:ss.SSSZ'; let clock; describe('errors', function () { @@ -80,8 +80,8 @@ describe('dateMath', function () { }); _.each(spans, function (span) { - var nowEx = 'now-5' + span; - var thenEx = anchor + '||-5' + span; + let nowEx = 'now-5' + span; + let thenEx = anchor + '||-5' + span; it('should return 5' + span + ' ago', function () { expect(dateMath.parse(nowEx).format(format)).to.eql(now.subtract(5, span).format(format)); @@ -104,8 +104,8 @@ describe('dateMath', function () { }); _.each(spans, function (span) { - var nowEx = 'now+5' + span; - var thenEx = anchor + '||+5' + span; + let nowEx = 'now+5' + span; + let thenEx = anchor + '||+5' + span; it('should return 5' + span + ' from now', function () { expect(dateMath.parse(nowEx).format()).to.eql(now.add(5, span).format()); diff --git a/src/ui/public/utils/__tests__/diff_object.js b/src/ui/public/utils/__tests__/diff_object.js index 9260b5ad5d069..6759be17bdc9c 100644 --- a/src/ui/public/utils/__tests__/diff_object.js +++ b/src/ui/public/utils/__tests__/diff_object.js @@ -1,74 +1,74 @@ -var diff = require('ui/utils/diff_object'); -var expect = require('expect.js'); -var _ = require('lodash'); +let diff = require('ui/utils/diff_object'); +let expect = require('expect.js'); +let _ = require('lodash'); describe('ui/utils/diff_object', function () { it('should list the removed keys', function () { - var target = { test: 'foo' }; - var source = { foo: 'test' }; - var results = diff(target, source); + let target = { test: 'foo' }; + let source = { foo: 'test' }; + let results = diff(target, source); expect(results).to.have.property('removed'); expect(results.removed).to.eql(['test']); }); it('should list the changed keys', function () { - var target = { foo: 'bar' }; - var source = { foo: 'test' }; - var results = diff(target, source); + let target = { foo: 'bar' }; + let source = { foo: 'test' }; + let results = diff(target, source); expect(results).to.have.property('changed'); expect(results.changed).to.eql(['foo']); }); it('should list the added keys', function () { - var target = { }; - var source = { foo: 'test' }; - var results = diff(target, source); + let target = { }; + let source = { foo: 'test' }; + let results = diff(target, source); expect(results).to.have.property('added'); expect(results.added).to.eql(['foo']); }); it('should list all the keys that are change or removed', function () { - var target = { foo: 'bar', test: 'foo' }; - var source = { foo: 'test' }; - var results = diff(target, source); + let target = { foo: 'bar', test: 'foo' }; + let source = { foo: 'test' }; + let results = diff(target, source); expect(results).to.have.property('keys'); expect(results.keys).to.eql(['foo', 'test']); }); it('should ignore functions', function () { - var target = { foo: 'bar', test: 'foo' }; - var source = { foo: 'test', fn: _.noop }; + let target = { foo: 'bar', test: 'foo' }; + let source = { foo: 'test', fn: _.noop }; diff(target, source); expect(target).to.not.have.property('fn'); }); it('should ignore underscores', function () { - var target = { foo: 'bar', test: 'foo' }; - var source = { foo: 'test', _private: 'foo' }; + let target = { foo: 'bar', test: 'foo' }; + let source = { foo: 'test', _private: 'foo' }; diff(target, source); expect(target).to.not.have.property('_private'); }); it('should ignore dollar signs', function () { - var target = { foo: 'bar', test: 'foo' }; - var source = { foo: 'test', $private: 'foo' }; + let target = { foo: 'bar', test: 'foo' }; + let source = { foo: 'test', $private: 'foo' }; diff(target, source); expect(target).to.not.have.property('$private'); }); it('should not list any changes for similar objects', function () { - var target = { foo: 'bar', test: 'foo' }; - var source = { foo: 'bar', test: 'foo', $private: 'foo' }; - var results = diff(target, source); + let target = { foo: 'bar', test: 'foo' }; + let source = { foo: 'bar', test: 'foo', $private: 'foo' }; + let results = diff(target, source); expect(results.changed).to.be.empty(); }); it('should only change keys that actually changed', function () { - var obj = { 'message': 'foo' }; - var target = { obj: obj, message: 'foo' }; - var source = { obj: _.cloneDeep(obj), message: 'test' }; - var results = diff(target, source); + let obj = { 'message': 'foo' }; + let target = { obj: obj, message: 'foo' }; + let source = { obj: _.cloneDeep(obj), message: 'test' }; + let results = diff(target, source); expect(target.obj).to.be(obj); }); diff --git a/src/ui/public/utils/__tests__/diff_time_picker_vals.js b/src/ui/public/utils/__tests__/diff_time_picker_vals.js index 6c27a1364a49c..f5f5be669669b 100644 --- a/src/ui/public/utils/__tests__/diff_time_picker_vals.js +++ b/src/ui/public/utils/__tests__/diff_time_picker_vals.js @@ -1,7 +1,7 @@ -var moment = require('moment'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let moment = require('moment'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Diff Time Picker Values', function () { let diffTimePickerValues; @@ -12,13 +12,13 @@ describe('Diff Time Picker Values', function () { })); it('accepts two undefined values', function () { - var diff = diffTimePickerValues(undefined, undefined); + let diff = diffTimePickerValues(undefined, undefined); expect(diff).to.be(false); }); describe('dateMath ranges', function () { it('knows a match', function () { - var diff = diffTimePickerValues( + let diff = diffTimePickerValues( { to: 'now', from: 'now-7d' @@ -32,7 +32,7 @@ describe('Diff Time Picker Values', function () { expect(diff).to.be(false); }); it('knows a difference', function () { - var diff = diffTimePickerValues( + let diff = diffTimePickerValues( { to: 'now', from: 'now-7d' @@ -49,7 +49,7 @@ describe('Diff Time Picker Values', function () { describe('a dateMath range, and a moment range', function () { it('is always different', function () { - var diff = diffTimePickerValues( + let diff = diffTimePickerValues( { to: moment(), from: moment() @@ -66,10 +66,10 @@ describe('Diff Time Picker Values', function () { describe('moment ranges', function () { it('uses the time value of moments for comparison', function () { - var to = moment(); - var from = moment().add(1, 'day'); + let to = moment(); + let from = moment().add(1, 'day'); - var diff = diffTimePickerValues( + let diff = diffTimePickerValues( { to: to.clone(), from: from.clone() @@ -84,11 +84,11 @@ describe('Diff Time Picker Values', function () { }); it('fails if any to or from is different', function () { - var to = moment(); - var from = moment().add(1, 'day'); - var from2 = moment().add(2, 'day'); + let to = moment(); + let from = moment().add(1, 'day'); + let from2 = moment().add(2, 'day'); - var diff = diffTimePickerValues( + let diff = diffTimePickerValues( { to: to.clone(), from: from.clone() @@ -104,7 +104,7 @@ describe('Diff Time Picker Values', function () { }); it('does not fall apart with unusual values', function () { - var diff = diffTimePickerValues({}, {}); + let diff = diffTimePickerValues({}, {}); expect(diff).to.be(false); }); }); diff --git a/src/ui/public/utils/__tests__/ordinal_suffix.js b/src/ui/public/utils/__tests__/ordinal_suffix.js index 1c63aa0aa8372..0ad67e726b79e 100644 --- a/src/ui/public/utils/__tests__/ordinal_suffix.js +++ b/src/ui/public/utils/__tests__/ordinal_suffix.js @@ -1,9 +1,9 @@ -var _ = require('lodash'); -var addOrdinalSuffix = require('ui/utils/ordinal_suffix'); -var expect = require('expect.js'); +let _ = require('lodash'); +let addOrdinalSuffix = require('ui/utils/ordinal_suffix'); +let expect = require('expect.js'); describe('ordinal suffix util', function () { - var checks = { + let checks = { 1: 'st', 2: 'nd', 3: 'rd', @@ -37,8 +37,8 @@ describe('ordinal suffix util', function () { }; _.forOwn(checks, function (expected, num) { - var int = parseInt(num, 10); - var float = int + Math.random(); + let int = parseInt(num, 10); + let float = int + Math.random(); it('knowns ' + int, function () { expect(addOrdinalSuffix(num)).to.be(num + '' + expected); diff --git a/src/ui/public/utils/__tests__/parse_interval.js b/src/ui/public/utils/__tests__/parse_interval.js index 79ca8137d8be7..04b00404d2f97 100644 --- a/src/ui/public/utils/__tests__/parse_interval.js +++ b/src/ui/public/utils/__tests__/parse_interval.js @@ -1,9 +1,9 @@ -var parseInterval = require('ui/utils/parse_interval'); -var expect = require('expect.js'); +let parseInterval = require('ui/utils/parse_interval'); +let expect = require('expect.js'); describe('parseInterval', function () { it('should correctly parse an interval containing unit and value', function () { - var duration = parseInterval('1d'); + let duration = parseInterval('1d'); expect(duration.as('d')).to.be(1); duration = parseInterval('2y'); @@ -26,7 +26,7 @@ describe('parseInterval', function () { }); it('should correctly parse fractional intervals containing unit and value', function () { - var duration = parseInterval('1.5w'); + let duration = parseInterval('1.5w'); expect(duration.as('w')).to.be(1.5); duration = parseInterval('2.35y'); @@ -34,7 +34,7 @@ describe('parseInterval', function () { }); it('should correctly bubble up intervals which are less than 1', function () { - var duration = parseInterval('0.5y'); + let duration = parseInterval('0.5y'); expect(duration.as('d')).to.be(183); duration = parseInterval('0.5d'); @@ -42,7 +42,7 @@ describe('parseInterval', function () { }); it('should correctly parse a unit in an interval only', function () { - var duration = parseInterval('d'); + let duration = parseInterval('d'); expect(duration.as('d')).to.be(1); duration = parseInterval('m'); @@ -56,7 +56,7 @@ describe('parseInterval', function () { }); it('should return null for an invalid interval', function () { - var duration = parseInterval(''); + let duration = parseInterval(''); expect(duration).to.not.be.ok(); duration = parseInterval(null); diff --git a/src/ui/public/utils/__tests__/range.js b/src/ui/public/utils/__tests__/range.js index 9cd2a1a0715c6..d004ae6b5fd45 100644 --- a/src/ui/public/utils/__tests__/range.js +++ b/src/ui/public/utils/__tests__/range.js @@ -1,7 +1,7 @@ describe('Range parsing utility', function () { - var _ = require('lodash'); - var expect = require('expect.js'); - var parse = require('ui/utils/range'); + let _ = require('lodash'); + let expect = require('expect.js'); + let parse = require('ui/utils/range'); it('throws an error for inputs that are not formatted properly', function () { expect(function () { @@ -25,7 +25,7 @@ describe('Range parsing utility', function () { }).to.throwException(TypeError); }); - var tests = { + let tests = { '[ 0 , 100 ]': { props: { min: 0, @@ -92,7 +92,7 @@ describe('Range parsing utility', function () { _.forOwn(tests, function (spec, str) { describe(str, function () { - var range = parse(str); + let range = parse(str); it('creation', function () { expect(range).to.eql(spec.props); diff --git a/src/ui/public/utils/__tests__/scanner.js b/src/ui/public/utils/__tests__/scanner.js index 495a546a87816..68ea8ce660402 100644 --- a/src/ui/public/utils/__tests__/scanner.js +++ b/src/ui/public/utils/__tests__/scanner.js @@ -1,9 +1,9 @@ -var Scanner = require('ui/utils/scanner'); -var expect = require('expect.js'); -var elasticsearch = require('elasticsearch-browser'); -var sinon = require('sinon'); +let Scanner = require('ui/utils/scanner'); +let expect = require('expect.js'); +let elasticsearch = require('elasticsearch-browser'); +let sinon = require('sinon'); -var es = new elasticsearch.Client({ +let es = new elasticsearch.Client({ host: 'http://localhost:9210', }); diff --git a/src/ui/public/utils/__tests__/sequencer.js b/src/ui/public/utils/__tests__/sequencer.js index 3225673e05f21..551e3a27f503f 100644 --- a/src/ui/public/utils/__tests__/sequencer.js +++ b/src/ui/public/utils/__tests__/sequencer.js @@ -1,9 +1,9 @@ describe('sequencer util', function () { - var _ = require('lodash'); - var sequencer = require('ui/utils/sequencer'); - var expect = require('expect.js'); + let _ = require('lodash'); + let sequencer = require('ui/utils/sequencer'); + let expect = require('expect.js'); - var opts = [ + let opts = [ { min: 500, max: 7500, length: 1500 }, { min: 50, max: 500, length: 1000 }, { min: 5, max: 50, length: 100 } diff --git a/src/ui/public/utils/__tests__/slugify_id.js b/src/ui/public/utils/__tests__/slugify_id.js index 85d880f441edd..9f2945cf8824c 100644 --- a/src/ui/public/utils/__tests__/slugify_id.js +++ b/src/ui/public/utils/__tests__/slugify_id.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var slugifyId = require('ui/utils/slugify_id'); -var expect = require('expect.js'); +let _ = require('lodash'); +let slugifyId = require('ui/utils/slugify_id'); +let expect = require('expect.js'); describe('slugifyId()', function () { - var fixtures = [ + let fixtures = [ ['test/test', 'test-slash-test'], ['test?test', 'test-questionmark-test'], ['test=test', 'test-equal-test'], @@ -24,9 +24,9 @@ describe('slugifyId()', function () { ]; _.each(fixtures, function (fixture) { - var msg = 'should convert ' + fixture[0] + ' to ' + fixture[1]; + let msg = 'should convert ' + fixture[0] + ' to ' + fixture[1]; it(msg, function () { - var results = slugifyId(fixture[0]); + let results = slugifyId(fixture[0]); expect(results).to.be(fixture[1]); }); }); diff --git a/src/ui/public/utils/lodash-mixins/__tests__/_move.js b/src/ui/public/utils/lodash-mixins/__tests__/_move.js index 4d89a7f29cec2..6f6c72c65107f 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_move.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_move.js @@ -1,9 +1,9 @@ describe('_.move', function () { - var _ = require('lodash'); - var expect = require('expect.js'); + let _ = require('lodash'); + let expect = require('expect.js'); it('accepts previous from->to syntax', function () { - var list = [ + let list = [ 1, 1, 1, @@ -27,7 +27,7 @@ describe('_.move', function () { }); it('moves an object up based on a function callback', function () { - var list = [ + let list = [ 1, 1, 1, @@ -55,7 +55,7 @@ describe('_.move', function () { }); it('moves an object down based on a function callback', function () { - var list = [ + let list = [ 1, 1, 1, @@ -83,7 +83,7 @@ describe('_.move', function () { }); it('moves an object up based on a where callback', function () { - var list = [ + let list = [ { v: 1 }, { v: 1 }, { v: 1 }, @@ -110,7 +110,7 @@ describe('_.move', function () { it('moves an object up based on a where callback', function () { - var list = [ + let list = [ { v: 1 }, { v: 1 }, { v: 1 }, @@ -136,7 +136,7 @@ describe('_.move', function () { }); it('moves an object down based on a pluck callback', function () { - var list = [ + let list = [ { id: 0, normal: true }, { id: 1, normal: true }, { id: 2, normal: true }, diff --git a/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js b/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js index 3832d77f230ec..792d3a988d318 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js @@ -1,9 +1,9 @@ describe('_.organize', function () { - var _ = require('lodash'); - var expect = require('expect.js'); + let _ = require('lodash'); + let expect = require('expect.js'); it('it works', function () { - var col = [ + let col = [ { name: 'one', roles: ['user', 'admin', 'owner'] @@ -22,7 +22,7 @@ describe('_.organize', function () { } ]; - var resp = _.organizeBy(col, 'roles'); + let resp = _.organizeBy(col, 'roles'); expect(resp).to.have.property('user'); expect(resp.user).to.have.length(4); @@ -34,15 +34,15 @@ describe('_.organize', function () { }); it('behaves just like groupBy in normal scenarios', function () { - var col = [ + let col = [ { name: 'one' }, { name: 'two' }, { name: 'three' }, { name: 'four' } ]; - var orgs = _.organizeBy(col, 'name'); - var groups = _.groupBy(col, 'name'); + let orgs = _.organizeBy(col, 'name'); + let groups = _.groupBy(col, 'name'); expect(orgs).to.eql(groups); }); }); diff --git a/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js b/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js index 25925947a1062..08525d9f4f9c7 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js @@ -1,12 +1,12 @@ describe('_.pushAll', function () { - var _ = require('lodash'); - var expect = require('expect.js'); + let _ = require('lodash'); + let expect = require('expect.js'); it('pushes an entire array into another', function () { - var a = [1, 2, 3, 4]; - var b = [5, 6, 7, 8]; + let a = [1, 2, 3, 4]; + let b = [5, 6, 7, 8]; - var output = _.pushAll(b, a); + let output = _.pushAll(b, a); expect(output).to.be(a); expect(a).to.eql([1, 2, 3, 4, 5, 6, 7, 8]); expect(b).to.eql([5, 6, 7, 8]); diff --git a/src/ui/public/vislib/__tests__/components/color.js b/src/ui/public/vislib/__tests__/components/color.js index 15228bb4d3fd0..37859656f3920 100644 --- a/src/ui/public/vislib/__tests__/components/color.js +++ b/src/ui/public/vislib/__tests__/components/color.js @@ -1,6 +1,6 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); const _ = require('lodash'); const d3 = require('d3'); @@ -12,14 +12,14 @@ describe('Vislib Color Module Test Suite', function () { describe('Color (main)', function () { let previousConfig; let getColors; - var arr = ['good', 'better', 'best', 'never', 'let', 'it', 'rest']; - var arrayOfNumbers = [1, 2, 3, 4, 5]; - var arrayOfUndefinedValues = [undefined, undefined, undefined]; - var arrayOfObjects = [{}, {}, {}]; - var arrayOfBooleans = [true, false, true]; - var arrayOfNullValues = [null, null, null]; - var emptyObject = {}; - var nullValue = null; + let arr = ['good', 'better', 'best', 'never', 'let', 'it', 'rest']; + let arrayOfNumbers = [1, 2, 3, 4, 5]; + let arrayOfUndefinedValues = [undefined, undefined, undefined]; + let arrayOfObjects = [{}, {}, {}]; + let arrayOfBooleans = [true, false, true]; + let arrayOfNullValues = [null, null, null]; + let emptyObject = {}; + let nullValue = null; let notAValue; let color; @@ -239,14 +239,14 @@ describe('Vislib Color Module Test Suite', function () { }); describe('Color Palette', function () { - var num1 = 45; - var num2 = 72; - var num3 = 90; - var string = 'Welcome'; - var bool = true; - var nullValue = null; - var emptyArr = []; - var emptyObject = {}; + let num1 = 45; + let num2 = 72; + let num3 = 90; + let string = 'Welcome'; + let bool = true; + let nullValue = null; + let emptyArr = []; + let emptyObject = {}; let notAValue; let createColorPalette; let colorPalette; diff --git a/src/ui/public/vislib/__tests__/components/labels.js b/src/ui/public/vislib/__tests__/components/labels.js index d4cf64095084d..3c3cef42ab9e1 100644 --- a/src/ui/public/vislib/__tests__/components/labels.js +++ b/src/ui/public/vislib/__tests__/components/labels.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); let getLabels; let seriesLabels; @@ -11,7 +11,7 @@ let rowsArr; let uniqLabels; let error; -var seriesData = { +let seriesData = { 'label': '', 'series': [ { @@ -21,7 +21,7 @@ var seriesData = { ] }; -var rowsData = { +let rowsData = { 'rows': [ { 'label': 'a', @@ -62,7 +62,7 @@ var rowsData = { ] }; -var columnsData = { +let columnsData = { 'columns': [ { 'label': 'a', @@ -148,23 +148,23 @@ describe('Vislib Labels Module Test Suite', function () { }); describe('Data array', function () { - var childrenObject = { + let childrenObject = { children: [] }; - var seriesObject = { + let seriesObject = { series: [] }; - var rowsObject = { + let rowsObject = { rows: [] }; - var columnsObject = { + let columnsObject = { columns: [] }; - var string = 'string'; - var number = 23; - var boolean = false; - var emptyArray = []; - var nullValue = null; + let string = 'string'; + let number = 23; + let boolean = false; + let emptyArray = []; + let nullValue = null; let notAValue; let dataArray; let testSeries; @@ -263,7 +263,7 @@ describe('Vislib Labels Module Test Suite', function () { describe('Unique labels', function () { let uniqLabels; - var arrObj = [ + let arrObj = [ {'label': 'a'}, {'label': 'b'}, {'label': 'b'}, @@ -272,12 +272,12 @@ describe('Vislib Labels Module Test Suite', function () { {'label': 'd'}, {'label': 'f'} ]; - var string = 'string'; - var number = 24; - var boolean = false; - var nullValue = null; - var emptyObject = {}; - var emptyArray = []; + let string = 'string'; + let number = 24; + let boolean = false; + let nullValue = null; + let emptyObject = {}; + let emptyArray = []; let notAValue; let uniq; let testArr; @@ -336,18 +336,18 @@ describe('Vislib Labels Module Test Suite', function () { }); describe('Get series', function () { - var string = 'string'; - var number = 24; - var boolean = false; - var nullValue = null; - var rowsObject = { + let string = 'string'; + let number = 24; + let boolean = false; + let nullValue = null; + let rowsObject = { rows: [] }; - var columnsObject = { + let columnsObject = { columns: [] }; - var emptyObject = {}; - var emptyArray = []; + let emptyObject = {}; + let emptyArray = []; let notAValue; let getSeries; let columnsLabels; diff --git a/src/ui/public/vislib/__tests__/components/zero_injection.js b/src/ui/public/vislib/__tests__/components/zero_injection.js index eb628c9980b48..ee8645f4d664b 100644 --- a/src/ui/public/vislib/__tests__/components/zero_injection.js +++ b/src/ui/public/vislib/__tests__/components/zero_injection.js @@ -1,11 +1,11 @@ -var angular = require('angular'); -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let angular = require('angular'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Vislib Zero Injection Module Test Suite', function () { - var dateHistogramRows = { + let dateHistogramRows = { 'rows': [ { 'label': 'Top 5 @tags: success', @@ -155,7 +155,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var seriesData = { + let seriesData = { series: [ { label: '200', @@ -170,7 +170,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var multiSeriesData = { + let multiSeriesData = { series: [ { label: '200', @@ -199,7 +199,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var multiSeriesNumberedData = { + let multiSeriesNumberedData = { series: [ { label: '200', @@ -228,24 +228,24 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var childrenObject = { + let childrenObject = { children: [] }; - var seriesObject = { + let seriesObject = { series: [] }; - var rowsObject = { + let rowsObject = { rows: [] }; - var columnsObject = { + let columnsObject = { columns: [] }; - var emptyObject = {}; - var str = 'string'; - var number = 24; - var boolean = false; - var nullValue = null; - var emptyArray = []; + let emptyObject = {}; + let str = 'string'; + let number = 24; + let boolean = false; + let nullValue = null; + let emptyArray = []; let notAValue; describe('Zero Injection (main)', function () { @@ -491,8 +491,8 @@ describe('Vislib Zero Injection Module Test Suite', function () { describe('Zero Filled Array', function () { let createZeroArray; - var arr1 = [1, 2, 3, 4, 5]; - var arr2 = ['1', '2', '3', '4', '5']; + let arr1 = [1, 2, 3, 4, 5]; + let arr2 = ['1', '2', '3', '4', '5']; let results1; let results2; @@ -572,10 +572,10 @@ describe('Vislib Zero Injection Module Test Suite', function () { describe('Zero Filled Data Array', function () { let zeroFillArray; - var xValueArr = [1, 2, 3, 4, 5]; + let xValueArr = [1, 2, 3, 4, 5]; let createZeroArray; let arr1; - var arr2 = [ {x: 3, y: 834} ]; + let arr2 = [ {x: 3, y: 834} ]; let results; beforeEach(ngMock.module('kibana')); @@ -653,7 +653,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { }); it('should return ordered x values', function () { - var values = results.rows[0].series[0].values; + let values = results.rows[0].series[0].values; expect(values[0].x).to.be.lessThan(values[1].x); expect(values[1].x).to.be.lessThan(values[2].x); expect(values[2].x).to.be.lessThan(values[3].x); diff --git a/src/ui/public/vislib/__tests__/index.js b/src/ui/public/vislib/__tests__/index.js index 921f896db915c..fc3d02ed5aec5 100644 --- a/src/ui/public/vislib/__tests__/index.js +++ b/src/ui/public/vislib/__tests__/index.js @@ -1,11 +1,11 @@ -var _ = require('lodash'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var d3 = require('d3'); +let _ = require('lodash'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let d3 = require('d3'); require('ui/vislib/styles/main.less'); -var angular = require('angular'); +let angular = require('angular'); describe('Vislib Index Test Suite', function () { let vislib; diff --git a/src/ui/public/vislib/__tests__/lib/axis_title.js b/src/ui/public/vislib/__tests__/lib/axis_title.js index 9c8eac24e4444..b42019dbeb9c0 100644 --- a/src/ui/public/vislib/__tests__/lib/axis_title.js +++ b/src/ui/public/vislib/__tests__/lib/axis_title.js @@ -1,9 +1,9 @@ -var d3 = require('d3'); -var angular = require('angular'); -var _ = require('lodash'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let _ = require('lodash'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib AxisTitle Class Test Suite', function () { let AxisTitle; @@ -14,7 +14,7 @@ describe('Vislib AxisTitle Class Test Suite', function () { let dataObj; let xTitle; let yTitle; - var data = { + let data = { hits: 621, label: '', ordered: { diff --git a/src/ui/public/vislib/__tests__/lib/chart_title.js b/src/ui/public/vislib/__tests__/lib/chart_title.js index 948f683323ae5..f87a0495db6c3 100644 --- a/src/ui/public/vislib/__tests__/lib/chart_title.js +++ b/src/ui/public/vislib/__tests__/lib/chart_title.js @@ -1,9 +1,9 @@ -var d3 = require('d3'); -var angular = require('angular'); -var _ = require('lodash'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let _ = require('lodash'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib ChartTitle Class Test Suite', function () { let ChartTitle; @@ -12,7 +12,7 @@ describe('Vislib ChartTitle Class Test Suite', function () { let chartTitle; let el; let dataObj; - var data = { + let data = { hits: 621, label: '', ordered: { diff --git a/src/ui/public/vislib/__tests__/lib/data.js b/src/ui/public/vislib/__tests__/lib/data.js index f6bf399865c9a..3f39ddb2f6261 100644 --- a/src/ui/public/vislib/__tests__/lib/data.js +++ b/src/ui/public/vislib/__tests__/lib/data.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var _ = require('lodash'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let angular = require('angular'); +let _ = require('lodash'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); -var dataSeries = require('fixtures/vislib/mock_data/date_histogram/_series'); -var dataSeriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); -var dataStacked = require('fixtures/vislib/mock_data/stacked/_stacked'); +let dataSeries = require('fixtures/vislib/mock_data/date_histogram/_series'); +let dataSeriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); +let dataStacked = require('fixtures/vislib/mock_data/stacked/_stacked'); -var seriesData = { +let seriesData = { 'label': '', 'series': [ { @@ -17,7 +17,7 @@ var seriesData = { ] }; -var rowsData = { +let rowsData = { 'rows': [ { 'label': 'a', @@ -58,7 +58,7 @@ var rowsData = { ] }; -var colsData = { +let colsData = { 'columns': [ { 'label': 'a', @@ -115,12 +115,12 @@ describe('Vislib Data Class Test Suite', function () { }); it('should return an object', function () { - var rowIn = new Data(rowsData, {}, persistedState); + let rowIn = new Data(rowsData, {}, persistedState); expect(_.isObject(rowIn)).to.be(true); }); it('should update label in series data', function () { - var seriesDataWithoutLabelInSeries = { + let seriesDataWithoutLabelInSeries = { 'label': '', 'series': [ { @@ -130,12 +130,12 @@ describe('Vislib Data Class Test Suite', function () { ], 'yAxisLabel': 'customLabel' }; - var modifiedData = new Data(seriesDataWithoutLabelInSeries, {}, persistedState); + let modifiedData = new Data(seriesDataWithoutLabelInSeries, {}, persistedState); expect(modifiedData.data.series[0].label).to.be('customLabel'); }); it('should update label in row data', function () { - var seriesDataWithoutLabelInRow = { + let seriesDataWithoutLabelInRow = { 'rows': [ { 'label': '', @@ -160,13 +160,13 @@ describe('Vislib Data Class Test Suite', function () { ], }; - var modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState); + let modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState); expect(modifiedData.data.rows[0].series[0].label).to.be('customLabel'); expect(modifiedData.data.rows[1].series[0].label).to.be('customLabel'); }); it('should update label in column data', function () { - var seriesDataWithoutLabelInRow = { + let seriesDataWithoutLabelInRow = { 'columns': [ { 'label': '', @@ -192,7 +192,7 @@ describe('Vislib Data Class Test Suite', function () { 'yAxisLabel': 'customLabel' }; - var modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState); + let modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState); expect(modifiedData.data.columns[0].series[0].label).to.be('customLabel'); expect(modifiedData.data.columns[1].series[0].label).to.be('customLabel'); }); @@ -201,7 +201,7 @@ describe('Vislib Data Class Test Suite', function () { describe('_removeZeroSlices', function () { let data; - var pieData = { + let pieData = { slices: { children: [ {size: 30}, @@ -216,7 +216,7 @@ describe('Vislib Data Class Test Suite', function () { }); it('should remove zero values', function () { - var slices = data._removeZeroSlices(data.data.slices); + let slices = data._removeZeroSlices(data.data.slices); expect(slices.children.length).to.be(2); }); }); @@ -248,8 +248,8 @@ describe('Vislib Data Class Test Suite', function () { function testLength(inputData) { return function () { - var data = new Data(inputData, {}, persistedState); - var len = _.reduce(data.chartData(), function (sum, chart) { + let data = new Data(inputData, {}, persistedState); + let len = _.reduce(data.chartData(), function (sum, chart) { return sum + chart.series.reduce(function (sum, series) { return sum + series.values.length; }, 0); @@ -264,9 +264,9 @@ describe('Vislib Data Class Test Suite', function () { let visData; let visDataNeg; let visDataStacked; - var minValue = 4; - var minValueNeg = -41; - var minValueStacked = 15; + let minValue = 4; + let minValueNeg = -41; + let minValueStacked = 15; beforeEach(function () { visData = new Data(dataSeries, {}, persistedState); @@ -284,15 +284,15 @@ describe('Vislib Data Class Test Suite', function () { }); it('should have a minimum date value that is greater than the max value within the date range', function () { - var series = _.pluck(visData.chartData(), 'series'); - var stackedSeries = _.pluck(visDataStacked.chartData(), 'series'); + let series = _.pluck(visData.chartData(), 'series'); + let stackedSeries = _.pluck(visDataStacked.chartData(), 'series'); expect(_.min(series.values, function (d) { return d.x; })).to.be.greaterThan(minValue); expect(_.min(stackedSeries.values, function (d) { return d.x; })).to.be.greaterThan(minValueStacked); }); it('allows passing a value getter for manipulating the values considered', function () { - var realMin = visData.getYMin(); - var multiplier = 13.2; + let realMin = visData.getYMin(); + let multiplier = 13.2; expect(visData.getYMin(function (d) { return d.y * multiplier; })).to.be(realMin * multiplier); }); }); @@ -301,9 +301,9 @@ describe('Vislib Data Class Test Suite', function () { let visData; let visDataNeg; let visDataStacked; - var maxValue = 41; - var maxValueNeg = -4; - var maxValueStacked = 115; + let maxValue = 41; + let maxValueNeg = -4; + let maxValueStacked = 115; beforeEach(function () { visData = new Data(dataSeries, {}, persistedState); @@ -321,22 +321,22 @@ describe('Vislib Data Class Test Suite', function () { }); it('should have a minimum date value that is greater than the max value within the date range', function () { - var series = _.pluck(visData.chartData(), 'series'); - var stackedSeries = _.pluck(visDataStacked.chartData(), 'series'); + let series = _.pluck(visData.chartData(), 'series'); + let stackedSeries = _.pluck(visDataStacked.chartData(), 'series'); expect(_.min(series, function (d) { return d.x; })).to.be.greaterThan(maxValue); expect(_.min(stackedSeries, function (d) { return d.x; })).to.be.greaterThan(maxValueStacked); }); it('allows passing a value getter for manipulating the values considered', function () { - var realMax = visData.getYMax(); - var multiplier = 13.2; + let realMax = visData.getYMax(); + let multiplier = 13.2; expect(visData.getYMax(function (d) { return d.y * multiplier; })).to.be(realMax * multiplier); }); }); describe('geohashGrid methods', function () { let data; - var geohashGridData = { + let geohashGridData = { hits: 3954, rows: [{ title: 'Top 5 _type: apache', @@ -379,14 +379,14 @@ describe('Vislib Data Class Test Suite', function () { describe('getVisData', function () { it('should return the rows property', function () { - var visData = data.getVisData(); + let visData = data.getVisData(); expect(visData).to.eql(geohashGridData.rows); }); }); describe('getGeoExtents', function () { it('should return the min and max geoJson properties', function () { - var minMax = data.getGeoExtents(); + let minMax = data.getGeoExtents(); expect(minMax.min).to.be(1); expect(minMax.max).to.be(331); }); @@ -395,12 +395,12 @@ describe('Vislib Data Class Test Suite', function () { describe('null value check', function () { it('should return false', function () { - var data = new Data(rowsData, {}, persistedState); + let data = new Data(rowsData, {}, persistedState); expect(data.hasNullValues()).to.be(false); }); it('should return true', function () { - var nullRowData = { rows: rowsData.rows.slice(0) }; + let nullRowData = { rows: rowsData.rows.slice(0) }; nullRowData.rows.push({ 'label': 'e', 'series': [ @@ -411,7 +411,7 @@ describe('Vislib Data Class Test Suite', function () { ] }); - var data = new Data(nullRowData, {}, persistedState); + let data = new Data(nullRowData, {}, persistedState); expect(data.hasNullValues()).to.be(true); }); }); diff --git a/src/ui/public/vislib/__tests__/lib/dispatch.js b/src/ui/public/vislib/__tests__/lib/dispatch.js index 125ff4a1f65ba..af426ac532e29 100644 --- a/src/ui/public/vislib/__tests__/lib/dispatch.js +++ b/src/ui/public/vislib/__tests__/lib/dispatch.js @@ -1,12 +1,12 @@ -var angular = require('angular'); -var _ = require('lodash'); -var $ = require('jquery'); -var d3 = require('d3'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let angular = require('angular'); +let _ = require('lodash'); +let $ = require('jquery'); +let d3 = require('d3'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); // Data -var data = require('fixtures/vislib/mock_data/date_histogram/_series'); +let data = require('fixtures/vislib/mock_data/date_histogram/_series'); describe('Vislib Dispatch Class Test Suite', function () { @@ -37,7 +37,7 @@ describe('Vislib Dispatch Class Test Suite', function () { }); it('extends the SimpleEmitter class', function () { - var events = _.pluck(vis.handler.charts, 'events'); + let events = _.pluck(vis.handler.charts, 'events'); expect(events.length).to.be.above(0); events.forEach(function (dispatch) { expect(dispatch).to.be.a(SimpleEmitter); @@ -63,11 +63,11 @@ describe('Vislib Dispatch Class Test Suite', function () { describe('addEvent method', function () { it('returns a function that binds the passed event to a selection', function () { - var chart = _.first(vis.handler.charts); - var apply = chart.events.addEvent('event', _.noop); + let chart = _.first(vis.handler.charts); + let apply = chart.events.addEvent('event', _.noop); expect(apply).to.be.a('function'); - var els = getEls(vis.el, 3, 'div'); + let els = getEls(vis.el, 3, 'div'); apply(els); els.each(function () { expect(d3.select(this).on('event')).to.be(_.noop); @@ -86,11 +86,11 @@ describe('Vislib Dispatch Class Test Suite', function () { }); it('returns a function that binds ' + event + ' events to a selection', function () { - var chart = _.first(vis.handler.charts); - var apply = chart.events[name](d3.select(document.createElement('svg'))); + let chart = _.first(vis.handler.charts); + let apply = chart.events[name](d3.select(document.createElement('svg'))); expect(apply).to.be.a('function'); - var els = getEls(vis.el, 3, 'div'); + let els = getEls(vis.el, 3, 'div'); apply(els); els.each(function () { expect(d3.select(this).on(event)).to.be.a('function'); @@ -107,7 +107,7 @@ describe('Vislib Dispatch Class Test Suite', function () { describe('addMousePointer method', function () { it('should be a function', function () { vis.handler.charts.forEach(function (chart) { - var pointer = chart.events.addMousePointer; + let pointer = chart.events.addMousePointer; expect(_.isFunction(pointer)).to.be(true); }); diff --git a/src/ui/public/vislib/__tests__/lib/error_handler.js b/src/ui/public/vislib/__tests__/lib/error_handler.js index 64049675f3d02..4cc6789d9fa59 100644 --- a/src/ui/public/vislib/__tests__/lib/error_handler.js +++ b/src/ui/public/vislib/__tests__/lib/error_handler.js @@ -1,7 +1,7 @@ -var expect = require('expect.js'); -var angular = require('angular'); -var ngMock = require('ngMock'); +let expect = require('expect.js'); +let angular = require('angular'); +let ngMock = require('ngMock'); describe('Vislib ErrorHandler Test Suite', function () { let ErrorHandler; diff --git a/src/ui/public/vislib/__tests__/lib/handler/handler.js b/src/ui/public/vislib/__tests__/lib/handler/handler.js index 43bc998fb325c..5d806b98fe032 100644 --- a/src/ui/public/vislib/__tests__/lib/handler/handler.js +++ b/src/ui/public/vislib/__tests__/lib/handler/handler.js @@ -1,21 +1,21 @@ -var angular = require('angular'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let angular = require('angular'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); // Data -var series = require('fixtures/vislib/mock_data/date_histogram/_series'); -var columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); -var rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); -var stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); -var dateHistogramArray = [ +let series = require('fixtures/vislib/mock_data/date_histogram/_series'); +let columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); +let rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); +let stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); +let dateHistogramArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', @@ -27,7 +27,7 @@ dateHistogramArray.forEach(function (data, i) { let Handler; let vis; let persistedState; - var events = [ + let events = [ 'click', 'brush' ]; diff --git a/src/ui/public/vislib/__tests__/lib/layout/layout.js b/src/ui/public/vislib/__tests__/lib/layout/layout.js index eb9921088950f..cc529a5b8dcd9 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/layout.js +++ b/src/ui/public/vislib/__tests__/lib/layout/layout.js @@ -1,21 +1,21 @@ -var d3 = require('d3'); -var angular = require('angular'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); // Data -var series = require('fixtures/vislib/mock_data/date_histogram/_series'); -var columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); -var rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); -var stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); -var dateHistogramArray = [ +let series = require('fixtures/vislib/mock_data/date_histogram/_series'); +let columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); +let rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); +let stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); +let dateHistogramArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', diff --git a/src/ui/public/vislib/__tests__/lib/layout/layout_types.js b/src/ui/public/vislib/__tests__/lib/layout/layout_types.js index c85a2561e8da0..924ca18dda7ec 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/layout_types.js +++ b/src/ui/public/vislib/__tests__/lib/layout/layout_types.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var _ = require('lodash'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let angular = require('angular'); +let _ = require('lodash'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib Layout Types Test Suite', function () { let layoutType; diff --git a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js index 4ef36bfac09d4..1c0c4dda07dc3 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js +++ b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js @@ -1,8 +1,8 @@ -var d3 = require('d3'); -var angular = require('angular'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib Split Function Test Suite', function () { describe('Column Chart', function () { @@ -11,7 +11,7 @@ describe('Vislib Split Function Test Suite', function () { let xAxisSplit; let yAxisSplit; let el; - var data = { + let data = { rows: [ { hits : 621, diff --git a/src/ui/public/vislib/__tests__/lib/layout/types/column_layout.js b/src/ui/public/vislib/__tests__/lib/layout/types/column_layout.js index c0dc4ea100d72..690a41f7b4653 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/types/column_layout.js +++ b/src/ui/public/vislib/__tests__/lib/layout/types/column_layout.js @@ -1,14 +1,14 @@ -var d3 = require('d3'); -var angular = require('angular'); -var _ = require('lodash'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let _ = require('lodash'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib Column Layout Test Suite', function () { let layoutType; let columnLayout; let el; - var data = { + let data = { hits: 621, label: '', ordered: { diff --git a/src/ui/public/vislib/__tests__/lib/resize_checker.js b/src/ui/public/vislib/__tests__/lib/resize_checker.js index 5841e0f35a8f8..234d2dd45fa13 100644 --- a/src/ui/public/vislib/__tests__/lib/resize_checker.js +++ b/src/ui/public/vislib/__tests__/lib/resize_checker.js @@ -1,19 +1,19 @@ describe('Vislib Resize Checker', function () { - var $ = require('jquery'); - var _ = require('lodash'); - var Promise = require('bluebird'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); + let $ = require('jquery'); + let _ = require('lodash'); + let Promise = require('bluebird'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); - var sinon = require('auto-release-sinon'); + let sinon = require('auto-release-sinon'); require('testUtils/noDigestPromises').activateForSuite(); let ResizeChecker; let EventEmitter; let checker; let reflowWatcher; - var reflowSpies = {}; + let reflowSpies = {}; beforeEach(ngMock.module('kibana')); @@ -24,7 +24,7 @@ describe('Vislib Resize Checker', function () { reflowSpies.on = sinon.spy(reflowWatcher, 'on'); reflowSpies.off = sinon.spy(reflowWatcher, 'off'); - var $el = $(document.createElement('div')) + let $el = $(document.createElement('div')) .appendTo('body') .css('visibility', 'hidden') .get(0); @@ -44,7 +44,7 @@ describe('Vislib Resize Checker', function () { it('listens for the "reflow" event of the reflowWatchers', function () { expect(reflowSpies.on).to.have.property('callCount', 1); - var call = reflowSpies.on.getCall(0); + let call = reflowSpies.on.getCall(0); expect(call.args[0]).to.be('reflow'); }); @@ -60,8 +60,8 @@ describe('Vislib Resize Checker', function () { describe('#read', function () { it('gets the proper dimensions for the element', function () { - var dimensions = checker.read(); - var windowWidth = document.documentElement.clientWidth; + let dimensions = checker.read(); + let windowWidth = document.documentElement.clientWidth; expect(dimensions.w).to.equal(windowWidth); expect(dimensions.h).to.equal(0); @@ -70,7 +70,7 @@ describe('Vislib Resize Checker', function () { describe('#saveSize', function () { it('calls #read() when no arg is passed', function () { - var stub = sinon.stub(checker, 'read').returns({}); + let stub = sinon.stub(checker, 'read').returns({}); checker.saveSize(); @@ -78,7 +78,7 @@ describe('Vislib Resize Checker', function () { }); it('saves the size of the element', function () { - var football = {}; + let football = {}; checker.saveSize(football); expect(checker).to.have.property('_savedSize', football); }); @@ -120,12 +120,12 @@ describe('Vislib Resize Checker', function () { }); it('emits "resize" based on MS_MAX_RESIZE_DELAY, even if el\'s constantly changing size', function () { - var steps = _.random(5, 10); + let steps = _.random(5, 10); this.slow(steps * 10); // we are going to fake the delay using the fake clock - var msStep = Math.floor(ResizeChecker.MS_MAX_RESIZE_DELAY / (steps - 1)); - var clock = sinon.useFakeTimers(); + let msStep = Math.floor(ResizeChecker.MS_MAX_RESIZE_DELAY / (steps - 1)); + let clock = sinon.useFakeTimers(); _.times(steps, function step(i) { checker.$el.css('height', 100 + i); @@ -142,8 +142,8 @@ describe('Vislib Resize Checker', function () { describe('#destroy()', function () { it('removes the "reflow" event from the reflowWatcher', function () { - var onCall = reflowSpies.on.getCall(0); - var handler = onCall.args[1]; + let onCall = reflowSpies.on.getCall(0); + let handler = onCall.args[1]; checker.destroy(); expect(reflowSpies.off).to.have.property('callCount', 1); @@ -151,7 +151,7 @@ describe('Vislib Resize Checker', function () { }); it('clears the timeout', function () { - var spy = sinon.spy(window, 'clearTimeout'); + let spy = sinon.spy(window, 'clearTimeout'); checker.destroy(); expect(spy).to.have.property('callCount', 1); }); @@ -173,26 +173,26 @@ describe('Vislib Resize Checker', function () { }); it('walks the schedule, using each value as it\'s next timeout', function () { - var timerId = checker.startSchedule(schedule); + let timerId = checker.startSchedule(schedule); // start at 0 even though "start" used the first slot, we will still check it - for (var i = 0; i < schedule.length; i++) { + for (let i = 0; i < schedule.length; i++) { expect(clock.timers[timerId]).to.have.property('callAt', schedule[i]); timerId = checker.continueSchedule(); } }); it('repeats the last value in the schedule', function () { - var timerId = checker.startSchedule(schedule); + let timerId = checker.startSchedule(schedule); // start at 1, and go until there is one left - for (var i = 1; i < schedule.length - 1; i++) { + for (let i = 1; i < schedule.length - 1; i++) { timerId = checker.continueSchedule(); } - var last = _.last(schedule); + let last = _.last(schedule); _.times(5, function () { - var timer = clock.timers[checker.continueSchedule()]; + let timer = clock.timers[checker.continueSchedule()]; expect(timer).to.have.property('callAt', last); }); }); diff --git a/src/ui/public/vislib/__tests__/lib/x_axis.js b/src/ui/public/vislib/__tests__/lib/x_axis.js index c8b1c05236d64..a068a679940b2 100644 --- a/src/ui/public/vislib/__tests__/lib/x_axis.js +++ b/src/ui/public/vislib/__tests__/lib/x_axis.js @@ -1,9 +1,9 @@ -var d3 = require('d3'); -var angular = require('angular'); -var _ = require('lodash'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let d3 = require('d3'); +let angular = require('angular'); +let _ = require('lodash'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('Vislib xAxis Class Test Suite', function () { let XAxis; @@ -13,7 +13,7 @@ describe('Vislib xAxis Class Test Suite', function () { let el; let fixture; let dataObj; - var data = { + let data = { hits: 621, label: '', ordered: { diff --git a/src/ui/public/vislib/__tests__/lib/y_axis.js b/src/ui/public/vislib/__tests__/lib/y_axis.js index 9eef839ed6edf..abd597717649c 100644 --- a/src/ui/public/vislib/__tests__/lib/y_axis.js +++ b/src/ui/public/vislib/__tests__/lib/y_axis.js @@ -1,8 +1,8 @@ -var _ = require('lodash'); -var d3 = require('d3'); -var $ = require('jquery'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let _ = require('lodash'); +let d3 = require('d3'); +let $ = require('jquery'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); let YAxis; let Data; @@ -12,7 +12,7 @@ let buildYAxis; let yAxis; let yAxisDiv; -var timeSeries = [ +let timeSeries = [ 1408734060000, 1408734090000, 1408734120000, @@ -25,7 +25,7 @@ var timeSeries = [ 1408734330000 ]; -var defaultGraphData = [ +let defaultGraphData = [ [ 8, 23, 30, 28, 36, 30, 26, 22, 29, 24 ], [ 2, 13, 20, 18, 26, 20, 16, 12, 19, 14 ] ]; @@ -40,7 +40,7 @@ function makeSeriesData(data) { } function createData(seriesData) { - var data = { + let data = { hits: 621, label: 'test', ordered: { @@ -56,7 +56,7 @@ function createData(seriesData) { yAxisLabel: 'Count' }; - var node = $('
').css({ + let node = $('
').css({ height: 40, width: 40 }) @@ -69,7 +69,7 @@ function createData(seriesData) { yAxisDiv = el.append('div') .attr('class', 'y-axis-div'); - var dataObj = new Data(data, { + let dataObj = new Data(data, { defaultYMin: true }, persistedState); @@ -130,10 +130,10 @@ describe('Vislib yAxis Class Test Suite', function () { let yScale; let graphData; let domain; - var height = 50; + let height = 50; function checkDomain(min, max) { - var domain = yScale.domain(); + let domain = yScale.domain(); expect(domain[0]).to.be.lessThan(min + 1); expect(domain[1]).to.be.greaterThan(max - 1); return domain; @@ -178,9 +178,9 @@ describe('Vislib yAxis Class Test Suite', function () { it('should have domain between 0 and max value', function () { - var min = 0; - var max = _.max(_.flattenDeep(graphData)); - var domain = checkDomain(min, max); + let min = 0; + let max = _.max(_.flattenDeep(graphData)); + let domain = checkDomain(min, max); expect(domain[1]).to.be.greaterThan(0); checkRange(); }); @@ -197,9 +197,9 @@ describe('Vislib yAxis Class Test Suite', function () { }); it('should have domain between min value and 0', function () { - var min = _.min(_.flattenDeep(graphData)); - var max = 0; - var domain = checkDomain(min, max); + let min = _.min(_.flattenDeep(graphData)); + let max = 0; + let domain = checkDomain(min, max); expect(domain[0]).to.be.lessThan(0); checkRange(); }); @@ -216,9 +216,9 @@ describe('Vislib yAxis Class Test Suite', function () { }); it('should have domain between min and max values', function () { - var min = _.min(_.flattenDeep(graphData)); - var max = _.max(_.flattenDeep(graphData)); - var domain = checkDomain(min, max); + let min = _.min(_.flattenDeep(graphData)); + let max = _.max(_.flattenDeep(graphData)); + let domain = checkDomain(min, max); expect(domain[0]).to.be.lessThan(0); expect(domain[1]).to.be.greaterThan(0); checkRange(); @@ -233,8 +233,8 @@ describe('Vislib yAxis Class Test Suite', function () { }); it('should throw a NaN error', function () { - var min = 'Not a number'; - var max = 12; + let min = 'Not a number'; + let max = 12; expect(function () { yAxis._validateUserExtents(min, max); @@ -247,7 +247,7 @@ describe('Vislib yAxis Class Test Suite', function () { domain = []; domain[0] = yAxis._attr.yAxis.min = 20; domain[1] = yAxis._attr.yAxis.max = 80; - var newDomain = yAxis._validateUserExtents(domain); + let newDomain = yAxis._validateUserExtents(domain); expect(newDomain[0]).to.be(domain[0] / 100); expect(newDomain[1]).to.be(domain[1] / 100); @@ -255,7 +255,7 @@ describe('Vislib yAxis Class Test Suite', function () { it('should return the user defined value', function () { domain = [20, 50]; - var newDomain = yAxis._validateUserExtents(domain); + let newDomain = yAxis._validateUserExtents(domain); expect(newDomain[0]).to.be(domain[0]); expect(newDomain[1]).to.be(domain[1]); @@ -264,8 +264,8 @@ describe('Vislib yAxis Class Test Suite', function () { describe('should throw an error when', function () { it('min === max', function () { - var min = 12; - var max = 12; + let min = 12; + let max = 12; expect(function () { yAxis._validateAxisExtents(min, max); @@ -273,8 +273,8 @@ describe('Vislib yAxis Class Test Suite', function () { }); it('min > max', function () { - var min = 30; - var max = 10; + let min = 30; + let max = 10; expect(function () { yAxis._validateAxisExtents(min, max); @@ -284,7 +284,7 @@ describe('Vislib yAxis Class Test Suite', function () { }); describe('getScaleType method', function () { - var fnNames = ['linear', 'log', 'square root']; + let fnNames = ['linear', 'log', 'square root']; it('should return a function', function () { fnNames.forEach(function (fnName) { @@ -316,7 +316,7 @@ describe('Vislib yAxis Class Test Suite', function () { }); it('should return a yMin value of 1', function () { - var yMin = yAxis._logDomain(0, 200)[0]; + let yMin = yAxis._logDomain(0, 200)[0]; expect(yMin).to.be(1); }); }); @@ -340,13 +340,13 @@ describe('Vislib yAxis Class Test Suite', function () { it('should use percentage format for percentages', function () { yAxis._attr.mode = 'percentage'; - var tickFormat = yAxis.getYAxis().tickFormat(); + let tickFormat = yAxis.getYAxis().tickFormat(); expect(tickFormat(1)).to.be('100%'); }); it('should use decimal format for small values', function () { yAxis.yMax = 1; - var tickFormat = yAxis.getYAxis().tickFormat(); + let tickFormat = yAxis.getYAxis().tickFormat(); expect(tickFormat(0.8)).to.be('0.8'); }); @@ -381,23 +381,23 @@ describe('Vislib yAxis Class Test Suite', function () { }); describe('#tickFormat()', function () { - var formatter = function () {}; + let formatter = function () {}; it('returns a basic number formatter by default', function () { - var yAxis = buildYAxis(); + let yAxis = buildYAxis(); expect(yAxis.tickFormat()).to.not.be(formatter); expect(yAxis.tickFormat()(1)).to.be('1'); }); it('returns the yAxisFormatter when passed', function () { - var yAxis = buildYAxis({ + let yAxis = buildYAxis({ yAxisFormatter: formatter }); expect(yAxis.tickFormat()).to.be(formatter); }); it('returns a percentage formatter when the vis is in percentage mode', function () { - var yAxis = buildYAxis({ + let yAxis = buildYAxis({ yAxisFormatter: formatter, _attr: { mode: 'percentage' diff --git a/src/ui/public/vislib/__tests__/vis.js b/src/ui/public/vislib/__tests__/vis.js index f6baec7a07a12..2901796357db0 100644 --- a/src/ui/public/vislib/__tests__/vis.js +++ b/src/ui/public/vislib/__tests__/vis.js @@ -1,22 +1,22 @@ -var _ = require('lodash'); -var $ = require('jquery'); -var d3 = require('d3'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); - -var series = require('fixtures/vislib/mock_data/date_histogram/_series'); -var columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); -var rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); -var stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); - -var dataArray = [ +let _ = require('lodash'); +let $ = require('jquery'); +let d3 = require('d3'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); + +let series = require('fixtures/vislib/mock_data/date_histogram/_series'); +let columns = require('fixtures/vislib/mock_data/date_histogram/_columns'); +let rows = require('fixtures/vislib/mock_data/date_histogram/_rows'); +let stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); + +let dataArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', @@ -26,8 +26,8 @@ var names = [ dataArray.forEach(function (data, i) { describe('Vislib Vis Test Suite for ' + names[i] + ' Data', function () { - var beforeEvent = 'click'; - var afterEvent = 'brush'; + let beforeEvent = 'click'; + let afterEvent = 'brush'; let vis; let persistedState; let secondVis; @@ -127,7 +127,7 @@ dataArray.forEach(function (data, i) { }); describe('on Method', function () { - var events = [ + let events = [ beforeEvent, afterEvent ]; @@ -171,7 +171,7 @@ dataArray.forEach(function (data, i) { }); it('should cause a listener for each event to be attached to each chart', function () { - var charts = vis.handler.charts; + let charts = vis.handler.charts; charts.forEach(function (chart, i) { expect(chart.events.listenerCount(beforeEvent)).to.be.above(0); @@ -218,7 +218,7 @@ dataArray.forEach(function (data, i) { }); it('should remove a listener', function () { - var charts = vis.handler.charts; + let charts = vis.handler.charts; expect(vis.listeners(beforeEvent)).to.not.contain(listener1); expect(vis.listeners(beforeEvent)).to.contain(listener2); @@ -234,7 +234,7 @@ dataArray.forEach(function (data, i) { }); it('should remove the event and all listeners when only event passed an argument', function () { - var charts = vis.handler.charts; + let charts = vis.handler.charts; vis.off(afterEvent); // should remove 'brush' event @@ -249,7 +249,7 @@ dataArray.forEach(function (data, i) { }); it('should remove the event from the chart when the last listener is removed', function () { - var charts = vis.handler.charts; + let charts = vis.handler.charts; vis.off(afterEvent, listener2); expect(vis.listenerCount(afterEvent)).to.be(0); diff --git a/src/ui/public/vislib/__tests__/visualizations/area_chart.js b/src/ui/public/vislib/__tests__/visualizations/area_chart.js index efb0d1f09332b..5730761260bfa 100644 --- a/src/ui/public/vislib/__tests__/visualizations/area_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/area_chart.js @@ -1,13 +1,13 @@ -var d3 = require('d3'); -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); - -var woahLotsOfVariables = require('fixtures/vislib/mock_data/date_histogram/_series'); -var notQuiteEnoughVariables = require('fixtures/vislib/mock_data/not_enough_data/_one_point'); -var someOtherVariables = { +let d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); + +let woahLotsOfVariables = require('fixtures/vislib/mock_data/date_histogram/_series'); +let notQuiteEnoughVariables = require('fixtures/vislib/mock_data/not_enough_data/_one_point'); +let someOtherVariables = { 'series pos': require('fixtures/vislib/mock_data/date_histogram/_series'), 'series pos neg': require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'), 'series neg': require('fixtures/vislib/mock_data/date_histogram/_series_neg'), @@ -16,7 +16,7 @@ var someOtherVariables = { 'stackedSeries': require('fixtures/vislib/mock_data/date_histogram/_stacked_series') }; -var visLibParams = { +let visLibParams = { type: 'area', addLegend: true, addTooltip: true @@ -156,12 +156,12 @@ _.forOwn(someOtherVariables, function (variablesAreCool, imaVariable) { it('should not draw circles where d.y === 0', function () { vis.handler.charts.forEach(function (chart) { - var series = chart.chartData.series; - var isZero = series.some(function (d) { + let series = chart.chartData.series; + let isZero = series.some(function (d) { return d.y === 0; }); - var circles = $.makeArray($(chart.chartEl).find('circle')); - var isNotDrawn = circles.some(function (d) { + let circles = $.makeArray($(chart.chartEl).find('circle')); + let isNotDrawn = circles.some(function (d) { return d.__data__.y === 0; }); @@ -181,7 +181,7 @@ _.forOwn(someOtherVariables, function (variablesAreCool, imaVariable) { it('should return a yMin and yMax', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; expect(yAxis.domain[0]).to.not.be(undefined); expect(yAxis.domain[1]).to.not.be(undefined); @@ -190,7 +190,7 @@ _.forOwn(someOtherVariables, function (variablesAreCool, imaVariable) { it('should render a zero axis line', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; if (yAxis.yMin < 0 && yAxis.yMax > 0) { expect($(chart.chartEl).find('line.zero-line').length).to.be(1); @@ -222,8 +222,8 @@ _.forOwn(someOtherVariables, function (variablesAreCool, imaVariable) { it('should return yAxis extents equal to data extents', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; - var yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; + let yAxis = chart.handler.yAxis; + let yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; expect(yAxis.domain[0]).to.equal(yVals[0]); expect(yAxis.domain[1]).to.equal(yVals[1]); diff --git a/src/ui/public/vislib/__tests__/visualizations/chart.js b/src/ui/public/vislib/__tests__/visualizations/chart.js index 71571e8cb186c..8dbc40ea874b5 100644 --- a/src/ui/public/vislib/__tests__/visualizations/chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/chart.js @@ -1,7 +1,7 @@ -var d3 = require('d3'); -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); +let d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); describe('Vislib _chart Test Suite', function () { let ColumnChart; @@ -9,12 +9,12 @@ describe('Vislib _chart Test Suite', function () { let Data; let persistedState; let Vis; - var chartData = {}; + let chartData = {}; let vis; let el; let myChart; let config; - var data = { + let data = { hits : 621, label : '', ordered : { diff --git a/src/ui/public/vislib/__tests__/visualizations/column_chart.js b/src/ui/public/vislib/__tests__/visualizations/column_chart.js index 97f5e814e7816..287e73cfe6e81 100644 --- a/src/ui/public/vislib/__tests__/visualizations/column_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/column_chart.js @@ -1,21 +1,21 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let d3 = require('d3'); // Data -var series = require('fixtures/vislib/mock_data/date_histogram/_series'); -var seriesPosNeg = require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'); -var seriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); -var termsColumns = require('fixtures/vislib/mock_data/terms/_columns'); -//var histogramRows = require('fixtures/vislib/mock_data/histogram/_rows'); -var stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); +let series = require('fixtures/vislib/mock_data/date_histogram/_series'); +let seriesPosNeg = require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'); +let seriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); +let termsColumns = require('fixtures/vislib/mock_data/terms/_columns'); +//let histogramRows = require('fixtures/vislib/mock_data/histogram/_rows'); +let stackedSeries = require('fixtures/vislib/mock_data/date_histogram/_stacked_series'); // tuple, with the format [description, mode, data] -var dataTypesArray = [ +let dataTypesArray = [ ['series', 'stacked', series], ['series with positive and negative values', 'stacked', seriesPosNeg], ['series with negative values', 'stacked', seriesNeg], @@ -25,14 +25,14 @@ var dataTypesArray = [ ]; dataTypesArray.forEach(function (dataType, i) { - var name = dataType[0]; - var mode = dataType[1]; - var data = dataType[2]; + let name = dataType[0]; + let mode = dataType[1]; + let data = dataType[2]; describe('Vislib Column Chart Test Suite for ' + name + ' Data', function () { let vis; let persistedState; - var visLibParams = { + let visLibParams = { type: 'histogram', hasTimeField: true, addLegend: true, @@ -102,7 +102,7 @@ dataTypesArray.forEach(function (dataType, i) { describe('addBarEvents method', function () { function checkChart(chart) { - var rect = $(chart.chartEl).find('.series rect').get(0); + let rect = $(chart.chartEl).find('.series rect').get(0); // check for existance of stuff and things return { @@ -119,23 +119,23 @@ dataTypesArray.forEach(function (dataType, i) { it('should attach the brush if data is a set of ordered dates', function () { vis.handler.charts.forEach(function (chart) { - var has = checkChart(chart); - var ordered = vis.handler.data.get('ordered'); - var date = Boolean(ordered && ordered.date); + let has = checkChart(chart); + let ordered = vis.handler.data.get('ordered'); + let date = Boolean(ordered && ordered.date); expect(has.brush).to.be(date); }); }); it('should attach a click event', function () { vis.handler.charts.forEach(function (chart) { - var has = checkChart(chart); + let has = checkChart(chart); expect(has.click).to.be(true); }); }); it('should attach a hover event', function () { vis.handler.charts.forEach(function (chart) { - var has = checkChart(chart); + let has = checkChart(chart); expect(has.mouseOver).to.be(true); }); }); @@ -150,7 +150,7 @@ dataTypesArray.forEach(function (dataType, i) { it('should return a yMin and yMax', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; expect(yAxis.domain[0]).to.not.be(undefined); expect(yAxis.domain[1]).to.not.be(undefined); @@ -159,7 +159,7 @@ dataTypesArray.forEach(function (dataType, i) { it('should render a zero axis line', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; if (yAxis.yMin < 0 && yAxis.yMax > 0) { expect($(chart.chartEl).find('line.zero-line').length).to.be(1); @@ -191,9 +191,9 @@ dataTypesArray.forEach(function (dataType, i) { it('should return yAxis extents equal to data extents', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; - var min = vis.handler.data.getYMin(); - var max = vis.handler.data.getYMax(); + let yAxis = chart.handler.yAxis; + let min = vis.handler.data.getYMin(); + let max = vis.handler.data.getYMax(); expect(yAxis.domain[0]).to.equal(min); expect(yAxis.domain[1]).to.equal(max); diff --git a/src/ui/public/vislib/__tests__/visualizations/line_chart.js b/src/ui/public/vislib/__tests__/visualizations/line_chart.js index c5187c79b1e77..20d20cb4de8c7 100644 --- a/src/ui/public/vislib/__tests__/visualizations/line_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/line_chart.js @@ -1,19 +1,19 @@ -var d3 = require('d3'); -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); +let d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); // Data -var seriesPos = require('fixtures/vislib/mock_data/date_histogram/_series'); -var seriesPosNeg = require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'); -var seriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); -var histogramColumns = require('fixtures/vislib/mock_data/histogram/_columns'); -var rangeRows = require('fixtures/vislib/mock_data/range/_rows'); -var termSeries = require('fixtures/vislib/mock_data/terms/_series'); - -var dataTypes = [ +let seriesPos = require('fixtures/vislib/mock_data/date_histogram/_series'); +let seriesPosNeg = require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'); +let seriesNeg = require('fixtures/vislib/mock_data/date_histogram/_series_neg'); +let histogramColumns = require('fixtures/vislib/mock_data/histogram/_columns'); +let rangeRows = require('fixtures/vislib/mock_data/range/_rows'); +let termSeries = require('fixtures/vislib/mock_data/terms/_series'); + +let dataTypes = [ ['series pos', seriesPos], ['series pos neg', seriesPosNeg], ['series neg', seriesNeg], @@ -24,8 +24,8 @@ var dataTypes = [ describe('Vislib Line Chart', function () { dataTypes.forEach(function (type, i) { - var name = type[0]; - var data = type[1]; + let name = type[0]; + let data = type[1]; describe(name + ' Data', function () { let vis; @@ -33,7 +33,7 @@ describe('Vislib Line Chart', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var visLibParams = { + let visLibParams = { type: 'line', addLegend: true, addTooltip: true, @@ -131,7 +131,7 @@ describe('Vislib Line Chart', function () { it('should return a yMin and yMax', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; expect(yAxis.domain[0]).to.not.be(undefined); expect(yAxis.domain[1]).to.not.be(undefined); @@ -140,7 +140,7 @@ describe('Vislib Line Chart', function () { it('should render a zero axis line', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; + let yAxis = chart.handler.yAxis; if (yAxis.yMin < 0 && yAxis.yMax > 0) { expect($(chart.chartEl).find('line.zero-line').length).to.be(1); @@ -172,8 +172,8 @@ describe('Vislib Line Chart', function () { it('should return yAxis extents equal to data extents', function () { vis.handler.charts.forEach(function (chart) { - var yAxis = chart.handler.yAxis; - var yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; + let yAxis = chart.handler.yAxis; + let yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; expect(yAxis.domain[0]).to.equal(yVals[0]); expect(yAxis.domain[1]).to.equal(yVals[1]); diff --git a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js index 942c7f76310e7..f37574e84f78b 100644 --- a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js @@ -1,44 +1,44 @@ -var d3 = require('d3'); -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var fixtures = require('fixtures/fake_hierarchical_data'); - -var rowAgg = [ +let d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let fixtures = require('fixtures/fake_hierarchical_data'); + +let rowAgg = [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, { type: 'terms', schema: 'split', params: { field: 'extension', rows: true }}, { type: 'terms', schema: 'segment', params: { field: 'machine.os' }}, { type: 'terms', schema: 'segment', params: { field: 'geo.src' }} ]; -var colAgg = [ +let colAgg = [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, { type: 'terms', schema: 'split', params: { field: 'extension', row: false }}, { type: 'terms', schema: 'segment', params: { field: 'machine.os' }}, { type: 'terms', schema: 'segment', params: { field: 'geo.src' }} ]; -var sliceAgg = [ +let sliceAgg = [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, { type: 'terms', schema: 'segment', params: { field: 'machine.os' }}, { type: 'terms', schema: 'segment', params: { field: 'geo.src' }} ]; -var aggArray = [ +let aggArray = [ rowAgg, colAgg, sliceAgg ]; -var names = [ +let names = [ 'rows', 'columns', 'slices' ]; -var sizes = [ +let sizes = [ 0, 5, 15, @@ -48,13 +48,13 @@ var sizes = [ ]; describe('No global chart settings', function () { - var visLibParams1 = { + let visLibParams1 = { el: '
', type: 'pie', addLegend: true, addTooltip: true }; - var visLibParams2 = { + let visLibParams2 = { el: '
', type: 'pie', addLegend: true, @@ -78,13 +78,13 @@ describe('No global chart settings', function () { indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); buildHierarchicalData = Private(require('ui/agg_response/hierarchical/build_hierarchical_data')); - var id1 = 1; - var id2 = 1; - var stubVis1 = new Vis(indexPattern, { + let id1 = 1; + let id2 = 1; + let stubVis1 = new Vis(indexPattern, { type: 'pie', aggs: rowAgg }); - var stubVis2 = new Vis(indexPattern, { + let stubVis2 = new Vis(indexPattern, { type: 'pie', aggs: colAgg }); @@ -115,19 +115,19 @@ describe('No global chart settings', function () { }); describe('_validatePieData method', function () { - var allZeros = [ + let allZeros = [ { slices: { children: [] } }, { slices: { children: [] } }, { slices: { children: [] } } ]; - var someZeros = [ + let someZeros = [ { slices: { children: [{}] } }, { slices: { children: [{}] } }, { slices: { children: [] } } ]; - var noZeros = [ + let noZeros = [ { slices: { children: [{}] } }, { slices: { children: [{}] } }, { slices: { children: [{}] } } @@ -152,7 +152,7 @@ describe('No global chart settings', function () { aggArray.forEach(function (dataAgg, i) { describe('Vislib PieChart Class Test Suite for ' + names[i] + ' data', function () { - var visLibParams = { + let visLibParams = { type: 'pie', addLegend: true, addTooltip: true @@ -172,8 +172,8 @@ aggArray.forEach(function (dataAgg, i) { indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); buildHierarchicalData = Private(require('ui/agg_response/hierarchical/build_hierarchical_data')); - var id = 1; - var stubVis = new Vis(indexPattern, { + let id = 1; + let stubVis = new Vis(indexPattern, { type: 'pie', aggs: dataAgg }); diff --git a/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js b/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js index 5617348cc59b9..76c6e9ed9412d 100644 --- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js +++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js @@ -1,22 +1,22 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var L = require('leaflet'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let L = require('leaflet'); -var sinon = require('auto-release-sinon'); -var geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); +let sinon = require('auto-release-sinon'); +let geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); // // Data -// var dataArray = [ +// let dataArray = [ // ['geojson', require('fixtures/vislib/mock_data/geohash/_geo_json')], // ['columns', require('fixtures/vislib/mock_data/geohash/_columns')], // ['rows', require('fixtures/vislib/mock_data/geohash/_rows')], // ]; // // TODO: Test the specific behavior of each these -// var mapTypes = [ +// let mapTypes = [ // 'Scaled Circle Markers', // 'Shaded Circle Markers', // 'Shaded Geohash Grid', @@ -24,10 +24,10 @@ var geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); // ]; describe('TileMap Map Tests', function () { - var $mockMapEl = $('
'); + let $mockMapEl = $('
'); let TileMapMap; - var leafletStubs = {}; - var leafletMocks = {}; + let leafletStubs = {}; + let leafletMocks = {}; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -56,7 +56,7 @@ describe('TileMap Map Tests', function () { }); it('should add zoom controls', function () { - var mapOptions = createStub.firstCall.args[0]; + let mapOptions = createStub.firstCall.args[0]; expect(mapOptions).to.be.an('object'); if (mapOptions.zoomControl) expect(mapOptions.zoomControl).to.be.ok(); @@ -81,8 +81,8 @@ describe('TileMap Map Tests', function () { expect(leafletStubs.tileLayer.callCount).to.equal(1); expect(leafletStubs.map.callCount).to.equal(1); - var callArgs = leafletStubs.map.firstCall.args; - var mapOptions = callArgs[1]; + let callArgs = leafletStubs.map.firstCall.args; + let mapOptions = callArgs[1]; expect(callArgs[0]).to.be($mockMapEl.get(0)); expect(mapOptions).to.have.property('zoom'); expect(mapOptions).to.have.property('center'); @@ -121,21 +121,21 @@ describe('TileMap Map Tests', function () { }); it('should attach interaction events', function () { - var expectedTileEvents = ['tileload']; - var expectedMapEvents = ['draw:created', 'moveend', 'zoomend', 'unload']; - var matchedEvents = { + let expectedTileEvents = ['tileload']; + let expectedMapEvents = ['draw:created', 'moveend', 'zoomend', 'unload']; + let matchedEvents = { tiles: 0, maps: 0, }; _.times(leafletMocks.tileLayer.on.callCount, function (index) { - var ev = leafletMocks.tileLayer.on.getCall(index).args[0]; + let ev = leafletMocks.tileLayer.on.getCall(index).args[0]; if (_.includes(expectedTileEvents, ev)) matchedEvents.tiles++; }); expect(matchedEvents.tiles).to.equal(expectedTileEvents.length); _.times(leafletMocks.map.on.callCount, function (index) { - var ev = leafletMocks.map.on.getCall(index).args[0]; + let ev = leafletMocks.map.on.getCall(index).args[0]; if (_.includes(expectedMapEvents, ev)) matchedEvents.maps++; }); expect(matchedEvents.maps).to.equal(expectedMapEvents.length); @@ -156,14 +156,14 @@ describe('TileMap Map Tests', function () { it('should pass the map options to the marker', function () { map._addMarkers(); - var args = createStub.firstCall.args[0]; + let args = createStub.firstCall.args[0]; expect(args).to.have.property('tooltipFormatter'); expect(args).to.have.property('valueFormatter'); expect(args).to.have.property('attr'); }); it('should destroy existing markers', function () { - var destroyStub = sinon.stub(); + let destroyStub = sinon.stub(); map._markers = { destroy: destroyStub }; map._addMarkers(); @@ -181,20 +181,20 @@ describe('TileMap Map Tests', function () { it('should return an empty array if no data', function () { map = new TileMapMap($mockMapEl, {}, {}); - var rects = map._getDataRectangles(); + let rects = map._getDataRectangles(); expect(rects).to.have.length(0); }); it('should return an array of arrays of rectangles', function () { - var rects = map._getDataRectangles(); + let rects = map._getDataRectangles(); _.times(5, function () { - var index = _.random(rects.length - 1); - var rect = rects[index]; - var featureRect = geoJsonData.geoJson.features[index].properties.rectangle; + let index = _.random(rects.length - 1); + let rect = rects[index]; + let featureRect = geoJsonData.geoJson.features[index].properties.rectangle; expect(rect.length).to.equal(featureRect.length); // should swap the array - var checkIndex = _.random(rect.length - 1); + let checkIndex = _.random(rect.length - 1); expect(rect[checkIndex]).to.eql(featureRect[checkIndex]); }); }); diff --git a/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js b/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js index bd6f34e2f337a..81919d923d906 100644 --- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js +++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js @@ -1,16 +1,16 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var L = require('leaflet'); -var sinon = require('auto-release-sinon'); -var geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let L = require('leaflet'); +let sinon = require('auto-release-sinon'); +let geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); // defaults to roughly the lower 48 US states -var defaultSWCoords = [13.496, -143.789]; -var defaultNECoords = [55.526, -57.919]; -var bounds = {}; +let defaultSWCoords = [13.496, -143.789]; +let defaultNECoords = [55.526, -57.919]; +let bounds = {}; let MarkerType; let map; @@ -25,7 +25,7 @@ function getBounds() { return L.latLngBounds(bounds.southWest, bounds.northEast); } -var mockMap = { +let mockMap = { addLayer: _.noop, closePopup: _.noop, getBounds: getBounds, @@ -72,8 +72,8 @@ describe('Marker Tests', function () { it('should not filter any features', function () { // set bounds to the entire world setBounds([-87.252, -343.828], [87.252, 343.125]); - var boundFilter = markerLayer._filterToMapBounds(); - var mapFeature = mapData.features.filter(boundFilter); + let boundFilter = markerLayer._filterToMapBounds(); + let mapFeature = mapData.features.filter(boundFilter); expect(mapFeature.length).to.equal(mapData.features.length); }); @@ -81,8 +81,8 @@ describe('Marker Tests', function () { it('should filter out data points that are outside of the map bounds', function () { // set bounds to roughly US southwest setBounds([31.690, -124.387], [42.324, -102.919]); - var boundFilter = markerLayer._filterToMapBounds(); - var mapFeature = mapData.features.filter(boundFilter); + let boundFilter = markerLayer._filterToMapBounds(); + let mapFeature = mapData.features.filter(boundFilter); expect(mapFeature.length).to.be.lessThan(mapData.features.length); }); @@ -90,8 +90,8 @@ describe('Marker Tests', function () { describe('legendQuantizer', function () { it('should return a range of hex colors', function () { - var minColor = markerLayer._legendQuantizer(mapData.properties.allmin); - var maxColor = markerLayer._legendQuantizer(mapData.properties.allmax); + let minColor = markerLayer._legendQuantizer(mapData.properties.allmin); + let maxColor = markerLayer._legendQuantizer(mapData.properties.allmax); expect(minColor.substring(0, 1)).to.equal('#'); expect(minColor).to.have.length(7); @@ -101,18 +101,18 @@ describe('Marker Tests', function () { }); it('should return a color with 1 color', function () { - var geoJson = { properties: { min: 1, max: 1 } }; + let geoJson = { properties: { min: 1, max: 1 } }; markerLayer = createMarker(MarkerClass, geoJson); // ensure the quantizer domain is correct - var color = markerLayer._legendQuantizer(1); + let color = markerLayer._legendQuantizer(1); expect(color).to.not.be(undefined); expect(color.substring(0, 1)).to.equal('#'); // should always get the same color back _.times(5, function () { - var num = _.random(0, 100); - var randColor = markerLayer._legendQuantizer(0); + let num = _.random(0, 100); + let randColor = markerLayer._legendQuantizer(0); expect(randColor).to.equal(color); }); }); @@ -120,19 +120,19 @@ describe('Marker Tests', function () { describe('applyShadingStyle', function () { it('should return a style object', function () { - var style = markerLayer.applyShadingStyle(100); + let style = markerLayer.applyShadingStyle(100); expect(style).to.be.an('object'); - var keys = _.keys(style); - var expected = ['fillColor', 'color']; + let keys = _.keys(style); + let expected = ['fillColor', 'color']; _.each(expected, function (key) { expect(keys).to.contain(key); }); }); it('should use the legendQuantizer', function () { - var spy = sinon.spy(markerLayer, '_legendQuantizer'); - var style = markerLayer.applyShadingStyle(100); + let spy = sinon.spy(markerLayer, '_legendQuantizer'); + let style = markerLayer.applyShadingStyle(100); expect(spy.callCount).to.equal(1); }); }); @@ -140,9 +140,9 @@ describe('Marker Tests', function () { describe('showTooltip', function () { it('should use the tooltip formatter', function () { let content; - var sample = _.sample(mapData.features); + let sample = _.sample(mapData.features); - var stub = sinon.stub(markerLayer, '_tooltipFormatter', function (val) { + let stub = sinon.stub(markerLayer, '_tooltipFormatter', function (val) { return; }); @@ -182,12 +182,12 @@ describe('Marker Tests', function () { }); it('should use the value formatter', function () { - var formatterSpy = sinon.spy(markerLayer, '_valueFormatter'); + let formatterSpy = sinon.spy(markerLayer, '_valueFormatter'); // called twice for every legend color defined - var expectedCallCount = markerLayer._legendColors.length * 2; + let expectedCallCount = markerLayer._legendColors.length * 2; markerLayer.addLegend(); - var legend = markerLayer._legend.onAdd(); + let legend = markerLayer._legend.onAdd(); expect(formatterSpy.callCount).to.equal(expectedCallCount); expect(legend).to.be.a(HTMLDivElement); @@ -198,14 +198,14 @@ describe('Marker Tests', function () { describe('Shaded Circles', function () { beforeEach(ngMock.module('MarkerFactory')); beforeEach(ngMock.inject(function (Private) { - var MarkerClass = Private(require('ui/vislib/visualizations/marker_types/shaded_circles')); + let MarkerClass = Private(require('ui/vislib/visualizations/marker_types/shaded_circles')); markerLayer = createMarker(MarkerClass); })); describe('geohashMinDistance method', function () { it('should return a finite number', function () { - var sample = _.sample(mapData.features); - var distance = markerLayer._geohashMinDistance(sample); + let sample = _.sample(mapData.features); + let distance = markerLayer._geohashMinDistance(sample); expect(distance).to.be.a('number'); expect(_.isFinite(distance)).to.be(true); @@ -220,34 +220,34 @@ describe('Marker Tests', function () { beforeEach(ngMock.inject(function (Private) { zoom = _.random(1, 18); sinon.stub(mockMap, 'getZoom', _.constant(zoom)); - var MarkerClass = Private(require('ui/vislib/visualizations/marker_types/scaled_circles')); + let MarkerClass = Private(require('ui/vislib/visualizations/marker_types/scaled_circles')); markerLayer = createMarker(MarkerClass); })); describe('radiusScale method', function () { - var valueArray = [10, 20, 30, 40, 50, 60]; - var max = _.max(valueArray); - var prev = -1; + let valueArray = [10, 20, 30, 40, 50, 60]; + let max = _.max(valueArray); + let prev = -1; it('should return 0 for value of 0', function () { expect(markerLayer._radiusScale(0)).to.equal(0); }); it('should return a scaled value for negative and positive numbers', function () { - var upperBound = markerLayer._radiusScale(max); - var results = []; + let upperBound = markerLayer._radiusScale(max); + let results = []; function roundValue(value) { // round number to 6 decimal places - var r = Math.pow(10, 6); + let r = Math.pow(10, 6); return Math.round(value * r) / r; } _.each(valueArray, function (value, i) { - var ratio = Math.pow(value / max, 0.5); - var comparison = ratio * upperBound; - var radius = markerLayer._radiusScale(value); - var negRadius = markerLayer._radiusScale(value * -1); + let ratio = Math.pow(value / max, 0.5); + let comparison = ratio * upperBound; + let radius = markerLayer._radiusScale(value); + let negRadius = markerLayer._radiusScale(value * -1); results.push(radius); expect(negRadius).to.equal(radius); @@ -265,7 +265,7 @@ describe('Marker Tests', function () { describe('Heatmaps', function () { beforeEach(ngMock.module('MarkerFactory')); beforeEach(ngMock.inject(function (Private) { - var MarkerClass = Private(require('ui/vislib/visualizations/marker_types/heatmap')); + let MarkerClass = Private(require('ui/vislib/visualizations/marker_types/heatmap')); markerLayer = createMarker(MarkerClass); })); @@ -277,7 +277,7 @@ describe('Marker Tests', function () { }); it('should return an array or values for each feature', function () { - var arr = markerLayer._dataToHeatArray(max); + let arr = markerLayer._dataToHeatArray(max); expect(arr).to.be.an('array'); expect(arr).to.have.length(mapData.features.length); @@ -285,11 +285,11 @@ describe('Marker Tests', function () { it('should return an array item with lat, lng, metric for each feature', function () { _.times(3, function () { - var arr = markerLayer._dataToHeatArray(max); - var index = _.random(mapData.features.length - 1); - var feature = mapData.features[index]; - var featureValue = feature.properties.value; - var featureArr = feature.geometry.coordinates.slice(0).concat(featureValue); + let arr = markerLayer._dataToHeatArray(max); + let index = _.random(mapData.features.length - 1); + let feature = mapData.features[index]; + let featureValue = feature.properties.value; + let featureArr = feature.geometry.coordinates.slice(0).concat(featureValue); expect(arr[index]).to.eql(featureArr); }); }); @@ -298,11 +298,11 @@ describe('Marker Tests', function () { _.times(5, function () { markerLayer._attr.heatNormalizeData = true; - var arr = markerLayer._dataToHeatArray(max); - var index = _.random(mapData.features.length - 1); - var feature = mapData.features[index]; - var featureValue = feature.properties.value / max; - var featureArr = feature.geometry.coordinates.slice(0).concat(featureValue); + let arr = markerLayer._dataToHeatArray(max); + let index = _.random(mapData.features.length - 1); + let feature = mapData.features[index]; + let featureValue = feature.properties.value / max; + let featureArr = feature.geometry.coordinates.slice(0).concat(featureValue); expect(arr[index]).to.eql(featureArr); }); }); @@ -311,18 +311,18 @@ describe('Marker Tests', function () { describe('tooltipProximity', function () { it('should return true if feature is close enough to event latlng', function () { _.times(5, function () { - var feature = _.sample(mapData.features); - var point = markerLayer._getLatLng(feature); - var arr = markerLayer._tooltipProximity(point, feature); + let feature = _.sample(mapData.features); + let point = markerLayer._getLatLng(feature); + let arr = markerLayer._tooltipProximity(point, feature); expect(arr).to.be(true); }); }); it('should return false if feature is not close enough to event latlng', function () { _.times(5, function () { - var feature = _.sample(mapData.features); - var point = L.latLng(90, -180); - var arr = markerLayer._tooltipProximity(point, feature); + let feature = _.sample(mapData.features); + let point = L.latLng(90, -180); + let arr = markerLayer._tooltipProximity(point, feature); expect(arr).to.be(false); }); }); @@ -331,9 +331,9 @@ describe('Marker Tests', function () { describe('nearestFeature', function () { it('should return nearest geoJson feature object', function () { _.times(5, function () { - var feature = _.sample(mapData.features); - var point = markerLayer._getLatLng(feature); - var nearestPoint = markerLayer._nearestFeature(point); + let feature = _.sample(mapData.features); + let point = markerLayer._getLatLng(feature); + let nearestPoint = markerLayer._nearestFeature(point); expect(nearestPoint).to.equal(feature); }); }); @@ -341,15 +341,15 @@ describe('Marker Tests', function () { describe('getLatLng', function () { it('should return a leaflet latLng object', function () { - var feature = _.sample(mapData.features); - var latLng = markerLayer._getLatLng(feature); - var compare = L.latLng(feature.geometry.coordinates.slice(0).reverse()); + let feature = _.sample(mapData.features); + let latLng = markerLayer._getLatLng(feature); + let compare = L.latLng(feature.geometry.coordinates.slice(0).reverse()); expect(latLng).to.eql(compare); }); it('should memoize the result', function () { - var spy = sinon.spy(L, 'latLng'); - var feature = _.sample(mapData.features); + let spy = sinon.spy(L, 'latLng'); + let feature = _.sample(mapData.features); markerLayer._getLatLng(feature); expect(spy.callCount).to.be(1); diff --git a/src/ui/public/vislib/__tests__/visualizations/tile_maps/tile_map.js b/src/ui/public/vislib/__tests__/visualizations/tile_maps/tile_map.js index 632ff499fc0b5..edc38c5e0e2d4 100644 --- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/tile_map.js +++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/tile_map.js @@ -1,13 +1,13 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var sinon = require('auto-release-sinon'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let sinon = require('auto-release-sinon'); -var geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); -var MockMap = require('fixtures/tilemap_map'); -var mockChartEl = $('
'); +let geoJsonData = require('fixtures/vislib/mock_data/geohash/_geo_json'); +let MockMap = require('fixtures/tilemap_map'); +let mockChartEl = $('
'); let TileMap; let extentsStub; @@ -17,7 +17,7 @@ function createTileMap(handler, chartEl, chartData) { chartEl = chartEl || mockChartEl; chartData = chartData || geoJsonData; - var tilemap = new TileMap(handler, chartEl, chartData); + let tilemap = new TileMap(handler, chartEl, chartData); return tilemap; } @@ -51,7 +51,7 @@ describe('TileMap Tests', function () { }); it('should call destroy for clean state', function () { - var destroySpy = sinon.spy(tilemap, 'destroy'); + let destroySpy = sinon.spy(tilemap, 'destroy'); tilemap.draw(); expect(destroySpy.callCount).to.equal(1); }); @@ -72,14 +72,14 @@ describe('TileMap Tests', function () { it('should append maps and required controls', function () { expect(tilemap.maps).to.have.length(1); - var map = tilemap.maps[0]; + let map = tilemap.maps[0]; expect(map.addTitle.callCount).to.equal(0); expect(map.addFitControl.callCount).to.equal(1); expect(map.addBoundingControl.callCount).to.equal(1); }); it('should only add controls if data exists', function () { - var noData = { + let noData = { geoJson: { features: [], properties: {}, @@ -91,17 +91,17 @@ describe('TileMap Tests', function () { tilemap._appendMap($selection); expect(tilemap.maps).to.have.length(1); - var map = tilemap.maps[0]; + let map = tilemap.maps[0]; expect(map.addTitle.callCount).to.equal(0); expect(map.addFitControl.callCount).to.equal(0); expect(map.addBoundingControl.callCount).to.equal(0); }); it('should append title if set in the data object', function () { - var mapTitle = 'Test Title'; + let mapTitle = 'Test Title'; tilemap = createTileMap(null, null, _.assign({ title: mapTitle }, geoJsonData)); tilemap._appendMap($selection); - var map = tilemap.maps[0]; + let map = tilemap.maps[0]; expect(map.addTitle.callCount).to.equal(1); expect(map.addTitle.firstCall.calledWith(mapTitle)).to.equal(true); @@ -109,8 +109,8 @@ describe('TileMap Tests', function () { }); describe('destroy', function () { - var maps = []; - var mapCount = 5; + let maps = []; + let mapCount = 5; beforeEach(function () { _.times(mapCount, function () { diff --git a/src/ui/public/vislib/__tests__/visualizations/time_marker.js b/src/ui/public/vislib/__tests__/visualizations/time_marker.js index e34b66ef1fb13..1c575e1c27503 100644 --- a/src/ui/public/vislib/__tests__/visualizations/time_marker.js +++ b/src/ui/public/vislib/__tests__/visualizations/time_marker.js @@ -1,21 +1,21 @@ -var d3 = require('d3'); -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); -var $ = require('jquery'); -var fixtures = require('fixtures/fake_hierarchical_data'); -var series = require('fixtures/vislib/mock_data/date_histogram/_series'); -var terms = require('fixtures/vislib/mock_data/terms/_columns'); +let d3 = require('d3'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); +let $ = require('jquery'); +let fixtures = require('fixtures/fake_hierarchical_data'); +let series = require('fixtures/vislib/mock_data/date_histogram/_series'); +let terms = require('fixtures/vislib/mock_data/terms/_columns'); describe('Vislib Time Marker Test Suite', function () { - var height = 50; - var color = '#ff0000'; - var opacity = 0.5; - var width = 3; - var customClass = 'custom-time-marker'; - var dateMathTimes = ['now-1m', 'now-5m', 'now-15m']; - var myTimes = dateMathTimes.map(function (dateMathString) { + let height = 50; + let color = '#ff0000'; + let opacity = 0.5; + let width = 3; + let customClass = 'custom-time-marker'; + let dateMathTimes = ['now-1m', 'now-5m', 'now-15m']; + let myTimes = dateMathTimes.map(function (dateMathString) { return { time: dateMathString, class: customClass, @@ -24,14 +24,14 @@ describe('Vislib Time Marker Test Suite', function () { width: width }; }); - var getExtent = function (dataArray, func) { + let getExtent = function (dataArray, func) { return func(dataArray, function (obj) { return func(obj.values, function (d) { return d.x; }); }); }; - var times = []; + let times = []; let TimeMarker; let defaultMarker; let customMarker; diff --git a/src/ui/public/vislib/__tests__/visualizations/vis_types.js b/src/ui/public/vislib/__tests__/visualizations/vis_types.js index 7341d20419ca4..32092cbf544ae 100644 --- a/src/ui/public/vislib/__tests__/visualizations/vis_types.js +++ b/src/ui/public/vislib/__tests__/visualizations/vis_types.js @@ -1,7 +1,7 @@ -var angular = require('angular'); -var expect = require('expect.js'); -var ngMock = require('ngMock'); -var _ = require('lodash'); +let angular = require('angular'); +let expect = require('expect.js'); +let ngMock = require('ngMock'); +let _ = require('lodash'); describe('Vislib Vis Types Test Suite', function () { let visTypes; diff --git a/src/ui/public/vislib/components/Tooltip/__tests__/positioning.js b/src/ui/public/vislib/components/Tooltip/__tests__/positioning.js index 65337332cc412..03fb2ae5e4edc 100644 --- a/src/ui/public/vislib/components/Tooltip/__tests__/positioning.js +++ b/src/ui/public/vislib/components/Tooltip/__tests__/positioning.js @@ -1,22 +1,22 @@ -var expect = require('expect.js'); +let expect = require('expect.js'); describe('Tooltip Positioning', function () { - var $ = require('jquery'); - var _ = require('lodash'); - var sinon = require('auto-release-sinon'); + let $ = require('jquery'); + let _ = require('lodash'); + let sinon = require('auto-release-sinon'); - var posTT = require('../positionTooltip'); - var positions = ['north', 'south', 'east', 'west']; - var bounds = ['top', 'left', 'bottom', 'right']; + let posTT = require('../positionTooltip'); + let positions = ['north', 'south', 'east', 'west']; + let bounds = ['top', 'left', 'bottom', 'right']; let $window; let $chart; let $tooltip; let $sizer; function testEl(width, height, $children) { - var $el = $('
'); + let $el = $('
'); - var size = { + let size = { width: _.random(width[0], width[1]), height: _.random(height[0], height[1]) }; @@ -57,7 +57,7 @@ describe('Tooltip Positioning', function () { xPercent = xPercent || 0.5; yPercent = yPercent || 0.5; - var base = $chart.offset(); + let base = $chart.offset(); return { clientX: base.left + ($chart.testSize.width * xPercent), @@ -67,14 +67,14 @@ describe('Tooltip Positioning', function () { describe('getTtSize()', function () { it('should measure the outer-size of the tooltip using an un-obstructed clone', function () { - var w = sinon.spy($.fn, 'outerWidth'); - var h = sinon.spy($.fn, 'outerHeight'); + let w = sinon.spy($.fn, 'outerWidth'); + let h = sinon.spy($.fn, 'outerHeight'); posTT.getTtSize($tooltip.html(), $sizer); [w, h].forEach(function (spy) { expect(spy).to.have.property('callCount', 1); - var matchHtml = w.thisValues.filter(function ($t) { + let matchHtml = w.thisValues.filter(function ($t) { return !$t.is($tooltip) && $t.html() === $tooltip.html(); }); expect(matchHtml).to.have.length(1); @@ -84,8 +84,8 @@ describe('Tooltip Positioning', function () { describe('getBasePosition()', function () { it('calculates the offset values for the four positions', function () { - var size = posTT.getTtSize($tooltip.html(), $sizer); - var pos = posTT.getBasePosition(size, makeEvent()); + let size = posTT.getTtSize($tooltip.html(), $sizer); + let pos = posTT.getBasePosition(size, makeEvent()); positions.forEach(function (p) { expect(pos).to.have.property(p); @@ -98,7 +98,7 @@ describe('Tooltip Positioning', function () { describe('getBounds()', function () { it('returns the offsets for the tlrb of the element', function () { - var cbounds = posTT.getBounds($chart); + let cbounds = posTT.getBounds($chart); bounds.forEach(function (b) { expect(cbounds).to.have.property(b); @@ -114,14 +114,14 @@ describe('Tooltip Positioning', function () { // size the tooltip very small so it won't collide with the edges $tooltip.css({ width: 15, height: 15 }); $sizer.css({ width: 15, height: 15 }); - var size = posTT.getTtSize($tooltip.html(), $sizer); + let size = posTT.getTtSize($tooltip.html(), $sizer); expect(size).to.have.property('width', 15); expect(size).to.have.property('height', 15); // position the element based on a mouse that is in the middle of the chart - var pos = posTT.getBasePosition(size, makeEvent(0.5, 0.5)); + let pos = posTT.getBasePosition(size, makeEvent(0.5, 0.5)); - var overflow = posTT.getOverflow(size, pos, [$chart, $window]); + let overflow = posTT.getOverflow(size, pos, [$chart, $window]); positions.forEach(function (p) { expect(overflow).to.have.property(p); @@ -131,11 +131,11 @@ describe('Tooltip Positioning', function () { }); it('identifies an overflow with a positive value in that direction', function () { - var size = posTT.getTtSize($tooltip.html(), $sizer); + let size = posTT.getTtSize($tooltip.html(), $sizer); // position the element based on a mouse that is in the bottom right hand courner of the chart - var pos = posTT.getBasePosition(size, makeEvent(0.99, 0.99)); - var overflow = posTT.getOverflow(size, pos, [$chart, $window]); + let pos = posTT.getBasePosition(size, makeEvent(0.99, 0.99)); + let overflow = posTT.getOverflow(size, pos, [$chart, $window]); positions.forEach(function (p) { expect(overflow).to.have.property(p); @@ -157,9 +157,9 @@ describe('Tooltip Positioning', function () { }); function check(xPercent, yPercent/*, prev, directions... */) { - var directions = _.drop(arguments, 2); - var event = makeEvent(xPercent, yPercent); - var placement = posTT({ + let directions = _.drop(arguments, 2); + let event = makeEvent(xPercent, yPercent); + let placement = posTT({ $window: $window, $chart: $chart, $sizer: $sizer, @@ -214,12 +214,12 @@ describe('Tooltip Positioning', function () { describe('maintain the direction of the tooltip on reposition', function () { it('mouse moves from the top right to the middle', function () { - var pos = check(0.99, 0.10, 'bottom', 'left'); + let pos = check(0.99, 0.10, 'bottom', 'left'); check(0.50, 0.50, pos, 'bottom', 'left'); }); it('mouse moves from the bottom left to the middle', function () { - var pos = check(0.10, 0.99, 'top', 'right'); + let pos = check(0.10, 0.99, 'top', 'right'); check(0.50, 0.50, pos, 'top', 'right'); }); }); diff --git a/src/ui/public/vislib_vis_type/__tests__/_VislibRenderbot.js b/src/ui/public/vislib_vis_type/__tests__/_VislibRenderbot.js index 2fc40c45f4037..2e28d8a450f6d 100644 --- a/src/ui/public/vislib_vis_type/__tests__/_VislibRenderbot.js +++ b/src/ui/public/vislib_vis_type/__tests__/_VislibRenderbot.js @@ -1,16 +1,16 @@ describe('renderbot', function exportWrapper() { - var _ = require('lodash'); - var $ = require('jquery'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var sinon = require('auto-release-sinon'); + let _ = require('lodash'); + let $ = require('jquery'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let sinon = require('auto-release-sinon'); let vislib; let Vis; let Renderbot; let VislibRenderbot; let persistedState; let normalizeChartData; - var mockVisType = { + let mockVisType = { name: 'test' }; @@ -30,8 +30,8 @@ describe('renderbot', function exportWrapper() { beforeEach(init); describe('creation', function () { - var vis = { type: mockVisType }; - var $el = 'element'; + let vis = { type: mockVisType }; + let $el = 'element'; let createVisStub; let renderbot; @@ -50,7 +50,7 @@ describe('renderbot', function exportWrapper() { }); describe('_createVis', function () { - var vis = { + let vis = { type: mockVisType, listeners: { 'test': _.noop, @@ -58,7 +58,7 @@ describe('renderbot', function exportWrapper() { 'test3': _.noop } }; - var $el = $('
testing
'); + let $el = $('
testing
'); let listenerSpy; let renderbot; @@ -76,15 +76,15 @@ describe('renderbot', function exportWrapper() { }); describe('param update', function () { - var params = { one: 'fish', two: 'fish' }; - var vis = { + let params = { one: 'fish', two: 'fish' }; + let vis = { type: _.defaults({ params: { defaults: params } }, mockVisType) }; - var $el = $('
testing
'); + let $el = $('
testing
'); let createVisSpy; let getParamsStub; let renderbot; @@ -113,20 +113,20 @@ describe('renderbot', function exportWrapper() { }); describe('render', function () { - var vis = { type: mockVisType, isHierarchical: _.constant(false) }; - var $el = $('
testing
'); - var stubs = {}; + let vis = { type: mockVisType, isHierarchical: _.constant(false) }; + let $el = $('
testing
'); + let stubs = {}; beforeEach(function () { sinon.stub(VislibRenderbot.prototype, '_getVislibParams', _.constant({})); }); it('should use #buildChartData', function () { - var renderbot = new VislibRenderbot(vis, $el, persistedState); + let renderbot = new VislibRenderbot(vis, $el, persistedState); - var football = {}; - var buildStub = sinon.stub(renderbot, 'buildChartData', _.constant(football)); - var renderStub = sinon.stub(renderbot.vislibVis, 'render'); + let football = {}; + let buildStub = sinon.stub(renderbot, 'buildChartData', _.constant(football)); + let renderStub = sinon.stub(renderbot.vislibVis, 'render'); renderbot.render('flat data', persistedState); expect(renderStub.callCount).to.be(1); @@ -136,7 +136,7 @@ describe('renderbot', function exportWrapper() { }); describe('destroy', function () { - var vis = { + let vis = { type: mockVisType, listeners: { 'test': _.noop, @@ -144,7 +144,7 @@ describe('renderbot', function exportWrapper() { 'test3': _.noop } }; - var $el = $('
testing
'); + let $el = $('
testing
'); let listenerSpy; let renderbot; @@ -161,7 +161,7 @@ describe('renderbot', function exportWrapper() { }); it('should destroy the vis', function () { - var spy = sinon.spy(renderbot.vislibVis, 'destroy'); + let spy = sinon.spy(renderbot.vislibVis, 'destroy'); renderbot.destroy(); expect(spy.callCount).to.be(1); }); diff --git a/src/ui/public/vislib_vis_type/__tests__/_buildChartData.js b/src/ui/public/vislib_vis_type/__tests__/_buildChartData.js index f731e60342527..2778597602fc4 100644 --- a/src/ui/public/vislib_vis_type/__tests__/_buildChartData.js +++ b/src/ui/public/vislib_vis_type/__tests__/_buildChartData.js @@ -1,8 +1,8 @@ describe('renderbot#buildChartData', function () { - var _ = require('lodash'); - var ngMock = require('ngMock'); - var expect = require('expect.js'); - var sinon = require('auto-release-sinon'); + let _ = require('lodash'); + let ngMock = require('ngMock'); + let expect = require('expect.js'); + let sinon = require('auto-release-sinon'); let buildChartData; let aggResponse; @@ -19,14 +19,14 @@ describe('renderbot#buildChartData', function () { describe('for hierarchical vis', function () { it('defers to hierarchical aggResponse converter', function () { - var football = {}; - var renderbot = { + let football = {}; + let renderbot = { vis: { isHierarchical: _.constant(true) } }; - var stub = sinon.stub(aggResponse, 'hierarchical').returns(football); + let stub = sinon.stub(aggResponse, 'hierarchical').returns(football); expect(buildChartData.call(renderbot, football)).to.be(football); expect(stub).to.have.property('callCount', 1); expect(stub.firstCall.args[0]).to.be(renderbot.vis); @@ -36,14 +36,14 @@ describe('renderbot#buildChartData', function () { describe('for point plot', function () { it('calls tabify to simplify the data into a table', function () { - var renderbot = { + let renderbot = { vis: { isHierarchical: _.constant(false) } }; - var football = { tables: [], hits: { total: 1 } }; + let football = { tables: [], hits: { total: 1 } }; - var stub = sinon.stub(aggResponse, 'tabify').returns(football); + let stub = sinon.stub(aggResponse, 'tabify').returns(football); expect(buildChartData.call(renderbot, football)).to.eql({ rows: [], hits: 1 }); expect(stub).to.have.property('callCount', 1); expect(stub.firstCall.args[0]).to.be(renderbot.vis); @@ -51,8 +51,8 @@ describe('renderbot#buildChartData', function () { }); it('returns a single chart if the tabify response contains only a single table', function () { - var chart = { hits: 1, rows: [], columns: [] }; - var renderbot = { + let chart = { hits: 1, rows: [], columns: [] }; + let renderbot = { vis: { isHierarchical: _.constant(false), type: { @@ -60,20 +60,20 @@ describe('renderbot#buildChartData', function () { } } }; - var esResp = { hits: { total: 1 } }; - var tabbed = { tables: [ new Table() ] }; + let esResp = { hits: { total: 1 } }; + let tabbed = { tables: [ new Table() ] }; sinon.stub(aggResponse, 'tabify').returns(tabbed); expect(buildChartData.call(renderbot, esResp)).to.eql(chart); }); it('converts table groups into rows/columns wrappers for charts', function () { - var chart = { hits: 1, rows: [], columns: [] }; - var converter = sinon.stub().returns('chart'); - var esResp = { hits: { total: 1 } }; - var tables = [new Table(), new Table(), new Table(), new Table()]; + let chart = { hits: 1, rows: [], columns: [] }; + let converter = sinon.stub().returns('chart'); + let esResp = { hits: { total: 1 } }; + let tables = [new Table(), new Table(), new Table(), new Table()]; - var renderbot = { + let renderbot = { vis: { isHierarchical: _.constant(false), type: { @@ -82,7 +82,7 @@ describe('renderbot#buildChartData', function () { } }; - var tabify = sinon.stub(aggResponse, 'tabify').returns({ + let tabify = sinon.stub(aggResponse, 'tabify').returns({ tables: [ { aggConfig: { params: { row: true } }, @@ -113,7 +113,7 @@ describe('renderbot#buildChartData', function () { ] }); - var chartData = buildChartData.call(renderbot, esResp); + let chartData = buildChartData.call(renderbot, esResp); // verify tables were converted expect(converter).to.have.property('callCount', 4); diff --git a/src/ui/public/watch_multi/__tests__/watch_multi.js b/src/ui/public/watch_multi/__tests__/watch_multi.js index 0d4434e0022fd..3c54d82e565d9 100644 --- a/src/ui/public/watch_multi/__tests__/watch_multi.js +++ b/src/ui/public/watch_multi/__tests__/watch_multi.js @@ -1,10 +1,10 @@ -var _ = require('lodash'); -var ngMock = require('ngMock'); -var expect = require('expect.js'); +let _ = require('lodash'); +let ngMock = require('ngMock'); +let expect = require('expect.js'); describe('$scope.$watchMulti', function () { - var sinon = require('auto-release-sinon'); + let sinon = require('auto-release-sinon'); let $rootScope; let $scope; @@ -20,15 +20,15 @@ describe('$scope.$watchMulti', function () { expect($rootScope.$watchMulti).to.be.a('function'); expect($scope).to.have.property('$watchMulti', $rootScope.$watchMulti); - var $isoScope = $scope.$new(true); + let $isoScope = $scope.$new(true); expect($isoScope).to.have.property('$watchMulti', $rootScope.$watchMulti); }); it('returns a working unwatch function', function () { $scope.a = 0; $scope.b = 0; - var triggers = 0; - var unwatch = $scope.$watchMulti(['a', 'b'], function () { triggers++; }); + let triggers = 0; + let unwatch = $scope.$watchMulti(['a', 'b'], function () { triggers++; }); // initial watch $scope.$apply(); @@ -53,7 +53,7 @@ describe('$scope.$watchMulti', function () { describe('simple scope watchers', function () { it('only triggers a single watch on initialization', function () { - var stub = sinon.stub(); + let stub = sinon.stub(); $scope.$watchMulti([ 'one', @@ -66,7 +66,7 @@ describe('$scope.$watchMulti', function () { }); it('only triggers a single watch when multiple values change', function () { - var stub = sinon.spy(function (a, b) {}); + let stub = sinon.spy(function (a, b) {}); $scope.$watchMulti([ 'one', @@ -87,7 +87,7 @@ describe('$scope.$watchMulti', function () { it('passes an array of the current and previous values, in order', function () { - var stub = sinon.spy(function (a, b) {}); + let stub = sinon.spy(function (a, b) {}); $scope.one = 'a'; $scope.two = 'b'; @@ -116,7 +116,7 @@ describe('$scope.$watchMulti', function () { }); it('always has an up to date value', function () { - var count = 0; + let count = 0; $scope.vals = [1, 0]; $scope.$watchMulti([ 'vals[0]', 'vals[1]' ], function (cur, prev) { @@ -124,7 +124,7 @@ describe('$scope.$watchMulti', function () { count++; }); - var $child = $scope.$new(); + let $child = $scope.$new(); $child.$watch('vals[0]', function (cur) { $child.vals[1] = cur; }); @@ -140,11 +140,11 @@ describe('$scope.$watchMulti', function () { let secondValue; beforeEach(function () { - var firstGetter = function () { + let firstGetter = function () { return firstValue; }; - var secondGetter = function () { + let secondGetter = function () { return secondValue; }; @@ -158,7 +158,7 @@ describe('$scope.$watchMulti', function () { }); it('should trigger the watcher on initialization', function () { - var stub = sinon.stub(); + let stub = sinon.stub(); firstValue = 'first'; secondValue = 'second'; @@ -174,7 +174,7 @@ describe('$scope.$watchMulti', function () { describe('nested watchers', function () { it('should trigger the handler at least once', function () { - var $scope = $rootScope.$new(); + let $scope = $rootScope.$new(); $scope.$$watchers = [{ get: _.noop, fn: _.noop, @@ -187,8 +187,8 @@ describe('$scope.$watchMulti', function () { last: false }]; - var first = sinon.stub(); - var second = sinon.stub(); + let first = sinon.stub(); + let second = sinon.stub(); function registerWatchers() { $scope.$watchMulti([first, second], function () {