Skip to content

Commit 721eb2d

Browse files
committed
Merge pull request #6865 from epixa/uiletconst
[internal] Replace var assignments with let in ui tests
2 parents ea386ef + 863228d commit 721eb2d

File tree

204 files changed

+2016
-2016
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+2016
-2016
lines changed

src/ui/__tests__/ui_exports.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as kbnTestServer from '../../../test/utils/kbn_server';
77
describe('UiExports', function () {
88
describe('#find()', function () {
99
it('finds exports based on the passed export names', function () {
10-
var uiExports = new UiExports({});
10+
let uiExports = new UiExports({});
1111
uiExports.aliases.foo = ['a', 'b', 'c'];
1212
uiExports.aliases.bar = ['d', 'e', 'f'];
1313

@@ -17,7 +17,7 @@ describe('UiExports', function () {
1717
});
1818

1919
it('allows query types that match nothing', function () {
20-
var uiExports = new UiExports({});
20+
let uiExports = new UiExports({});
2121
uiExports.aliases.foo = ['a', 'b', 'c'];
2222

2323
expect(uiExports.find(['foo'])).to.eql(['a', 'b', 'c']);

src/ui/public/agg_response/geo_json/__tests__/geo_json.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ describe('GeoJson Agg Response Converter', function () {
1717

1818
beforeEach(ngMock.module('kibana'));
1919
beforeEach(ngMock.inject(function (Private) {
20-
var Vis = Private(VisProvider);
21-
var indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
20+
let Vis = Private(VisProvider);
21+
let indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
2222

2323
esResponse = Private(FixturesAggRespGeohashGridProvider);
2424
tabify = Private(AggResponseTabifyTabifyProvider);
@@ -60,8 +60,8 @@ describe('GeoJson Agg Response Converter', function () {
6060

6161
describe('with table ' + JSON.stringify(tableOpts), function () {
6262
it('outputs a chart', function () {
63-
var table = makeTable();
64-
var chart = makeSingleChart(table);
63+
let table = makeTable();
64+
let chart = makeSingleChart(table);
6565
expect(chart).to.only.have.keys(
6666
'title',
6767
'tooltipFormatter',
@@ -78,18 +78,18 @@ describe('GeoJson Agg Response Converter', function () {
7878
});
7979

8080
it('outputs geohash points as features in a feature collection', function () {
81-
var table = makeTable();
82-
var chart = makeSingleChart(table);
83-
var geoJson = chart.geoJson;
81+
let table = makeTable();
82+
let chart = makeSingleChart(table);
83+
let geoJson = chart.geoJson;
8484

8585
expect(geoJson.type).to.be('FeatureCollection');
8686
expect(geoJson.features).to.be.an('array');
8787
expect(geoJson.features).to.have.length(table.rows.length);
8888
});
8989

9090
it('exports a bunch of properties about the geo hash grid', function () {
91-
var geoJson = makeGeoJson();
92-
var props = geoJson.properties;
91+
let geoJson = makeGeoJson();
92+
let props = geoJson.properties;
9393

9494
// props
9595
expect(props).to.be.an('object');
@@ -122,7 +122,7 @@ describe('GeoJson Agg Response Converter', function () {
122122

123123
it('should be geoJson format', function () {
124124
table.rows.forEach(function (row, i) {
125-
var feature = chart.geoJson.features[i];
125+
let feature = chart.geoJson.features[i];
126126
expect(feature).to.have.property('geometry');
127127
expect(feature.geometry).to.be.an('object');
128128
expect(feature).to.have.property('properties');
@@ -132,7 +132,7 @@ describe('GeoJson Agg Response Converter', function () {
132132

133133
it('should have valid geometry data', function () {
134134
table.rows.forEach(function (row, i) {
135-
var geometry = chart.geoJson.features[i].geometry;
135+
let geometry = chart.geoJson.features[i].geometry;
136136
expect(geometry.type).to.be('Point');
137137
expect(geometry).to.have.property('coordinates');
138138
expect(geometry.coordinates).to.be.an('array');
@@ -144,8 +144,8 @@ describe('GeoJson Agg Response Converter', function () {
144144

145145
it('should have value properties data', function () {
146146
table.rows.forEach(function (row, i) {
147-
var props = chart.geoJson.features[i].properties;
148-
var keys = ['value', 'geohash', 'aggConfigResult', 'rectangle', 'center'];
147+
let props = chart.geoJson.features[i].properties;
148+
let keys = ['value', 'geohash', 'aggConfigResult', 'rectangle', 'center'];
149149
expect(props).to.be.an('object');
150150
expect(props).to.only.have.keys(keys);
151151
expect(props.geohash).to.be.a('string');
@@ -155,15 +155,15 @@ describe('GeoJson Agg Response Converter', function () {
155155

156156
it('should use latLng in properties and lngLat in geometry', function () {
157157
table.rows.forEach(function (row, i) {
158-
var geometry = chart.geoJson.features[i].geometry;
159-
var props = chart.geoJson.features[i].properties;
158+
let geometry = chart.geoJson.features[i].geometry;
159+
let props = chart.geoJson.features[i].properties;
160160
expect(props.center).to.eql(geometry.coordinates.slice(0).reverse());
161161
});
162162
});
163163

164164
it('should handle both AggConfig and non-AggConfig results', function () {
165165
table.rows.forEach(function (row, i) {
166-
var props = chart.geoJson.features[i].properties;
166+
let props = chart.geoJson.features[i].properties;
167167
if (tableOpts.asAggConfigResults) {
168168
expect(props.aggConfigResult).to.be(row[metricColI]);
169169
expect(props.value).to.be(row[metricColI].value);

src/ui/public/agg_response/hierarchical/__tests__/build_hierarchical_data.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('buildHierarchicalData', function () {
3535
let results;
3636

3737
beforeEach(function () {
38-
var id = 1;
38+
let id = 1;
3939
vis = new Vis(indexPattern, {
4040
type: 'pie',
4141
aggs: [
@@ -48,7 +48,7 @@ describe('buildHierarchicalData', function () {
4848
});
4949

5050
it('should set the slices with one child to a consistent label', function () {
51-
var checkLabel = 'Count';
51+
let checkLabel = 'Count';
5252
expect(results).to.have.property('slices');
5353
expect(results.slices).to.have.property('children');
5454
expect(results.slices.children).to.have.length(1);
@@ -67,8 +67,8 @@ describe('buildHierarchicalData', function () {
6767
describe('rows and columns', function () {
6868

6969
it('should set the rows', function () {
70-
var id = 1;
71-
var vis = new Vis(indexPattern, {
70+
let id = 1;
71+
let vis = new Vis(indexPattern, {
7272
type: 'pie',
7373
aggs: [
7474
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
@@ -79,13 +79,13 @@ describe('buildHierarchicalData', function () {
7979
});
8080
// We need to set the aggs to a known value.
8181
_.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; });
82-
var results = buildHierarchicalData(vis, fixtures.threeTermBuckets);
82+
let results = buildHierarchicalData(vis, fixtures.threeTermBuckets);
8383
expect(results).to.have.property('rows');
8484
});
8585

8686
it('should set the columns', function () {
87-
var id = 1;
88-
var vis = new Vis(indexPattern, {
87+
let id = 1;
88+
let vis = new Vis(indexPattern, {
8989
type: 'pie',
9090
aggs: [
9191
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
@@ -96,7 +96,7 @@ describe('buildHierarchicalData', function () {
9696
});
9797
// We need to set the aggs to a known value.
9898
_.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; });
99-
var results = buildHierarchicalData(vis, fixtures.threeTermBuckets);
99+
let results = buildHierarchicalData(vis, fixtures.threeTermBuckets);
100100
expect(results).to.have.property('columns');
101101
});
102102

@@ -107,7 +107,7 @@ describe('buildHierarchicalData', function () {
107107
let results;
108108

109109
beforeEach(function () {
110-
var id = 1;
110+
let id = 1;
111111
vis = new Vis(indexPattern, {
112112
type: 'pie',
113113
aggs: [
@@ -149,7 +149,7 @@ describe('buildHierarchicalData', function () {
149149
let results;
150150

151151
beforeEach(function () {
152-
var id = 1;
152+
let id = 1;
153153
vis = new Vis(indexPattern, {
154154
type: 'pie',
155155
aggs: [
@@ -181,7 +181,7 @@ describe('buildHierarchicalData', function () {
181181
let results;
182182

183183
beforeEach(function () {
184-
var id = 1;
184+
let id = 1;
185185
vis = new Vis(indexPattern, {
186186
type: 'pie',
187187
aggs: [
@@ -222,7 +222,7 @@ describe('buildHierarchicalData', function () {
222222
let results;
223223

224224
beforeEach(function () {
225-
var id = 1;
225+
let id = 1;
226226
vis = new Vis(indexPattern, {
227227
type: 'pie',
228228
aggs: [
@@ -258,7 +258,7 @@ describe('buildHierarchicalData', function () {
258258
let results;
259259

260260
beforeEach(function () {
261-
var id = 1;
261+
let id = 1;
262262
vis = new Vis(indexPattern, {
263263
type: 'pie',
264264
aggs: [
@@ -281,7 +281,7 @@ describe('buildHierarchicalData', function () {
281281
});
282282

283283
it('should set the hits attribute for the results', function () {
284-
var errCall = Notifier.prototype.error.getCall(0);
284+
let errCall = Notifier.prototype.error.getCall(0);
285285
expect(errCall).to.be.ok();
286286
expect(errCall.args[0]).to.contain('not supported');
287287

src/ui/public/agg_response/hierarchical/__tests__/collect_branch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import collectBranch from 'ui/agg_response/hierarchical/_collect_branch';
44
import expect from 'expect.js';
55
describe('collectBranch()', function () {
66
let results;
7-
var convert = function (name) {
7+
let convert = function (name) {
88
return 'converted:' + name;
99
};
1010

src/ui/public/agg_response/hierarchical/__tests__/create_raw_data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('buildHierarchicalData()', function () {
2727
}));
2828

2929
beforeEach(function () {
30-
var id = 1;
30+
let id = 1;
3131
vis = new Vis(indexPattern, {
3232
type: 'pie',
3333
aggs: [
@@ -37,7 +37,7 @@ describe('buildHierarchicalData()', function () {
3737
{ type: 'terms', schema: 'segment', params: { field: 'geo.src' }}
3838
]
3939
});
40-
var buckets = arrayToLinkedList(vis.aggs.bySchemaGroup.buckets);
40+
let buckets = arrayToLinkedList(vis.aggs.bySchemaGroup.buckets);
4141
// We need to set the aggs to a known value.
4242
_.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; });
4343
results = createRawData(vis, fixtures.threeTermBuckets);
@@ -48,7 +48,7 @@ describe('buildHierarchicalData()', function () {
4848
expect(results.columns).to.have.length(6);
4949
_.each(results.columns, function (column) {
5050
expect(column).to.have.property('aggConfig');
51-
var agg = column.aggConfig;
51+
let agg = column.aggConfig;
5252
expect(column).to.have.property('categoryName', agg.schema.name);
5353
expect(column).to.have.property('id', agg.id);
5454
expect(column).to.have.property('aggType', agg.type);

src/ui/public/agg_response/hierarchical/__tests__/extract_buckets.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ describe('buildHierarchicalData()', function () {
77

88
it('should normalize a bucket object into an array', function () {
99

10-
var bucket = {
10+
let bucket = {
1111
buckets: {
1212
foo: { doc_count: 1 },
1313
bar: { doc_count: 2 }
1414
}
1515
};
1616

17-
var buckets = extractBuckets(bucket);
17+
let buckets = extractBuckets(bucket);
1818
expect(buckets).to.be.an(Array);
1919
expect(buckets).to.have.length(2);
2020
expect(buckets[0]).to.have.property('key', 'foo');
@@ -24,19 +24,19 @@ describe('buildHierarchicalData()', function () {
2424
});
2525

2626
it('should return an empty array for undefined buckets', function () {
27-
var buckets = extractBuckets();
27+
let buckets = extractBuckets();
2828
expect(buckets).to.be.an(Array);
2929
expect(buckets).to.have.length(0);
3030
});
3131

3232
it('should return the bucket array', function () {
33-
var bucket = {
33+
let bucket = {
3434
buckets: [
3535
{ key: 'foo', doc_count: 1 },
3636
{ key: 'bar', doc_count: 2 }
3737
]
3838
};
39-
var buckets = extractBuckets(bucket);
39+
let buckets = extractBuckets(bucket);
4040
expect(buckets).to.be.an(Array);
4141
expect(buckets).to.be(bucket.buckets);
4242
});

src/ui/public/agg_response/hierarchical/__tests__/transform_aggregation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ describe('buildHierarchicalData()', function () {
4242
});
4343

4444
it('relies on metricAgg#getValue() for the size of the children', function () {
45-
var aggData = {
45+
let aggData = {
4646
buckets: [
4747
{ key: 'foo' },
4848
{ key: 'bar' }
4949
]
5050
};
5151

52-
var football = {};
52+
let football = {};
5353
fixture.metric.getValue = _.constant(football);
5454

55-
var children = transform(fixture.agg, fixture.metric, aggData);
55+
let children = transform(fixture.agg, fixture.metric, aggData);
5656
expect(children).to.be.an(Array);
5757
expect(children).to.have.length(2);
5858
expect(children[0]).to.have.property('size', football);
5959
expect(children[1]).to.have.property('size', football);
6060
});
6161

6262
it('should create two levels of metrics', function () {
63-
var children = transform(fixture.agg, fixture.metric, fixture.aggData);
63+
let children = transform(fixture.agg, fixture.metric, fixture.aggData);
6464
fixture.metric.getValue = function (b) { return b.doc_count; };
6565

6666
expect(children).to.be.an(Array);

src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ describe('addToSiri', function () {
1010
}));
1111

1212
it('creates a new series the first time it sees an id', function () {
13-
var series = new Map();
14-
var point = {};
15-
var id = 'id';
13+
let series = new Map();
14+
let point = {};
15+
let id = 'id';
1616
addToSiri(series, point, id);
1717

1818
expect(series.has(id)).to.be(true);
@@ -23,13 +23,13 @@ describe('addToSiri', function () {
2323
});
2424

2525
it('adds points to existing series if id has been seen', function () {
26-
var series = new Map();
27-
var id = 'id';
26+
let series = new Map();
27+
let id = 'id';
2828

29-
var point = {};
29+
let point = {};
3030
addToSiri(series, point, id);
3131

32-
var point2 = {};
32+
let point2 = {};
3333
addToSiri(series, point2, id);
3434

3535
expect(series.has(id)).to.be(true);
@@ -41,10 +41,10 @@ describe('addToSiri', function () {
4141
});
4242

4343
it('allows overriding the series label', function () {
44-
var series = new Map();
45-
var id = 'id';
46-
var label = 'label';
47-
var point = {};
44+
let series = new Map();
45+
let id = 'id';
46+
let label = 'label';
47+
let point = {};
4848
addToSiri(series, point, id, label);
4949

5050
expect(series.has(id)).to.be(true);

src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('makeFakeXAspect', function () {
2222
}));
2323

2424
it('creates an object that looks like an aspect', function () {
25-
var vis = new Vis(indexPattern, { type: 'histogram' });
26-
var aspect = makeFakeXAspect(vis);
25+
let vis = new Vis(indexPattern, { type: 'histogram' });
26+
let aspect = makeFakeXAspect(vis);
2727

2828
expect(aspect)
2929
.to.have.property('i', -1)

0 commit comments

Comments
 (0)