diff --git a/src/ui/__tests__/ui_exports.js b/src/ui/__tests__/ui_exports.js index adf561822e947..e5f6996af5fee 100644 --- a/src/ui/__tests__/ui_exports.js +++ b/src/ui/__tests__/ui_exports.js @@ -7,7 +7,7 @@ import * as kbnTestServer from '../../../test/utils/kbn_server'; 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']; @@ -17,7 +17,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/agg_response/geo_json/__tests__/geo_json.js b/src/ui/public/agg_response/geo_json/__tests__/geo_json.js index 78fc73fdd6c2b..94bb16a66cb98 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 @@ -17,8 +17,8 @@ describe('GeoJson Agg Response Converter', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var Vis = Private(VisProvider); - var indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); + let Vis = Private(VisProvider); + let indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); esResponse = Private(FixturesAggRespGeohashGridProvider); tabify = Private(AggResponseTabifyTabifyProvider); @@ -60,8 +60,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', @@ -78,9 +78,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'); @@ -88,8 +88,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'); @@ -122,7 +122,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'); @@ -132,7 +132,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'); @@ -144,8 +144,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'); @@ -155,15 +155,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__/build_hierarchical_data.js b/src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js index 1498d6eb67f67..a5e5555c81243 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 @@ -35,7 +35,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -48,7 +48,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); @@ -67,8 +67,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' } }, @@ -79,13 +79,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' } }, @@ -96,7 +96,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'); }); @@ -107,7 +107,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -149,7 +149,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -181,7 +181,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -222,7 +222,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -258,7 +258,7 @@ describe('buildHierarchicalData', function () { let results; beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -281,7 +281,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 d7dba5977d5cf..d153e7d4afc34 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js @@ -4,7 +4,7 @@ import collectBranch from 'ui/agg_response/hierarchical/_collect_branch'; import expect from '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 9d05d2335e433..f42e4442c4fd1 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 @@ -27,7 +27,7 @@ describe('buildHierarchicalData()', function () { })); beforeEach(function () { - var id = 1; + let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ @@ -37,7 +37,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); @@ -48,7 +48,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 e6f3c365db479..8d2a45c3a1f45 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js @@ -7,14 +7,14 @@ describe('buildHierarchicalData()', 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 99afb3bb07f1e..97adf8ea4073b 100644 --- a/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js +++ b/src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js @@ -42,17 +42,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); @@ -60,7 +60,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 385f5e0a93040..4e9c563f78dbf 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 @@ -10,9 +10,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); @@ -23,13 +23,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); @@ -41,10 +41,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 8574fdf0af732..501631e1c921a 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 @@ -22,8 +22,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 efad784eacd94..e1bf5ce07a702 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 @@ -27,7 +27,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(); }); @@ -50,7 +50,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, @@ -92,7 +92,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); }); @@ -101,7 +101,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); @@ -110,7 +110,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); @@ -139,7 +139,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 6e77d96a695d4..1017a5f020cd1 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 @@ -7,8 +7,8 @@ describe('getPoint', function () { 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) { @@ -29,9 +29,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) @@ -42,8 +42,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); }); }); @@ -62,8 +62,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) @@ -73,8 +73,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) @@ -84,8 +84,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 c36a00be96289..b09fd319624fd 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 @@ -5,7 +5,7 @@ import AggResponsePointSeriesGetSeriesProvider from 'ui/agg_response/point_serie describe('getSeries', function () { let getSeries; - var agg = { fieldFormatter: _.constant(_.identity) }; + let agg = { fieldFormatter: _.constant(_.identity) }; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { @@ -19,7 +19,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], @@ -27,7 +27,7 @@ describe('getSeries', function () { [1, 2, 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: 0 }, y: { i: 1 }, @@ -35,13 +35,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', '') @@ -60,7 +60,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], @@ -68,7 +68,7 @@ describe('getSeries', function () { [1, 2, 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: 0 }, y: [ @@ -78,7 +78,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -103,7 +103,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'], @@ -114,7 +114,7 @@ describe('getSeries', function () { ['1', 3] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -122,7 +122,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -147,7 +147,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], @@ -156,7 +156,7 @@ describe('getSeries', function () { ['1', 3, 4] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -167,7 +167,7 @@ describe('getSeries', function () { } }; - var series = getSeries(rows, chart); + let series = getSeries(rows, chart); expect(series) .to.be.an('array') @@ -197,7 +197,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], @@ -206,7 +206,7 @@ describe('getSeries', function () { ['1', 3, 4] ].map(wrapRows); - var chart = { + let chart = { aspects: { x: { i: -1 }, series: { i: 0, agg: agg }, @@ -217,7 +217,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'); @@ -230,7 +230,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 2ca50fda6bff9..974afab294831 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 @@ -11,7 +11,7 @@ describe('initXAxis', function () { initXAxis = Private(AggResponsePointSeriesInitXAxisProvider); })); - var baseChart = { + let baseChart = { aspects: { x: { agg: { @@ -27,7 +27,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') @@ -35,7 +35,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); @@ -50,7 +50,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 ffb5d7e8682c2..97f1c98e12487 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 @@ -19,7 +19,7 @@ describe('initYAxis', function () { }; } - var baseChart = { + let baseChart = { aspects: { y: [ { agg: agg(), col: { title: 'y1' } }, @@ -33,17 +33,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'); }); @@ -51,7 +51,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'); @@ -61,7 +61,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 579d434f22129..8eba049940350 100644 --- a/src/ui/public/agg_response/point_series/__tests__/_main.js +++ b/src/ui/public/agg_response/point_series/__tests__/_main.js @@ -25,20 +25,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') @@ -47,7 +47,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' }, @@ -55,32 +55,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) @@ -100,7 +100,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' } }, @@ -109,40 +109,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); @@ -170,7 +170,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' } }, @@ -180,53 +180,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 f0c5bd3aabd1f..db7763ca82772 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 @@ -6,7 +6,7 @@ import ngMock from 'ng_mock'; import AggResponsePointSeriesOrderedDateAxisProvider from 'ui/agg_response/point_series/_ordered_date_axis'; describe('orderedDateAxis', function () { - var baseArgs = { + let baseArgs = { vis: { indexPattern: { timeFieldName: '@timestamp' @@ -37,7 +37,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'); @@ -45,10 +45,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')); }); @@ -56,7 +56,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) @@ -67,21 +67,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 6468fdd720471..73c9e796f252b 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 @@ -23,7 +23,7 @@ describe('tooltipFormatter', function () { return $row.eq(i).text().trim(); } - var baseEvent = { + let baseEvent = { datum: { aggConfigResult: { aggConfig: agg('inner'), @@ -42,20 +42,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 56c321d6de1bf..e2ecc8e75d55d 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_buckets.js +++ b/src/ui/public/agg_response/tabify/__tests__/_buckets.js @@ -12,13 +12,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); }); @@ -29,7 +29,7 @@ describe('Buckets wrapper', function () { } describe('with object style buckets', function () { - var aggResp = { + let aggResp = { buckets: { '0-100': {}, '100-200': {}, @@ -37,14 +37,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: {} }, @@ -52,8 +52,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 c9c844a683b5e..d8db8717c2dc0 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_get_columns.js +++ b/src/ui/public/agg_response/tabify/__tests__/_get_columns.js @@ -16,11 +16,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'); @@ -28,14 +28,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'); @@ -43,7 +43,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' } }, @@ -53,7 +53,7 @@ describe('get columns', function () { ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); expect(columns).to.have.length(8); columns.forEach(function (column, i) { @@ -63,7 +63,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' } }, @@ -75,7 +75,7 @@ describe('get columns', function () { ] }); - var columns = getColumns(vis); + let columns = getColumns(vis); function checkColumns(column, i) { expect(column).to.have.property('aggConfig'); @@ -93,14 +93,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' } }, @@ -112,7 +112,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 3b0ec6737738f..ea5d6096219d6 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_integration.js +++ b/src/ui/public/agg_response/tabify/__tests__/_integration.js @@ -26,13 +26,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'); @@ -81,7 +81,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); @@ -155,7 +155,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]); @@ -181,7 +181,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 }); @@ -215,7 +215,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 }); @@ -247,7 +247,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 608731f263c95..5f81ef8190d68 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_response_writer.js +++ b/src/ui/public/agg_response/tabify/__tests__/_response_writer.js @@ -42,15 +42,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' } } @@ -60,12 +60,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) { @@ -74,40 +74,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); @@ -120,29 +120,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 () { @@ -154,11 +154,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); @@ -166,7 +166,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); @@ -184,16 +184,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); @@ -201,7 +201,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' }, @@ -211,10 +211,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 () { @@ -230,11 +230,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]); @@ -243,7 +243,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); @@ -258,8 +258,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 () { @@ -272,10 +272,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 () { @@ -289,7 +289,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' } }, @@ -298,20 +298,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) { @@ -322,9 +322,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 @@ -347,7 +347,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' }}, @@ -355,8 +355,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(); }); @@ -366,7 +366,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' }}, @@ -374,8 +374,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 2f0c0f0077f23..1e4a869bcc229 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_table.js +++ b/src/ui/public/agg_response/tabify/__tests__/_table.js @@ -12,16 +12,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 }; @@ -30,7 +30,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); }); @@ -38,12 +38,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] @@ -55,9 +55,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) } @@ -69,9 +69,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 08d8372907010..5455caa143f34 100644 --- a/src/ui/public/agg_response/tabify/__tests__/_table_group.js +++ b/src/ui/public/agg_response/tabify/__tests__/_table_group.js @@ -10,7 +10,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 1c692da468b18..14ddb075192d1 100644 --- a/src/ui/public/agg_table/__tests__/_group.js +++ b/src/ui/public/agg_table/__tests__/_group.js @@ -34,9 +34,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(); @@ -46,7 +46,7 @@ describe('AggTableGroup Directive', function () { }); it('renders nothing if the table list is empty', function () { - var $el = $(''); + let $el = $(''); $scope.group = { tables: [] @@ -55,12 +55,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' } }, @@ -73,15 +73,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 8eadb01c5f124..062bd6ccfb37f 100644 --- a/src/ui/public/agg_table/__tests__/_table.js +++ b/src/ui/public/agg_table/__tests__/_table.js @@ -35,10 +35,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); @@ -48,14 +48,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' } }, @@ -69,27 +69,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(); }); @@ -109,11 +109,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: [ @@ -150,13 +150,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' }, @@ -172,7 +172,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' + @@ -185,12 +185,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__/agg_param_writer.js b/src/ui/public/agg_types/__tests__/agg_param_writer.js index ed9a12c043a06..58d113f2e6c5c 100644 --- a/src/ui/public/agg_types/__tests__/agg_param_writer.js +++ b/src/ui/public/agg_types/__tests__/agg_param_writer.js @@ -4,10 +4,10 @@ import AggTypesIndexProvider from 'ui/agg_types/index'; import RegistryVisTypesProvider from 'ui/registry/vis_types'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; module.exports = function AggParamWriterHelper(Private) { - var Vis = Private(VisProvider); - var aggTypes = Private(AggTypesIndexProvider); - var visTypes = Private(RegistryVisTypesProvider); - var stubbedLogstashIndexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); + let Vis = Private(VisProvider); + let aggTypes = Private(AggTypesIndexProvider); + let visTypes = Private(RegistryVisTypesProvider); + let stubbedLogstashIndexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); /** * Helper object for writing aggParams. Specify an aggType and it will find a vis & schema, and @@ -17,8 +17,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); * }); @@ -29,7 +29,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)) { @@ -47,7 +47,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; }); @@ -69,7 +69,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) { @@ -90,7 +90,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__/agg_params.js b/src/ui/public/agg_types/__tests__/agg_params.js index 4b2719ae3d287..1eff825ecb769 100644 --- a/src/ui/public/agg_types/__tests__/agg_params.js +++ b/src/ui/public/agg_types/__tests__/agg_params.js @@ -28,11 +28,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); @@ -42,43 +42,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' @@ -92,7 +92,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__/agg_type.js b/src/ui/public/agg_types/__tests__/agg_type.js index 10dd716ab3b5c..94dbcab47d495 100644 --- a/src/ui/public/agg_types/__tests__/agg_type.js +++ b/src/ui/public/agg_types/__tests__/agg_type.js @@ -39,7 +39,7 @@ describe('AggType Class', function () { }); describe('application of config properties', function () { - var copiedConfigProps = [ + let copiedConfigProps = [ 'name', 'title', 'makeLabel', @@ -48,11 +48,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]); @@ -62,9 +62,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 }); @@ -81,9 +81,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: [ { @@ -93,7 +93,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')); @@ -112,9 +112,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 }); @@ -128,7 +128,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' }); @@ -139,7 +139,7 @@ describe('AggType Class', function () { }); it('can disable customLabel', function () { - var aggType = new AggType({ + let aggType = new AggType({ name: 'smart agg', customLabels: false }); @@ -149,13 +149,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 }); @@ -169,8 +169,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 }); @@ -178,7 +178,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__/bucket_count_between.js b/src/ui/public/agg_types/__tests__/bucket_count_between.js index b1da84a139a57..75c2a4e46fdf7 100644 --- a/src/ui/public/agg_types/__tests__/bucket_count_between.js +++ b/src/ui/public/agg_types/__tests__/bucket_count_between.js @@ -32,7 +32,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: [ { @@ -46,14 +46,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: [ { @@ -67,14 +67,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: [ { @@ -88,13 +88,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: [ { @@ -104,8 +104,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' }); @@ -114,7 +114,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: [ { @@ -124,27 +124,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' }); @@ -154,14 +154,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, @@ -170,20 +170,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 e293c71aa263f..325e91ecf56c9 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/_histogram.js @@ -28,7 +28,7 @@ describe('Histogram Agg', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - var AggParamWriter = Private(AggParamWriterProvider); + let AggParamWriter = Private(AggParamWriterProvider); paramWriter = new AggParamWriter({ aggType: 'histogram' }); })); @@ -36,25 +36,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' }); @@ -68,7 +68,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 }); @@ -81,7 +81,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({ min_doc_count: true, extended_bounds: { min: 0 } }); @@ -90,7 +90,7 @@ describe('Histogram Agg', function () { }); it('writes when only eb.max is set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ min_doc_count: true, extended_bounds: { max: 0 } }); @@ -99,7 +99,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({ min_doc_count: true, extended_bounds: { min: 99, max: 100 } }); @@ -108,7 +108,7 @@ describe('Histogram Agg', function () { }); it('does not write when nothing is set', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ min_doc_count: true, extended_bounds: {} }); @@ -116,7 +116,7 @@ describe('Histogram Agg', function () { }); it('does not write when min_doc_count is false', function () { - var output = paramWriter.write({ + let output = paramWriter.write({ min_doc_count: false, extended_bounds: { min: 99, max: 100 } }); diff --git a/src/ui/public/agg_types/__tests__/buckets/_range.js b/src/ui/public/agg_types/__tests__/buckets/_range.js index 3c18eb8060605..a25c447bdd38f 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_range.js +++ b/src/ui/public/agg_types/__tests__/buckets/_range.js @@ -9,7 +9,7 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; describe('Range Agg', function () { - var buckets = values(resp.aggregations[1].buckets); + let buckets = values(resp.aggregations[1].buckets); let range; let Vis; @@ -21,7 +21,7 @@ describe('Range Agg', function () { Vis = Private(VisProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - var BytesFormat = Private(RegistryFieldFormatsProvider).byId.bytes; + let BytesFormat = Private(RegistryFieldFormatsProvider).byId.bytes; indexPattern.fieldFormatMap.bytes = new BytesFormat({ pattern: '0,0.[000] b' @@ -32,7 +32,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: [ { @@ -49,8 +49,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 86c5fbc7e43f4..cffbfb50d1a62 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 @@ -25,10 +25,10 @@ describe('AggConfig Filters', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - var Vis = Private(VisProvider); - var indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - var createFilter = Private(AggTypesBucketsCreateFilterDateHistogramProvider); - var TimeBuckets = Private(TimeBucketsProvider); + let Vis = Private(VisProvider); + let indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); + let createFilter = Private(AggTypesBucketsCreateFilterDateHistogramProvider); + let TimeBuckets = Private(TimeBucketsProvider); intervalOptions = Private(AggTypesBucketsIntervalOptionsProvider); init = function (interval, duration) { @@ -51,7 +51,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), @@ -68,7 +68,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'); @@ -95,8 +95,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 140231aeaeab7..117852228b6cc 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 @@ -23,7 +23,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: [ { @@ -38,8 +38,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 8bb6e5a3b64c2..43069575965af 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 @@ -23,7 +23,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: [ { @@ -39,8 +39,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 094acc337dfc7..702cd0ea746b7 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 @@ -23,7 +23,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: [ { @@ -34,8 +34,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 93157becdd0ef..d98e8f0727efc 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 @@ -21,7 +21,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: [ { @@ -40,8 +40,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); @@ -51,7 +51,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: [ { @@ -70,8 +70,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 c4ecfdba6f04a..b6ccd71d38cd5 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 @@ -21,7 +21,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: [ { @@ -37,8 +37,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 ea99720afb891..c0a67aa283655 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 @@ -21,12 +21,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 bf2c048ee683f..6d2e4834418eb 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 @@ -17,7 +17,7 @@ describe('editor', function () { beforeEach(ngMock.inject(function (Private, $injector, $compile) { indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - var Vis = Private(VisProvider); + let Vis = Private(VisProvider); /** * Render the AggParams editor for the date histogram aggregation @@ -38,8 +38,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'; @@ -48,10 +48,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, @@ -107,7 +107,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 8ea6e756df3e8..4e6c6870f2574 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 @@ -18,9 +18,9 @@ describe('params', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - var AggParamWriter = Private(AggParamWriterProvider); - var indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - var timefilter = $injector.get('timefilter'); + let AggParamWriter = Private(AggParamWriterProvider); + let indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); + let timefilter = $injector.get('timefilter'); timeField = indexPattern.timeFieldName; aggTypes = Private(AggTypesIndexProvider); @@ -31,7 +31,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({ @@ -43,24 +43,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); @@ -68,30 +68,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 } @@ -106,7 +106,7 @@ describe('params', function () { })); }); - var output = histoConfig.write(); + let output = histoConfig.write(); expect(_.has(output, 'metricScale')).to.be(should); }); }); @@ -115,9 +115,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 @@ -133,9 +133,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 5099871652494..3c7204b0682b8 100644 --- a/src/ui/public/agg_types/__tests__/controls/number_list.js +++ b/src/ui/public/agg_types/__tests__/controls/number_list.js @@ -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__/param_types/_calculate_interval.js b/src/ui/public/agg_types/__tests__/param_types/_calculate_interval.js index a5b6f033e0b76..47455e418a38a 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 @@ -21,15 +21,15 @@ describe('calculateInterval()', function () { calculateInterval = Private(AggTypesParamTypesCalculateIntervalProvider); })); - 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 b4a336957b08b..cc2679fc0d4b8 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_field.js +++ b/src/ui/public/agg_types/__tests__/param_types/_field.js @@ -17,7 +17,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 14cd247b44b74..69165309fb12d 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_optioned.js +++ b/src/ui/public/agg_types/__tests__/param_types/_optioned.js @@ -17,7 +17,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 ee9b995ac04cb..86c69ee620dad 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 @@ -6,7 +6,7 @@ import AggTypesParamTypesRawJsonProvider from 'ui/agg_types/param_types/raw_json module.exports = describe('JSON', function () { - var paramName = 'json_test'; + let paramName = 'json_test'; let BaseAggParam; let JsonAggParam; let aggParam; @@ -15,7 +15,7 @@ module.exports = describe('JSON', function () { function initAggParam(config) { config = config || {}; - var defaults = { + let defaults = { name: paramName, type: 'json' }; @@ -59,7 +59,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' }); @@ -75,7 +75,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' }); @@ -88,7 +88,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 87f21d2b7d19a..69e3d23905f27 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_regex.js +++ b/src/ui/public/agg_types/__tests__/param_types/_regex.js @@ -23,7 +23,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' }); @@ -36,11 +36,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 0b5c5fcf23f07..fde04e53a2742 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_string.js +++ b/src/ui/public/agg_types/__tests__/param_types/_string.js @@ -5,7 +5,7 @@ import AggTypesParamTypesBaseProvider from 'ui/agg_types/param_types/base'; import AggTypesParamTypesStringProvider from 'ui/agg_types/param_types/string'; module.exports = describe('String', function () { - var paramName = 'json_test'; + let paramName = 'json_test'; let BaseAggParam; let StringAggParam; let aggParam; @@ -14,7 +14,7 @@ module.exports = describe('String', function () { function initAggParam(config) { config = config || {}; - var defaults = { + let defaults = { name: paramName, type: 'string' }; @@ -42,8 +42,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 }); @@ -55,8 +55,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 4bf7df3c85c2c..c12ced529cf5f 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 @@ -2,7 +2,7 @@ import _ from 'lodash'; import sinon from '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 a0c6b15eeaef8..e7acb9b037080 100644 --- a/src/ui/public/bind/__tests__/bind.js +++ b/src/ui/public/bind/__tests__/bind.js @@ -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/binder/__tests__/binder.js b/src/ui/public/binder/__tests__/binder.js index f879ea3b69608..182050bb597fd 100644 --- a/src/ui/public/binder/__tests__/binder.js +++ b/src/ui/public/binder/__tests__/binder.js @@ -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/chrome/__tests__/nav_controls.js b/src/ui/public/chrome/__tests__/nav_controls.js index 64b3d54ef9d88..dda0bdc483465 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 5420c8881c8f5..46cb6fcaf9dd6 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 @@ -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 f4cf07d867413..0fff90df0f8f2 100644 --- a/src/ui/public/config/__tests__/config.js +++ b/src/ui/public/config/__tests__/config.js @@ -20,8 +20,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); }); @@ -31,7 +31,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'); }); @@ -41,21 +41,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 c8ff6b8460912..adae8151b2dcb 100644 --- a/src/ui/public/courier/data_source/__tests__/decorate_query.js +++ b/src/ui/public/courier/data_source/__tests__/decorate_query.js @@ -18,7 +18,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 9cf4dfdde9c46..8af5714e95931 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 @@ -24,8 +24,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 @@ -34,27 +34,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: { @@ -64,7 +64,7 @@ describe('SearchSource#normalizeSortRequest', function () { } }; - var result = normalizeSortRequest(sortState, indexPattern); + let result = normalizeSortRequest(sortState, indexPattern); expect(result).to.eql([normalizedSort]); sortState[fieldName] = { order: direction }; @@ -73,31 +73,31 @@ 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]); }); it('should remove unmapped_type parameter from _score sorting', function () { - var sortable = { _score: 'desc'}; - var expected = [{ + let sortable = { _score: 'desc'}; + let expected = [{ _score: { order: 'desc' } }]; - var result = normalizeSortRequest(sortable, indexPattern); + let result = normalizeSortRequest(sortable, indexPattern); expect(_.isEqual(result, expected)).to.be.ok(); }); diff --git a/src/ui/public/debounce/__tests__/debounce.js b/src/ui/public/debounce/__tests__/debounce.js index eec6762a45893..5208365c38a8f 100644 --- a/src/ui/public/debounce/__tests__/debounce.js +++ b/src/ui/public/debounce/__tests__/debounce.js @@ -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 21c2f53fd794d..b414843698b9d 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 @@ -7,16 +7,16 @@ import '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__/confirm-click.js b/src/ui/public/directives/__tests__/confirm-click.js index 8435eae9b7db2..bdb7e7d62355e 100644 --- a/src/ui/public/directives/__tests__/confirm-click.js +++ b/src/ui/public/directives/__tests__/confirm-click.js @@ -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 417c5a3125e81..535200bb0abc6 100644 --- a/src/ui/public/directives/__tests__/css_truncate.js +++ b/src/ui/public/directives/__tests__/css_truncate.js @@ -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__/fixed_scroll.js b/src/ui/public/directives/__tests__/fixed_scroll.js index d3ca2fed7f13c..7bcf4467ab740 100644 --- a/src/ui/public/directives/__tests__/fixed_scroll.js +++ b/src/ui/public/directives/__tests__/fixed_scroll.js @@ -9,7 +9,7 @@ import Promise from 'bluebird'; describe('FixedScroll directive', function () { 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__/input_focus.js b/src/ui/public/directives/__tests__/input_focus.js index a252ddd971769..5d30dbb52f0aa 100644 --- a/src/ui/public/directives/__tests__/input_focus.js +++ b/src/ui/public/directives/__tests__/input_focus.js @@ -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 56c375c147c5d..0d97c28dfd767 100644 --- a/src/ui/public/directives/__tests__/input_whole_number.js +++ b/src/ui/public/directives/__tests__/input_whole_number.js @@ -6,7 +6,7 @@ import '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 12713fdaafa83..b82de486c974c 100644 --- a/src/ui/public/directives/__tests__/json_input.js +++ b/src/ui/public/directives/__tests__/json_input.js @@ -7,7 +7,7 @@ import '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__/paginated_selectable_list.js b/src/ui/public/directives/__tests__/paginated_selectable_list.js index 0e5d9fcad7ca2..eb18304b478ff 100644 --- a/src/ui/public/directives/__tests__/paginated_selectable_list.js +++ b/src/ui/public/directives/__tests__/paginated_selectable_list.js @@ -3,7 +3,7 @@ import expect from 'expect.js'; import ngMock from 'ng_mock'; import _ from 'lodash'; -var objectList = [ +let objectList = [ { title: 'apple' }, { title: 'orange' }, { title: 'coconut' }, @@ -11,7 +11,7 @@ var objectList = [ { title: 'grapes' } ]; -var stringList = [ +let stringList = [ 'apple', 'orange', 'coconut', @@ -19,18 +19,18 @@ var stringList = [ 'grapes' ]; -var lists = [objectList, stringList, []]; +let lists = [objectList, stringList, []]; var $scope; var $element; var $isolatedScope; lists.forEach(function (list) { - var isArrayOfObjects = list.every((item) => { + let isArrayOfObjects = list.every((item) => { return _.isPlainObject(item); }); - var init = function (arr, willFail) { + let init = function (arr, willFail) { // Load the application ngMock.module('kibana'); @@ -83,8 +83,8 @@ lists.forEach(function (list) { }); it('should initially sort an array of objects in ascending order', function () { - var property = $isolatedScope.listProperty; - var sortedList = property ? _.sortBy(list, property) : _.sortBy(list); + let property = $isolatedScope.listProperty; + let sortedList = property ? _.sortBy(list, property) : _.sortBy(list); expect($isolatedScope.hits).to.be.an('array'); @@ -104,8 +104,8 @@ lists.forEach(function (list) { }); it('should sort an array of objects in ascending order', function () { - var property = $isolatedScope.listProperty; - var sortedList = property ? _.sortBy(list, property) : _.sortBy(list); + let property = $isolatedScope.listProperty; + let sortedList = property ? _.sortBy(list, property) : _.sortBy(list); $isolatedScope.isAscending = false; $isolatedScope.sortHits(list); @@ -122,8 +122,8 @@ lists.forEach(function (list) { }); it('should sort an array of objects in descending order', function () { - var property = $isolatedScope.listProperty; - var reversedList = property ? _.sortBy(list, property).reverse() : _.sortBy(list).reverse(); + let property = $isolatedScope.listProperty; + let reversedList = property ? _.sortBy(list, property).reverse() : _.sortBy(list).reverse(); $isolatedScope.isAscending = true; $isolatedScope.sortHits(list); @@ -146,8 +146,8 @@ lists.forEach(function (list) { }); it('should return the result of the function its passed', function () { - var property = $isolatedScope.listProperty; - var sortedList = property ? _.sortBy(list, property) : _.sortBy(list); + let property = $isolatedScope.listProperty; + let sortedList = property ? _.sortBy(list, property) : _.sortBy(list); $isolatedScope.hits.forEach(function (hit, index) { if (property) { @@ -165,8 +165,8 @@ lists.forEach(function (list) { }); it('should return the result of the function its passed', function () { - var property = $isolatedScope.listProperty; - var sortedList = property ? _.sortBy(list, property) : _.sortBy(list); + let property = $isolatedScope.listProperty; + let sortedList = property ? _.sortBy(list, property) : _.sortBy(list); $isolatedScope.userOnSelect = function (val) { return val; }; diff --git a/src/ui/public/directives/__tests__/parse_query.js b/src/ui/public/directives/__tests__/parse_query.js index 3e78f1e614ac7..6115bbdc20f35 100644 --- a/src/ui/public/directives/__tests__/parse_query.js +++ b/src/ui/public/directives/__tests__/parse_query.js @@ -14,14 +14,14 @@ let config; let $elemScope; let $elem; -var cycleIndex = 0; -var markup = ''; +let cycleIndex = 0; +let markup = ''; let fromUser; import toUser from 'ui/parse_query/lib/to_user'; import 'ui/parse_query'; import ParseQueryLibFromUserProvider from 'ui/parse_query/lib/from_user'; -var init = function () { +let init = function () { // Load the application ngMock.module('kibana'); @@ -41,7 +41,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__/timepicker.js b/src/ui/public/directives/__tests__/timepicker.js index 9d59f9d16675f..46208d5e80cd1 100644 --- a/src/ui/public/directives/__tests__/timepicker.js +++ b/src/ui/public/directives/__tests__/timepicker.js @@ -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 695f6d912f64a..6fc4b54390494 100644 --- a/src/ui/public/directives/__tests__/truncate.js +++ b/src/ui/public/directives/__tests__/truncate.js @@ -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 4a5cf3798f3fe..53ae966325067 100644 --- a/src/ui/public/directives/__tests__/typeahead.js +++ b/src/ui/public/directives/__tests__/typeahead.js @@ -7,8 +7,8 @@ import 'plugins/kibana/discover/index'; // TODO: This should not be needed, timefilter is only included here, it should move -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 d55b52cc64bed..702d983ab3b35 100644 --- a/src/ui/public/directives/__tests__/validate_cidr_mask.js +++ b/src/ui/public/directives/__tests__/validate_cidr_mask.js @@ -7,7 +7,7 @@ import '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 61d179356b981..02385b06a4940 100644 --- a/src/ui/public/directives/__tests__/validate_date_math.js +++ b/src/ui/public/directives/__tests__/validate_date_math.js @@ -7,7 +7,7 @@ import '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 16bca26e45467..f792f65c8174a 100644 --- a/src/ui/public/directives/__tests__/validate_index_name.js +++ b/src/ui/public/directives/__tests__/validate_index_name.js @@ -8,7 +8,7 @@ import '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 bf5bb8669dd5b..9f5066f28f8cf 100644 --- a/src/ui/public/directives/__tests__/validate_ip.js +++ b/src/ui/public/directives/__tests__/validate_ip.js @@ -7,7 +7,7 @@ import '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 99755a9897f74..cf2616dc4baf1 100644 --- a/src/ui/public/directives/__tests__/validate_json.js +++ b/src/ui/public/directives/__tests__/validate_json.js @@ -8,23 +8,23 @@ import '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 62b1bc365b5ec..b5dc9c3dcbbf6 100644 --- a/src/ui/public/doc_table/__tests__/doc_table.js +++ b/src/ui/public/doc_table/__tests__/doc_table.js @@ -23,7 +23,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; @@ -41,7 +41,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 52ed51913cced..3fc141bad8336 100644 --- a/src/ui/public/doc_table/__tests__/lib/get_sort.js +++ b/src/ui/public/doc_table/__tests__/lib/get_sort.js @@ -1,5 +1,5 @@ import getSort from 'ui/doc_table/lib/get_sort'; -var defaultSort = {time: 'desc'}; +let defaultSort = {time: 'desc'}; import expect from 'expect.js'; import ngMock from 'ng_mock'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; 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 fa92ccbec6ad3..f68527482c15e 100644 --- a/src/ui/public/doc_table/__tests__/lib/rows_headers.js +++ b/src/ui/public/doc_table/__tests__/lib/rows_headers.js @@ -28,7 +28,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); @@ -37,17 +37,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(); }); @@ -79,7 +79,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(); }); @@ -89,7 +89,7 @@ describe('Doc Table', function () { describe('kbnTableHeader', function () { - var $elem = angular.element( + let $elem = angular.element( '' ); @@ -120,7 +120,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); @@ -201,7 +201,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__/field_type.js b/src/ui/public/filters/__tests__/field_type.js index 1dd63bd1ab8f6..215a34be2c206 100644 --- a/src/ui/public/filters/__tests__/field_type.js +++ b/src/ui/public/filters/__tests__/field_type.js @@ -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 4e02b009b504b..920f6fb90f0bd 100644 --- a/src/ui/public/filters/__tests__/label.js +++ b/src/ui/public/filters/__tests__/label.js @@ -9,7 +9,7 @@ import '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 781a5d8362e1b..1d4a330251e5b 100644 --- a/src/ui/public/filters/__tests__/moment.js +++ b/src/ui/public/filters/__tests__/moment.js @@ -9,10 +9,10 @@ import '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 4ecfe30159979..2412d032da994 100644 --- a/src/ui/public/filters/__tests__/rison.js +++ b/src/ui/public/filters/__tests__/rison.js @@ -8,7 +8,7 @@ import '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 febc2a144639a..cacfab16b8676 100644 --- a/src/ui/public/filters/__tests__/short_dots.js +++ b/src/ui/public/filters/__tests__/short_dots.js @@ -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 32484c9094acf..3f03605c27f3d 100644 --- a/src/ui/public/filters/__tests__/start_from.js +++ b/src/ui/public/filters/__tests__/start_from.js @@ -6,7 +6,7 @@ import '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 f186614186a19..8baa7469ccf5c 100644 --- a/src/ui/public/filters/__tests__/uriescape.js +++ b/src/ui/public/filters/__tests__/uriescape.js @@ -7,7 +7,7 @@ import '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 fcf65da5fa34d..050cd99d92c27 100644 --- a/src/ui/public/highlight/__tests__/highlight.js +++ b/src/ui/public/highlight/__tests__/highlight.js @@ -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__/_cast_mapping_type.js b/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js index 3d4b8f6bef9bf..60a4b93ba6d77 100644 --- a/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js +++ b/src/ui/public/index_patterns/__tests__/_cast_mapping_type.js @@ -20,7 +20,7 @@ describe('type normalizer (castMappingType)', function () { }); it('should cast numeric types to "number"', function () { - var types = [ + let types = [ 'float', 'double', 'integer', @@ -36,7 +36,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', @@ -53,7 +53,7 @@ describe('type normalizer (castMappingType)', function () { }); it('should cast text and keyword types to "string"', function () { - var types = [ + let types = [ 'keyword', 'text' ]; diff --git a/src/ui/public/index_patterns/__tests__/_field_format.js b/src/ui/public/index_patterns/__tests__/_field_format.js index 710b0738ac963..fd8eb22e9dd97 100644 --- a/src/ui/public/index_patterns/__tests__/_field_format.js +++ b/src/ui/public/index_patterns/__tests__/_field_format.js @@ -24,14 +24,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); }); @@ -39,29 +39,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'); }); }); @@ -69,7 +69,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'); }); @@ -81,9 +81,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('formatted')).to.be('formatted'); expect(html('formatted')).to.be('formatted'); @@ -95,9 +95,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('formatted text')).to.be('formatted text'); expect(html('formatted html')).to.be('formatted html'); @@ -105,13 +105,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('<'); }); @@ -121,7 +121,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(''); }); @@ -134,7 +134,7 @@ describe('FieldFormat class', function () { html: _.constant('html'), }; - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('val')).to.be('text'); }); @@ -144,12 +144,12 @@ describe('FieldFormat class', function () { html: _.constant('html'), }; - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert('val', 'html')).to.be('html'); }); it('formats a value as " - " when no value is specified', function () { - var f = new TestFormat(); + let f = new TestFormat(); expect(f.convert()).to.be(' - '); }); }); diff --git a/src/ui/public/index_patterns/__tests__/_index_pattern.js b/src/ui/public/index_patterns/__tests__/_index_pattern.js index f11650ec7188f..ccce5e10f73f5 100644 --- a/src/ui/public/index_patterns/__tests__/_index_pattern.js +++ b/src/ui/public/index_patterns/__tests__/_index_pattern.js @@ -20,7 +20,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; @@ -77,7 +77,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); @@ -129,16 +129,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); }); @@ -147,7 +147,7 @@ describe('index pattern', function () { describe('refresh fields', function () { // override the default indexPattern, with a truncated field list require('test_utils/no_digest_promises').activateForSuite(); - var indexPatternId = 'test-pattern'; + let indexPatternId = 'test-pattern'; let indexPattern; let fieldLength; let truncatedFields; @@ -181,8 +181,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')); }); @@ -193,15 +193,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')); }); }); @@ -210,11 +210,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' @@ -222,17 +222,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); @@ -242,8 +242,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) { @@ -254,9 +254,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); @@ -266,10 +266,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); @@ -280,9 +280,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); @@ -293,7 +293,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); }); @@ -311,11 +311,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'); }); @@ -340,13 +340,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'); }); @@ -361,7 +361,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); }); }); @@ -372,7 +372,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); }); }); @@ -390,11 +390,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'); }); @@ -420,13 +420,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'); }); @@ -442,7 +442,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 feaf6b4c6dae2..3384e9c530a7c 100644 --- a/src/ui/public/index_patterns/__tests__/_map_field.js +++ b/src/ui/public/index_patterns/__tests__/_map_field.js @@ -18,31 +18,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; @@ -51,7 +51,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 b65ce865f12bf..e2313bce95759 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 @@ import expect from 'expect.js'; describe('Index pattern to wildcard', function () { - var fn = require('ui/index_patterns/_pattern_to_wildcard')(); + let fn = require('ui/index_patterns/_pattern_to_wildcard')(); 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 427ef3f074588..632e959b263cc 100644 --- a/src/ui/public/index_patterns/__tests__/flatten_hit.js +++ b/src/ui/public/index_patterns/__tests__/flatten_hit.js @@ -13,7 +13,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 241cdda7e53e0..ff486c86a68c4 100644 --- a/src/ui/public/index_patterns/__tests__/intervals.js +++ b/src/ui/public/index_patterns/__tests__/intervals.js @@ -14,10 +14,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', @@ -33,10 +33,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', @@ -82,10 +82,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', @@ -106,10 +106,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', @@ -126,10 +126,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', @@ -147,10 +147,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/indexed_array/__tests__/indexed_array.js b/src/ui/public/indexed_array/__tests__/indexed_array.js index f0ee09fc1fce5..69820fbe8bba4 100644 --- a/src/ui/public/indexed_array/__tests__/indexed_array.js +++ b/src/ui/public/indexed_array/__tests__/indexed_array.js @@ -4,7 +4,7 @@ import expect from 'expect.js'; import IndexedArray from 'ui/indexed_array'; // 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/indexed_array/__tests__/inflector.js b/src/ui/public/indexed_array/__tests__/inflector.js index 6af57d8ce99c1..3fc45e1a9f974 100644 --- a/src/ui/public/indexed_array/__tests__/inflector.js +++ b/src/ui/public/indexed_array/__tests__/inflector.js @@ -3,13 +3,13 @@ import expect from '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/jquery/__tests__/find_test_subject.js b/src/ui/public/jquery/__tests__/find_test_subject.js index 0bc06bca17358..7a70ec05bd2a1 100644 --- a/src/ui/public/jquery/__tests__/find_test_subject.js +++ b/src/ui/public/jquery/__tests__/find_test_subject.js @@ -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 261139420b4cf..a4dcae53d176d 100644 --- a/src/ui/public/listen/__tests__/listen.js +++ b/src/ui/public/listen/__tests__/listen.js @@ -22,8 +22,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); @@ -33,8 +33,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'); @@ -45,14 +45,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'); @@ -62,7 +62,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); @@ -70,7 +70,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/navbar_extensions/__tests__/navbar_extensions.js b/src/ui/public/navbar_extensions/__tests__/navbar_extensions.js index 8f2e78652e701..04518f44d5387 100644 --- a/src/ui/public/navbar_extensions/__tests__/navbar_extensions.js +++ b/src/ui/public/navbar_extensions/__tests__/navbar_extensions.js @@ -69,7 +69,7 @@ describe('navbar-extensions directive', function () { it('should append to end then order == 0', function () { registerExtension({ order: 0 }); - var $el = init(); + let $el = init(); expect($el.find('button').last().hasClass('test-button')).to.be.ok(); }); @@ -96,7 +96,7 @@ describe('navbar-extensions directive', function () { ` }); - var $el = init(); + let $el = init(); expect($el.find('button').length).to.equal(3); expect($el.find('button').last().hasClass('test-button-2')).to.be.ok(); 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 2a9a2cae4526a..5b89a909386bc 100644 --- a/src/ui/public/notify/__tests__/lib/_format_es_msg.js +++ b/src/ui/public/notify/__tests__/lib/_format_es_msg.js @@ -3,23 +3,23 @@ import expect from 'expect.js'; describe('formatESMsg', function () { 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 393a44f2ddbd8..725fd6a518d73 100644 --- a/src/ui/public/notify/__tests__/lib/_format_msg.js +++ b/src/ui/public/notify/__tests__/lib/_format_msg.js @@ -3,26 +3,26 @@ import expect from 'expect.js'; describe('formatMsg', function () { 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 7c180c3580c8d..6416683902929 100644 --- a/src/ui/public/notify/__tests__/notifier.js +++ b/src/ui/public/notify/__tests__/notifier.js @@ -6,11 +6,11 @@ import Notifier from 'ui/notify/notifier'; describe('Notifier', function () { let $interval; - 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(function () { ngMock.module('kibana'); @@ -56,7 +56,7 @@ describe('Notifier', function () { }); it('sets timeRemaining and decrements', function () { - var notif = notify('error'); + let notif = notify('error'); expect(notif.timeRemaining).to.equal(300); $interval.flush(1000); @@ -64,8 +64,8 @@ describe('Notifier', function () { }); it('closes notification on lifetime expiry', function () { - var expectation = sinon.mock(); - var notif = notifier.error(message, expectation); + let expectation = sinon.mock(); + let notif = notifier.error(message, expectation); expectation.once(); expectation.withExactArgs('ignore'); @@ -76,7 +76,7 @@ describe('Notifier', function () { }); it('allows canceling of timer', function () { - var notif = notify('error'); + let notif = notify('error'); expect(notif.timerId).to.not.be(undefined); notif.cancelTimer(); @@ -85,7 +85,7 @@ describe('Notifier', function () { }); it('resets timer on addition to stack', function () { - var notif = notify('error'); + let notif = notify('error'); $interval.flush(100000); expect(notif.timeRemaining).to.equal(200); @@ -95,12 +95,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; }); @@ -133,12 +133,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; }); @@ -171,12 +171,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; }); @@ -197,13 +197,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 cbf6324455b27..5a1c6da246285 100644 --- a/src/ui/public/paginated_table/__tests__/index.js +++ b/src/ui/public/paginated_table/__tests__/index.js @@ -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 41ad7e078a3b7..11115f087e6f8 100644 --- a/src/ui/public/persisted_log/__tests__/persisted_log.js +++ b/src/ui/public/persisted_log/__tests__/persisted_log.js @@ -8,9 +8,9 @@ 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 e79f36a3bac97..af6a2deb3c9cf 100644 --- a/src/ui/public/persisted_state/__tests__/persisted_state.js +++ b/src/ui/public/persisted_state/__tests__/persisted_state.js @@ -36,7 +36,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); @@ -45,7 +45,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); @@ -53,10 +53,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); }; @@ -64,8 +64,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); }; @@ -75,10 +75,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); }; @@ -86,10 +86,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); }; @@ -99,10 +99,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); }; @@ -117,8 +117,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 @@ -127,9 +127,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 @@ -141,14 +141,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); @@ -157,15 +157,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); @@ -176,7 +176,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); }); @@ -184,28 +184,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'); @@ -213,8 +213,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' }}); @@ -225,16 +225,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'); @@ -242,8 +242,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'); @@ -251,8 +251,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' }}); @@ -264,8 +264,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' @@ -285,8 +285,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, @@ -299,8 +299,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' @@ -315,16 +315,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 @@ -334,21 +334,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); @@ -358,11 +358,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'); @@ -379,38 +379,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); @@ -421,7 +421,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' @@ -432,7 +432,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' } }); @@ -451,7 +451,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'] }); @@ -459,9 +459,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); @@ -471,25 +471,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 } }}); }); @@ -555,19 +555,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); @@ -579,14 +579,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'); }; @@ -667,7 +667,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 873a22ad2871a..fc3dab39d3436 100644 --- a/src/ui/public/private/__tests__/private.js +++ b/src/ui/public/private/__tests__/private.js @@ -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); }); @@ -115,12 +115,12 @@ describe('Private module loader', function () { }; } - 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.have.property('instance1'); expect(instance2.instance1).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 dbf5b5461f9d7..576fa9f0bd9ae 100644 --- a/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js +++ b/src/ui/public/reflow_watcher/__tests__/reflow_watcher.js @@ -8,11 +8,11 @@ import EventsProvider from 'ui/events'; import ReflowWatcherProvider from 'ui/reflow_watcher'; describe('Reflow watcher', function () { - 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); }; @@ -70,7 +70,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 fb39dc64c9617..85091d32bc754 100644 --- a/src/ui/public/registry/__tests__/index.js +++ b/src/ui/public/registry/__tests__/index.js @@ -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__/_route_manager.js b/src/ui/public/routes/__tests__/_route_manager.js index 29f99f49a1195..75685be9b093a 100644 --- a/src/ui/public/routes/__tests__/_route_manager.js +++ b/src/ui/public/routes/__tests__/_route_manager.js @@ -5,7 +5,7 @@ import RouteManager from 'ui/routes/route_manager'; import expect from '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/route_manager', 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/route_manager', 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/route_manager', 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__/_work_queue.js b/src/ui/public/routes/__tests__/_work_queue.js index 1321ec0fd81e4..863f7345075bd 100644 --- a/src/ui/public/routes/__tests__/_work_queue.js +++ b/src/ui/public/routes/__tests__/_work_queue.js @@ -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__/_wrap_route_with_prep.js b/src/ui/public/routes/__tests__/_wrap_route_with_prep.js index d1e915abf4d25..a56cb503e1d46 100644 --- a/src/ui/public/routes/__tests__/_wrap_route_with_prep.js +++ b/src/ui/public/routes/__tests__/_wrap_route_with_prep.js @@ -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 e30201d534f7f..7b33aaad955a3 100644 --- a/src/ui/public/safe_confirm/__tests__/safe_confirm.js +++ b/src/ui/public/safe_confirm/__tests__/safe_confirm.js @@ -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 5de4631512a2b..6f9af310db4a4 100644 --- a/src/ui/public/state_management/__tests__/app_state.js +++ b/src/ui/public/state_management/__tests__/app_state.js @@ -27,7 +27,7 @@ describe('State Management', function () { }); it('should use passed in params', function () { - var params = { + let params = { test: true, mock: false }; @@ -46,8 +46,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__/state.js b/src/ui/public/state_management/__tests__/state.js index 9af33460604c7..d0233594e5b44 100644 --- a/src/ui/public/state_management/__tests__/state.js +++ b/src/ui/public/state_management/__tests__/state.js @@ -23,26 +23,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(); @@ -54,7 +54,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(); }); @@ -67,29 +67,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(); @@ -101,7 +101,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(); @@ -111,7 +111,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(); @@ -123,7 +123,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'); @@ -131,15 +131,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 907c16dd7c018..8a4d5e2872f7c 100644 --- a/src/ui/public/storage/__tests__/storage.js +++ b/src/ui/public/storage/__tests__/storage.js @@ -5,7 +5,7 @@ import 'ui/storage'; let storage; let $window; -var payload = { first: 'john', last: 'smith' }; +let payload = { first: 'john', last: 'smith' }; function init() { @@ -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 652ef54ffefdf..f48823ea3d5e1 100644 --- a/src/ui/public/stringify/__tests__/_color.js +++ b/src/ui/public/stringify/__tests__/_color.js @@ -13,7 +13,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', @@ -27,7 +27,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 f1da188ef28fd..3154ae73c3616 100644 --- a/src/ui/public/stringify/__tests__/_conformance.js +++ b/src/ui/public/stringify/__tests__/_conformance.js @@ -8,7 +8,7 @@ let fieldFormats; let FieldFormat; let config; -var formatIds = [ +let formatIds = [ 'bytes', 'date', 'duration', @@ -73,7 +73,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'); }); @@ -81,11 +81,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', @@ -93,22 +93,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 f1975e0ce2594..aec730580bf48 100644 --- a/src/ui/public/stringify/__tests__/_date.js +++ b/src/ui/public/stringify/__tests__/_date.js @@ -15,8 +15,8 @@ describe('Date Format', function () { settings = config; fieldFormats = Private(RegistryFieldFormatsProvider); - var DateFormat = fieldFormats.getType('date'); - var date = new DateFormat(); + let DateFormat = fieldFormats.getType('date'); + let date = new DateFormat(); convert = date.convert.bind(date); })); @@ -30,17 +30,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 f49294c97d9c0..cd953acd1d445 100644 --- a/src/ui/public/stringify/__tests__/_ip.js +++ b/src/ui/public/stringify/__tests__/_ip.js @@ -10,7 +10,7 @@ describe('IP Address Format', function () { })); it('converts 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 8d2b9ae5de94b..63d4691c33b09 100644 --- a/src/ui/public/stringify/__tests__/_source.js +++ b/src/ui/public/stringify/__tests__/_source.js @@ -28,8 +28,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 a293abd83bc97..f0b4b254db15e 100644 --- a/src/ui/public/stringify/__tests__/_string.js +++ b/src/ui/public/stringify/__tests__/_string.js @@ -10,16 +10,16 @@ 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'); }); it('convert a string to title case', function () { - var StringFormat = fieldFormats.getType('string'); - var string = new StringFormat({ + let StringFormat = fieldFormats.getType('string'); + let string = new StringFormat({ transform: 'title' }); expect(string.convert('PLEASE DO NOT SHOUT')).to.be('Please Do Not Shout'); diff --git a/src/ui/public/stringify/__tests__/_truncate.js b/src/ui/public/stringify/__tests__/_truncate.js index a92a111f44631..7e9564944402a 100644 --- a/src/ui/public/stringify/__tests__/_truncate.js +++ b/src/ui/public/stringify/__tests__/_truncate.js @@ -10,29 +10,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 c9b7e2c230384..845ad0fb27885 100644 --- a/src/ui/public/stringify/__tests__/_url.js +++ b/src/ui/public/stringify/__tests__/_url.js @@ -19,9 +19,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'); @@ -30,17 +30,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'); @@ -49,15 +49,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'); @@ -65,19 +65,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}}' }); @@ -87,19 +87,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/style_compile/__tests__/style_compile.js b/src/ui/public/style_compile/__tests__/style_compile.js index f68a27c6c471a..3bb46d7f3cb27 100644 --- a/src/ui/public/style_compile/__tests__/style_compile.js +++ b/src/ui/public/style_compile/__tests__/style_compile.js @@ -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/url/__tests__/url.js b/src/ui/public/url/__tests__/url.js index 3e99ed56ae7ad..10319796c2443 100644 --- a/src/ui/public/url/__tests__/url.js +++ b/src/ui/public/url/__tests__/url.js @@ -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__/add_word_breaks.js b/src/ui/public/utils/__tests__/add_word_breaks.js index 870004c91dad3..594029f7e4045 100644 --- a/src/ui/public/utils/__tests__/add_word_breaks.js +++ b/src/ui/public/utils/__tests__/add_word_breaks.js @@ -4,7 +4,7 @@ import addWordBreaks from '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 ccc65824258d7..3c2711465b404 100644 --- a/src/ui/public/utils/__tests__/cidr_mask.js +++ b/src/ui/public/utils/__tests__/cidr_mask.js @@ -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 b50fe9c1f1518..7bc81a22f31b1 100644 --- a/src/ui/public/utils/__tests__/datemath.js +++ b/src/ui/public/utils/__tests__/datemath.js @@ -6,10 +6,10 @@ import sinon from '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 736fdc41b60a8..9ae29007ad3c0 100644 --- a/src/ui/public/utils/__tests__/diff_object.js +++ b/src/ui/public/utils/__tests__/diff_object.js @@ -5,70 +5,70 @@ import _ from '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 5299d36c9bb89..3fa98ac573c2f 100644 --- a/src/ui/public/utils/__tests__/diff_time_picker_vals.js +++ b/src/ui/public/utils/__tests__/diff_time_picker_vals.js @@ -13,13 +13,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' @@ -33,7 +33,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' @@ -50,7 +50,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() @@ -67,10 +67,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() @@ -85,11 +85,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() @@ -105,7 +105,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__/ipv4_address.js b/src/ui/public/utils/__tests__/ipv4_address.js index 6d37383fe63a5..dee0b3932e24f 100644 --- a/src/ui/public/utils/__tests__/ipv4_address.js +++ b/src/ui/public/utils/__tests__/ipv4_address.js @@ -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__/obj_define.js b/src/ui/public/utils/__tests__/obj_define.js index 0e5f5d1952333..fb4588fd0922d 100644 --- a/src/ui/public/utils/__tests__/obj_define.js +++ b/src/ui/public/utils/__tests__/obj_define.js @@ -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__/ordinal_suffix.js b/src/ui/public/utils/__tests__/ordinal_suffix.js index 0f82da7834a21..1fc5c716ca646 100644 --- a/src/ui/public/utils/__tests__/ordinal_suffix.js +++ b/src/ui/public/utils/__tests__/ordinal_suffix.js @@ -3,7 +3,7 @@ import addOrdinalSuffix from 'ui/utils/ordinal_suffix'; import expect from '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 1f3e746ec0ef6..fe65c29a01e97 100644 --- a/src/ui/public/utils/__tests__/parse_interval.js +++ b/src/ui/public/utils/__tests__/parse_interval.js @@ -3,7 +3,7 @@ import expect from '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'); @@ -29,7 +29,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'); @@ -37,7 +37,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'); @@ -45,7 +45,7 @@ describe('parseInterval', function () { }); it('should correctly parse a unit in an interval only', function () { - var duration = parseInterval('ms'); + let duration = parseInterval('ms'); expect(duration.as('ms')).to.be(1); duration = parseInterval('d'); @@ -62,7 +62,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 62bf2c6d128cd..de403fc61728d 100644 --- a/src/ui/public/utils/__tests__/range.js +++ b/src/ui/public/utils/__tests__/range.js @@ -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__/sequencer.js b/src/ui/public/utils/__tests__/sequencer.js index 11862e5dfe8a7..ef03a16b8f939 100644 --- a/src/ui/public/utils/__tests__/sequencer.js +++ b/src/ui/public/utils/__tests__/sequencer.js @@ -3,7 +3,7 @@ import sequencer from 'ui/utils/sequencer'; import expect from 'expect.js'; describe('sequencer util', function () { - 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__/simple_emitter.js b/src/ui/public/utils/__tests__/simple_emitter.js index ae031d5c63560..41518bbe877d9 100644 --- a/src/ui/public/utils/__tests__/simple_emitter.js +++ b/src/ui/public/utils/__tests__/simple_emitter.js @@ -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__/slugify_id.js b/src/ui/public/utils/__tests__/slugify_id.js index 72df24e4b8e17..18541030f0c4d 100644 --- a/src/ui/public/utils/__tests__/slugify_id.js +++ b/src/ui/public/utils/__tests__/slugify_id.js @@ -4,7 +4,7 @@ import expect from '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 728b019ef905e..f041849c687e6 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_move.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_move.js @@ -3,7 +3,7 @@ import expect from 'expect.js'; describe('_.move', function () { 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 b7861e162e6db..3f45863ec0de9 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js @@ -3,7 +3,7 @@ import expect from 'expect.js'; describe('_.organize', function () { 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 79f4ef47d3570..edf624b5cfa1f 100644 --- a/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js +++ b/src/ui/public/utils/lodash-mixins/__tests__/_push_all.js @@ -3,10 +3,10 @@ import expect from 'expect.js'; describe('_.pushAll', function () { 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/vis/__tests__/_agg_config.js b/src/ui/public/vis/__tests__/_agg_config.js index 168843af7e558..6cd93b738b6b6 100644 --- a/src/ui/public/vis/__tests__/_agg_config.js +++ b/src/ui/public/vis/__tests__/_agg_config.js @@ -25,7 +25,7 @@ describe('AggConfig', function () { describe('#toDsl', function () { it('calls #write()', function () { - var vis = new Vis(indexPattern, { + let vis = new Vis(indexPattern, { type: 'histogram', aggs: [ { @@ -35,15 +35,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: [ { @@ -53,15 +53,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: [ { @@ -71,17 +71,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: [ { @@ -95,14 +95,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'); @@ -114,7 +114,7 @@ describe('AggConfig', function () { describe('::ensureIds', function () { it('accepts an array of objects and assigns ids to them', function () { - var objs = [ + let objs = [ {}, {}, {}, @@ -128,7 +128,7 @@ describe('AggConfig', function () { }); it('assigns ids relative to the other items in the list', function () { - var objs = [ + let objs = [ { id: '100' }, {}, ]; @@ -138,7 +138,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' }, @@ -155,14 +155,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) { @@ -173,12 +173,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); }); @@ -191,7 +191,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: [ { @@ -201,13 +201,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'); @@ -217,37 +217,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: [ { @@ -273,7 +273,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: [ { @@ -284,13 +284,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: [ { @@ -301,13 +301,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: [ { @@ -318,7 +318,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__/_agg_config_result.js b/src/ui/public/vis/__tests__/_agg_config_result.js index e4c5b03bef14e..100549de9a924 100644 --- a/src/ui/public/vis/__tests__/_agg_config_result.js +++ b/src/ui/public/vis/__tests__/_agg_config_result.js @@ -20,12 +20,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'); @@ -34,12 +34,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'); @@ -53,18 +53,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); @@ -72,15 +72,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); @@ -90,15 +90,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__/_agg_configs.js b/src/ui/public/vis/__tests__/_agg_configs.js index ac94ecb619817..b8e4b72dd9d1b 100644 --- a/src/ui/public/vis/__tests__/_agg_configs.js +++ b/src/ui/public/vis/__tests__/_agg_configs.js @@ -22,7 +22,7 @@ describe('AggConfigs', function () { beforeEach(ngMock.inject(function (Private) { // replace the AggConfig module with a spy 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; } @@ -40,28 +40,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' @@ -77,12 +77,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' @@ -93,8 +93,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); }); @@ -135,17 +135,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'); }); @@ -154,7 +154,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' }, @@ -167,8 +167,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; }); @@ -185,7 +185,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' }, @@ -194,8 +194,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; }); @@ -206,7 +206,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' }, @@ -215,8 +215,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; }); @@ -231,14 +231,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' }, @@ -246,8 +246,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; @@ -260,7 +260,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); @@ -274,7 +274,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' } }, @@ -282,9 +282,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'); @@ -293,7 +293,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' } }, @@ -304,10 +304,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'); @@ -320,7 +320,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 } }, @@ -333,12 +333,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__/_vis.js b/src/ui/public/vis/__tests__/_vis.js index 79b937fd58fa0..d750bc5226fbf 100644 --- a/src/ui/public/vis/__tests__/_vis.js +++ b/src/ui/public/vis/__tests__/_vis.js @@ -12,7 +12,7 @@ describe('Vis Class', function () { let visTypes; let vis; - var stateFixture = { + let stateFixture = { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, @@ -34,7 +34,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); @@ -58,7 +58,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'); @@ -75,14 +75,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'); @@ -102,7 +102,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/vislib/__tests__/components/color.js b/src/ui/public/vislib/__tests__/components/color.js index 744d32d3d99a5..19138ad8ab9cf 100644 --- a/src/ui/public/vislib/__tests__/components/color.js +++ b/src/ui/public/vislib/__tests__/components/color.js @@ -16,14 +16,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; @@ -243,14 +243,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 d76dfe9c49e12..f0d7cd5e31c8a 100644 --- a/src/ui/public/vislib/__tests__/components/labels.js +++ b/src/ui/public/vislib/__tests__/components/labels.js @@ -15,7 +15,7 @@ let rowsArr; let uniqLabels; let error; -var seriesData = { +let seriesData = { 'label': '', 'series': [ { @@ -25,7 +25,7 @@ var seriesData = { ] }; -var rowsData = { +let rowsData = { 'rows': [ { 'label': 'a', @@ -66,7 +66,7 @@ var rowsData = { ] }; -var columnsData = { +let columnsData = { 'columns': [ { 'label': 'a', @@ -152,23 +152,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; @@ -267,7 +267,7 @@ describe('Vislib Labels Module Test Suite', function () { describe('Unique labels', function () { let uniqLabels; - var arrObj = [ + let arrObj = [ {'label': 'a'}, {'label': 'b'}, {'label': 'b'}, @@ -276,12 +276,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; @@ -340,18 +340,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 a055c0a9fb7a5..2393226c1f855 100644 --- a/src/ui/public/vislib/__tests__/components/zero_injection.js +++ b/src/ui/public/vislib/__tests__/components/zero_injection.js @@ -11,7 +11,7 @@ import VislibComponentsZeroInjectionZeroFilledArrayProvider from 'ui/vislib/comp import VislibComponentsZeroInjectionZeroFillDataArrayProvider from 'ui/vislib/components/zero_injection/zero_fill_data_array'; describe('Vislib Zero Injection Module Test Suite', function () { - var dateHistogramRows = { + let dateHistogramRows = { 'rows': [ { 'label': 'Top 5 @tags: success', @@ -161,7 +161,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var seriesData = { + let seriesData = { series: [ { label: '200', @@ -176,7 +176,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var multiSeriesData = { + let multiSeriesData = { series: [ { label: '200', @@ -205,7 +205,7 @@ describe('Vislib Zero Injection Module Test Suite', function () { ] }; - var multiSeriesNumberedData = { + let multiSeriesNumberedData = { series: [ { label: '200', @@ -234,24 +234,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 () { @@ -497,8 +497,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; @@ -578,10 +578,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')); @@ -659,7 +659,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__/lib/axis_title.js b/src/ui/public/vislib/__tests__/lib/axis_title.js index b2dc19f9e2799..bdb7f08b0701d 100644 --- a/src/ui/public/vislib/__tests__/lib/axis_title.js +++ b/src/ui/public/vislib/__tests__/lib/axis_title.js @@ -17,7 +17,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 1340146ab334f..469949d6d777b 100644 --- a/src/ui/public/vislib/__tests__/lib/chart_title.js +++ b/src/ui/public/vislib/__tests__/lib/chart_title.js @@ -15,7 +15,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 6903192f3ac4e..20224d660e6d3 100644 --- a/src/ui/public/vislib/__tests__/lib/data.js +++ b/src/ui/public/vislib/__tests__/lib/data.js @@ -9,7 +9,7 @@ import dataStacked from 'fixtures/vislib/mock_data/stacked/_stacked'; import VislibLibDataProvider from 'ui/vislib/lib/data'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var seriesData = { +let seriesData = { 'label': '', 'series': [ { @@ -19,7 +19,7 @@ var seriesData = { ] }; -var rowsData = { +let rowsData = { 'rows': [ { 'label': 'a', @@ -60,7 +60,7 @@ var rowsData = { ] }; -var colsData = { +let colsData = { 'columns': [ { 'label': 'a', @@ -117,12 +117,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': [ { @@ -132,12 +132,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': '', @@ -162,13 +162,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': '', @@ -194,7 +194,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'); }); @@ -203,7 +203,7 @@ describe('Vislib Data Class Test Suite', function () { describe('_removeZeroSlices', function () { let data; - var pieData = { + let pieData = { slices: { children: [ {size: 30}, @@ -218,7 +218,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); }); }); @@ -250,8 +250,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); @@ -266,9 +266,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); @@ -286,15 +286,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); }); }); @@ -303,9 +303,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); @@ -323,22 +323,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', @@ -381,14 +381,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); }); @@ -397,12 +397,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': [ @@ -413,7 +413,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 daee015c5f4cd..2fedc6a239ca2 100644 --- a/src/ui/public/vislib/__tests__/lib/dispatch.js +++ b/src/ui/public/vislib/__tests__/lib/dispatch.js @@ -39,7 +39,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); @@ -65,11 +65,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); @@ -88,11 +88,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'); @@ -109,7 +109,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/handler/handler.js b/src/ui/public/vislib/__tests__/lib/handler/handler.js index 5c73a1dc6eedd..ea933bf8d89e0 100644 --- a/src/ui/public/vislib/__tests__/lib/handler/handler.js +++ b/src/ui/public/vislib/__tests__/lib/handler/handler.js @@ -12,13 +12,13 @@ import $ from 'jquery'; import VislibLibHandlerHandlerProvider from 'ui/vislib/lib/handler/handler'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var dateHistogramArray = [ +let dateHistogramArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', @@ -30,7 +30,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 54cf3afe338b7..a69e53aa89235 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/layout.js +++ b/src/ui/public/vislib/__tests__/lib/layout/layout.js @@ -12,13 +12,13 @@ import $ from 'jquery'; import VislibLibLayoutLayoutProvider from 'ui/vislib/lib/layout/layout'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var dateHistogramArray = [ +let dateHistogramArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', 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 ce4169f6029c1..ce07621a41d93 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 @@ -15,7 +15,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 f4836cfa966e6..f500ad8dcb534 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 @@ -9,7 +9,7 @@ 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 68e916b5dc31f..f4bdb6b70622b 100644 --- a/src/ui/public/vislib/__tests__/lib/resize_checker.js +++ b/src/ui/public/vislib/__tests__/lib/resize_checker.js @@ -16,7 +16,7 @@ describe('Vislib Resize Checker', function () { let EventEmitter; let checker; let reflowWatcher; - var reflowSpies = {}; + let reflowSpies = {}; beforeEach(ngMock.module('kibana')); @@ -27,7 +27,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); @@ -47,7 +47,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'); }); @@ -63,8 +63,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); @@ -73,7 +73,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(); @@ -81,7 +81,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); }); @@ -123,12 +123,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); @@ -145,8 +145,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); @@ -154,7 +154,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); }); @@ -176,26 +176,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 e0dd324eab1b8..7b9ea1a5b3e03 100644 --- a/src/ui/public/vislib/__tests__/lib/x_axis.js +++ b/src/ui/public/vislib/__tests__/lib/x_axis.js @@ -16,7 +16,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 8c97e7af9897f..d89c1febb3003 100644 --- a/src/ui/public/vislib/__tests__/lib/y_axis.js +++ b/src/ui/public/vislib/__tests__/lib/y_axis.js @@ -15,7 +15,7 @@ let buildYAxis; let yAxis; let yAxisDiv; -var timeSeries = [ +let timeSeries = [ 1408734060000, 1408734090000, 1408734120000, @@ -28,7 +28,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 ] ]; @@ -43,7 +43,7 @@ function makeSeriesData(data) { } function createData(seriesData) { - var data = { + let data = { hits: 621, label: 'test', ordered: { @@ -59,7 +59,7 @@ function createData(seriesData) { yAxisLabel: 'Count' }; - var node = $('
').css({ + let node = $('
').css({ height: 40, width: 40 }) @@ -72,7 +72,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); @@ -133,10 +133,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; @@ -181,9 +181,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(); }); @@ -200,9 +200,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(); }); @@ -219,9 +219,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(); @@ -236,8 +236,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); @@ -250,7 +250,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); @@ -258,7 +258,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]); @@ -267,8 +267,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); @@ -276,8 +276,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); @@ -287,7 +287,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) { @@ -319,7 +319,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); }); }); @@ -343,13 +343,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'); }); @@ -384,23 +384,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 d80730ecfca7f..9129ca2a9d84c 100644 --- a/src/ui/public/vislib/__tests__/vis.js +++ b/src/ui/public/vislib/__tests__/vis.js @@ -11,14 +11,14 @@ import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var dataArray = [ +let dataArray = [ series, columns, rows, stackedSeries ]; -var names = [ +let names = [ 'series', 'columns', 'rows', @@ -28,8 +28,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; @@ -129,7 +129,7 @@ dataArray.forEach(function (data, i) { }); describe('on Method', function () { - var events = [ + let events = [ beforeEvent, afterEvent ]; @@ -173,7 +173,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); @@ -220,7 +220,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); @@ -236,7 +236,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 @@ -251,7 +251,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 6c8bb24f5b52b..72c125746e223 100644 --- a/src/ui/public/vislib/__tests__/visualizations/area_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/area_chart.js @@ -9,7 +9,7 @@ import notQuiteEnoughVariables from 'fixtures/vislib/mock_data/not_enough_data/_ import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var someOtherVariables = { +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'), @@ -18,7 +18,7 @@ var someOtherVariables = { 'stackedSeries': require('fixtures/vislib/mock_data/date_histogram/_stacked_series') }; -var visLibParams = { +let visLibParams = { type: 'area', addLegend: true, addTooltip: true @@ -158,12 +158,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; }); @@ -183,7 +183,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); @@ -192,7 +192,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); @@ -224,8 +224,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 e2c9601e0d25f..73ce39d9fab29 100644 --- a/src/ui/public/vislib/__tests__/visualizations/chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/chart.js @@ -14,12 +14,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 57ebe0cea8cba..e168d039513b5 100644 --- a/src/ui/public/vislib/__tests__/visualizations/column_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/column_chart.js @@ -10,14 +10,14 @@ import series from 'fixtures/vislib/mock_data/date_histogram/_series'; import seriesPosNeg from 'fixtures/vislib/mock_data/date_histogram/_series_pos_neg'; import seriesNeg from 'fixtures/vislib/mock_data/date_histogram/_series_neg'; import termsColumns from 'fixtures/vislib/mock_data/terms/_columns'; -//var histogramRows = require('fixtures/vislib/mock_data/histogram/_rows'); +//let histogramRows = require('fixtures/vislib/mock_data/histogram/_rows'); import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series'; import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; // 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], @@ -27,14 +27,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, @@ -104,7 +104,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 { @@ -121,23 +121,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); }); }); @@ -152,7 +152,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); @@ -161,7 +161,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); @@ -193,9 +193,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 59248dd6390dd..bd4ffcb7b5885 100644 --- a/src/ui/public/vislib/__tests__/visualizations/line_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/line_chart.js @@ -15,7 +15,7 @@ import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var dataTypes = [ +let dataTypes = [ ['series pos', seriesPos], ['series pos neg', seriesPosNeg], ['series neg', seriesNeg], @@ -26,8 +26,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; @@ -35,7 +35,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, @@ -133,7 +133,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); @@ -142,7 +142,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); @@ -174,8 +174,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 741b3ec6260bd..26edaecadc6fa 100644 --- a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js @@ -11,39 +11,39 @@ import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_s import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import AggResponseHierarchicalBuildHierarchicalDataProvider from 'ui/agg_response/hierarchical/build_hierarchical_data'; -var rowAgg = [ +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, @@ -53,13 +53,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, @@ -83,13 +83,13 @@ describe('No global chart settings', function () { indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); buildHierarchicalData = Private(AggResponseHierarchicalBuildHierarchicalDataProvider); - 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 }); @@ -120,19 +120,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: [{}] } } @@ -157,7 +157,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 @@ -177,8 +177,8 @@ aggArray.forEach(function (dataAgg, i) { indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); buildHierarchicalData = Private(AggResponseHierarchicalBuildHierarchicalDataProvider); - 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 cbad9bfc54c59..b74f779c1510b 100644 --- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js +++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js @@ -10,14 +10,14 @@ import $ from 'jquery'; import VislibVisualizationsMapProvider from 'ui/vislib/visualizations/_map'; // // 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', @@ -25,10 +25,10 @@ import VislibVisualizationsMapProvider from 'ui/vislib/visualizations/_map'; // ]; 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) { @@ -57,7 +57,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(); @@ -82,8 +82,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'); @@ -122,21 +122,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); @@ -157,14 +157,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(); @@ -182,20 +182,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 5e9c7b5609b29..04ed6fdbea14d 100644 --- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js +++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/markers.js @@ -12,9 +12,9 @@ import VislibVisualizationsMarkerTypesShadedCirclesProvider from 'ui/vislib/visu import VislibVisualizationsMarkerTypesScaledCirclesProvider from 'ui/vislib/visualizations/marker_types/scaled_circles'; import VislibVisualizationsMarkerTypesHeatmapProvider from 'ui/vislib/visualizations/marker_types/heatmap'; // 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; @@ -29,7 +29,7 @@ function getBounds() { return L.latLngBounds(bounds.southWest, bounds.northEast); } -var mockMap = { +let mockMap = { addLayer: _.noop, closePopup: _.noop, getBounds: getBounds, @@ -76,8 +76,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); }); @@ -85,8 +85,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); }); @@ -94,8 +94,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); @@ -105,18 +105,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); }); }); @@ -124,19 +124,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); }); }); @@ -144,9 +144,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; }); @@ -186,12 +186,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); @@ -202,14 +202,14 @@ describe('Marker Tests', function () { describe('Shaded Circles', function () { beforeEach(ngMock.module('MarkerFactory')); beforeEach(ngMock.inject(function (Private) { - var MarkerClass = Private(VislibVisualizationsMarkerTypesShadedCirclesProvider); + let MarkerClass = Private(VislibVisualizationsMarkerTypesShadedCirclesProvider); 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); @@ -224,34 +224,34 @@ describe('Marker Tests', function () { beforeEach(ngMock.inject(function (Private) { zoom = _.random(1, 18); sinon.stub(mockMap, 'getZoom', _.constant(zoom)); - var MarkerClass = Private(VislibVisualizationsMarkerTypesScaledCirclesProvider); + let MarkerClass = Private(VislibVisualizationsMarkerTypesScaledCirclesProvider); 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); @@ -269,7 +269,7 @@ describe('Marker Tests', function () { describe('Heatmaps', function () { beforeEach(ngMock.module('MarkerFactory')); beforeEach(ngMock.inject(function (Private) { - var MarkerClass = Private(VislibVisualizationsMarkerTypesHeatmapProvider); + let MarkerClass = Private(VislibVisualizationsMarkerTypesHeatmapProvider); markerLayer = createMarker(MarkerClass); })); @@ -281,7 +281,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); @@ -289,11 +289,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); }); }); @@ -302,11 +302,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); }); }); @@ -315,18 +315,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); }); }); @@ -335,9 +335,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); }); }); @@ -345,15 +345,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 6f75ac8e05f5a..d1f4c3235fd08 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 @@ -8,7 +8,7 @@ import geoJsonData from 'fixtures/vislib/mock_data/geohash/_geo_json'; import MockMap from 'fixtures/tilemap_map'; import $ from 'jquery'; import VislibVisualizationsTileMapProvider from 'ui/vislib/visualizations/tile_map'; -var mockChartEl = $('
'); +let mockChartEl = $('
'); let TileMap; let extentsStub; @@ -18,7 +18,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; } @@ -52,7 +52,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); }); @@ -73,14 +73,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: {}, @@ -92,17 +92,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); @@ -110,8 +110,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 08fe6475b1ded..4f13b37dfbadd 100644 --- a/src/ui/public/vislib/__tests__/visualizations/time_marker.js +++ b/src/ui/public/vislib/__tests__/visualizations/time_marker.js @@ -10,13 +10,13 @@ import $ from 'jquery'; import VislibVisualizationsTimeMarkerProvider from 'ui/vislib/visualizations/time_marker'; 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, @@ -25,14 +25,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/components/tooltip/__tests__/positioning.js b/src/ui/public/vislib/components/tooltip/__tests__/positioning.js index cce03b6df453c..9edb8b45415d8 100644 --- a/src/ui/public/vislib/components/tooltip/__tests__/positioning.js +++ b/src/ui/public/vislib/components/tooltip/__tests__/positioning.js @@ -6,17 +6,17 @@ import posTT from '../position_tooltip'; describe('Tooltip Positioning', function () { - var positions = ['north', 'south', 'east', 'west']; - var bounds = ['top', 'left', 'bottom', 'right']; + 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__/_build_chart_data.js b/src/ui/public/vislib_vis_type/__tests__/_build_chart_data.js index 2df792b2da08d..44628c2b39de5 100644 --- a/src/ui/public/vislib_vis_type/__tests__/_build_chart_data.js +++ b/src/ui/public/vislib_vis_type/__tests__/_build_chart_data.js @@ -23,14 +23,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); @@ -40,14 +40,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); @@ -55,8 +55,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: { @@ -64,20 +64,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: { @@ -86,7 +86,7 @@ describe('renderbot#buildChartData', function () { } }; - var tabify = sinon.stub(aggResponse, 'tabify').returns({ + let tabify = sinon.stub(aggResponse, 'tabify').returns({ tables: [ { aggConfig: { params: { row: true } }, @@ -117,7 +117,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/vislib_vis_type/__tests__/_vislib_renderbot.js b/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js index 7f11ef76313c3..b70e61001a9e4 100644 --- a/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js +++ b/src/ui/public/vislib_vis_type/__tests__/_vislib_renderbot.js @@ -16,7 +16,7 @@ describe('renderbot', function exportWrapper() { let VislibRenderbot; let persistedState; let normalizeChartData; - var mockVisType = { + let mockVisType = { name: 'test' }; @@ -36,8 +36,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; @@ -56,7 +56,7 @@ describe('renderbot', function exportWrapper() { }); describe('_createVis', function () { - var vis = { + let vis = { type: mockVisType, listeners: { 'test': _.noop, @@ -64,7 +64,7 @@ describe('renderbot', function exportWrapper() { 'test3': _.noop } }; - var $el = $('
testing
'); + let $el = $('
testing
'); let listenerSpy; let renderbot; @@ -82,15 +82,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; @@ -119,20 +119,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); @@ -142,7 +142,7 @@ describe('renderbot', function exportWrapper() { }); describe('destroy', function () { - var vis = { + let vis = { type: mockVisType, listeners: { 'test': _.noop, @@ -150,7 +150,7 @@ describe('renderbot', function exportWrapper() { 'test3': _.noop } }; - var $el = $('
testing
'); + let $el = $('
testing
'); let listenerSpy; let renderbot; @@ -167,7 +167,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/watch_multi/__tests__/watch_multi.js b/src/ui/public/watch_multi/__tests__/watch_multi.js index fe39adb2e428a..e87d124c93a89 100644 --- a/src/ui/public/watch_multi/__tests__/watch_multi.js +++ b/src/ui/public/watch_multi/__tests__/watch_multi.js @@ -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 () {