ES6ify /gr-change-table-editor/*
Bug: Issue 6179 Change-Id: I5c04b15507e7dd253e2daea23e367a552f505ed2
This commit is contained in:
@@ -28,13 +28,13 @@
|
|||||||
Gerrit.ChangeTableBehavior,
|
Gerrit.ChangeTableBehavior,
|
||||||
],
|
],
|
||||||
|
|
||||||
_getButtonText: function(isShown) {
|
_getButtonText(isShown) {
|
||||||
return isShown ? 'Hide' : 'Show';
|
return isShown ? 'Hide' : 'Show';
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateDisplayedColumns: function(displayedColumns, name, checked) {
|
_updateDisplayedColumns(displayedColumns, name, checked) {
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
return displayedColumns.filter(function(column) {
|
return displayedColumns.filter(column => {
|
||||||
return name.toLowerCase() !== column.toLowerCase();
|
return name.toLowerCase() !== column.toLowerCase();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
/**
|
/**
|
||||||
* Handles tap on either the checkbox itself or the surrounding table cell.
|
* Handles tap on either the checkbox itself or the surrounding table cell.
|
||||||
*/
|
*/
|
||||||
_handleTargetTap: function(e) {
|
_handleTargetTap(e) {
|
||||||
var checkbox = Polymer.dom(e.target).querySelector('input');
|
let checkbox = Polymer.dom(e.target).querySelector('input');
|
||||||
if (checkbox) {
|
if (checkbox) {
|
||||||
checkbox.click();
|
checkbox.click();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -33,12 +33,12 @@ limitations under the License.
|
|||||||
</test-fixture>
|
</test-fixture>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
suite('gr-change-table-editor tests', function() {
|
suite('gr-change-table-editor tests', () => {
|
||||||
var element;
|
let element;
|
||||||
var columns;
|
let columns;
|
||||||
var sandbox;
|
let sandbox;
|
||||||
|
|
||||||
setup(function() {
|
setup(() => {
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
|
|
||||||
@@ -55,25 +55,25 @@ limitations under the License.
|
|||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(function() {
|
teardown(() => {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders', function() {
|
test('renders', () => {
|
||||||
var rows = element.$$('tbody').querySelectorAll('tr');
|
const rows = element.$$('tbody').querySelectorAll('tr');
|
||||||
var tds;
|
let tds;
|
||||||
|
|
||||||
assert.equal(rows.length, element.columnNames.length);
|
assert.equal(rows.length, element.columnNames.length);
|
||||||
for (var i = 0; i < columns.length; i++) {
|
for (let i = 0; i < columns.length; i++) {
|
||||||
tds = rows[i].querySelectorAll('td');
|
tds = rows[i].querySelectorAll('td');
|
||||||
assert.equal(tds[0].textContent, columns[i]);
|
assert.equal(tds[0].textContent, columns[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hide item', function() {
|
test('hide item', () => {
|
||||||
var checkbox = element.$$('table input');
|
const checkbox = element.$$('table input');
|
||||||
var isChecked = checkbox.checked;
|
const isChecked = checkbox.checked;
|
||||||
var displayedLength = element.displayedColumns.length;
|
const displayedLength = element.displayedColumns.length;
|
||||||
assert.isTrue(isChecked);
|
assert.isTrue(isChecked);
|
||||||
|
|
||||||
MockInteractions.tap(checkbox);
|
MockInteractions.tap(checkbox);
|
||||||
@@ -83,7 +83,7 @@ limitations under the License.
|
|||||||
displayedLength - 1);
|
displayedLength - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('show item', function() {
|
test('show item', () => {
|
||||||
element.set('displayedColumns', [
|
element.set('displayedColumns', [
|
||||||
'Status',
|
'Status',
|
||||||
'Owner',
|
'Owner',
|
||||||
@@ -92,9 +92,9 @@ limitations under the License.
|
|||||||
'Updated',
|
'Updated',
|
||||||
]);
|
]);
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
var checkbox = element.$$('table input');
|
const checkbox = element.$$('table input');
|
||||||
var isChecked = checkbox.checked;
|
const isChecked = checkbox.checked;
|
||||||
var displayedLength = element.displayedColumns.length;
|
const displayedLength = element.displayedColumns.length;
|
||||||
assert.isFalse(isChecked);
|
assert.isFalse(isChecked);
|
||||||
assert.equal(element.$$('table').style.display, '');
|
assert.equal(element.$$('table').style.display, '');
|
||||||
|
|
||||||
@@ -105,11 +105,11 @@ limitations under the License.
|
|||||||
displayedLength + 1);
|
displayedLength + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_handleTargetTap', function() {
|
test('_handleTargetTap', () => {
|
||||||
var checkbox = element.$$('table input');
|
const checkbox = element.$$('table input');
|
||||||
var originalDisplayedColumns = element.displayedColumns;
|
let originalDisplayedColumns = element.displayedColumns;
|
||||||
var td = element.$$('table .checkboxContainer');
|
const td = element.$$('table .checkboxContainer');
|
||||||
var displayedColumnStub =
|
const displayedColumnStub =
|
||||||
sandbox.stub(element, '_updateDisplayedColumns');
|
sandbox.stub(element, '_updateDisplayedColumns');
|
||||||
|
|
||||||
MockInteractions.tap(checkbox);
|
MockInteractions.tap(checkbox);
|
||||||
@@ -126,9 +126,9 @@ limitations under the License.
|
|||||||
checkbox.checked));
|
checkbox.checked));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_updateDisplayedColumns', function() {
|
test('_updateDisplayedColumns', () => {
|
||||||
var name = 'Subject';
|
let name = 'Subject';
|
||||||
var checked = false;
|
let checked = false;
|
||||||
assert.deepEqual(element._updateDisplayedColumns(columns, name, checked),
|
assert.deepEqual(element._updateDisplayedColumns(columns, name, checked),
|
||||||
[
|
[
|
||||||
'Status',
|
'Status',
|
||||||
|
Reference in New Issue
Block a user