Commit 729822c0 authored by dpapad's avatar dpapad Committed by Commit Bot

Print Preview WebUI tests: Use const instead of let where possible.

CL produced with ESLint --fix and clang-format.

This is in preparation for turning on the 'prefer-const' ESLint rule for that
folder.

Bug: 72003
Change-Id: I94a6f0ae63da907e552c659325de600b6b3733c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885553
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710372}
parent 6d673ee9
...@@ -22,10 +22,10 @@ cr.define('advanced_dialog_test', function() { ...@@ -22,10 +22,10 @@ cr.define('advanced_dialog_test', function() {
let destination = null; let destination = null;
/** @type {string} */ /** @type {string} */
let printerId = 'FooDevice'; const printerId = 'FooDevice';
/** @type {string} */ /** @type {string} */
let printerName = 'FooName'; const printerName = 'FooName';
/** @override */ /** @override */
setup(function() { setup(function() {
......
...@@ -89,7 +89,7 @@ cr.define('custom_margins_test', function() { ...@@ -89,7 +89,7 @@ cr.define('custom_margins_test', function() {
// Wait for the control elements to be created before updating the state. // Wait for the control elements to be created before updating the state.
container.measurementSystem = measurementSystem; container.measurementSystem = measurementSystem;
document.body.appendChild(container); document.body.appendChild(container);
let controlsAdded = test_util.eventToPromise('dom-change', container); const controlsAdded = test_util.eventToPromise('dom-change', container);
return controlsAdded.then(() => { return controlsAdded.then(() => {
// 8.5 x 11, in pixels // 8.5 x 11, in pixels
const controls = getControls(); const controls = getControls();
...@@ -275,7 +275,7 @@ cr.define('custom_margins_test', function() { ...@@ -275,7 +275,7 @@ cr.define('custom_margins_test', function() {
assertEquals('0', window.getComputedStyle(control).opacity); assertEquals('0', window.getComputedStyle(control).opacity);
}); });
let onTransitionEnd = getAllTransitions(controls); const onTransitionEnd = getAllTransitions(controls);
// Controls become visible when margin type CUSTOM is selected. // Controls become visible when margin type CUSTOM is selected.
model.set( model.set(
'settings.margins.value', print_preview.MarginsType.CUSTOM); 'settings.margins.value', print_preview.MarginsType.CUSTOM);
...@@ -309,7 +309,7 @@ cr.define('custom_margins_test', function() { ...@@ -309,7 +309,7 @@ cr.define('custom_margins_test', function() {
assertEquals(defaultMarginPts, control.getPositionInPts()); assertEquals(defaultMarginPts, control.getPositionInPts());
}); });
let onTransitionEnd = getAllTransitions(controls); const onTransitionEnd = getAllTransitions(controls);
// Disappears when preview is loading or an error message is shown. // Disappears when preview is loading or an error message is shown.
// Check that all the controls also disappear. // Check that all the controls also disappear.
......
...@@ -28,7 +28,7 @@ cr.define('destination_dialog_test', function() { ...@@ -28,7 +28,7 @@ cr.define('destination_dialog_test', function() {
let destinations = []; let destinations = [];
/** @type {!Array<!print_preview.LocalDestinationInfo>} */ /** @type {!Array<!print_preview.LocalDestinationInfo>} */
let localDestinations = []; const localDestinations = [];
/** @type {!Array<!print_preview.RecentDestination>} */ /** @type {!Array<!print_preview.RecentDestination>} */
let recentDestinations = []; let recentDestinations = [];
......
...@@ -53,7 +53,7 @@ cr.define('destination_item_test', function() { ...@@ -53,7 +53,7 @@ cr.define('destination_item_test', function() {
// the destination is stale. // the destination is stale.
test(assert(TestNames.Offline), function() { test(assert(TestNames.Offline), function() {
const now = new Date(); const now = new Date();
let twoMonthsAgo = new Date(now.getTime()); const twoMonthsAgo = new Date(now.getTime());
let month = twoMonthsAgo.getMonth() - 2; let month = twoMonthsAgo.getMonth() - 2;
if (month < 0) { if (month < 0) {
month = month + 12; month = month + 12;
......
...@@ -54,7 +54,7 @@ cr.define('destination_settings_test', function() { ...@@ -54,7 +54,7 @@ cr.define('destination_settings_test', function() {
// Stub out native layer and cloud print interface. // Stub out native layer and cloud print interface.
nativeLayer = new print_preview.NativeLayerStub(); nativeLayer = new print_preview.NativeLayerStub();
print_preview.NativeLayer.setInstance(nativeLayer); print_preview.NativeLayer.setInstance(nativeLayer);
let localDestinations = []; const localDestinations = [];
destinations = print_preview_test_utils.getDestinations( destinations = print_preview_test_utils.getDestinations(
nativeLayer, localDestinations); nativeLayer, localDestinations);
nativeLayer.setLocalDestinations(localDestinations); nativeLayer.setLocalDestinations(localDestinations);
...@@ -197,7 +197,7 @@ cr.define('destination_settings_test', function() { ...@@ -197,7 +197,7 @@ cr.define('destination_settings_test', function() {
* destinations in the dropdown. * destinations in the dropdown.
*/ */
function assertDropdownItems(expectedDestinations) { function assertDropdownItems(expectedDestinations) {
let options = const options =
destinationSettings.$.destinationSelect.shadowRoot.querySelectorAll( destinationSettings.$.destinationSelect.shadowRoot.querySelectorAll(
'option:not([hidden])'); 'option:not([hidden])');
assertEquals(expectedDestinations.length + 1, options.length); assertEquals(expectedDestinations.length + 1, options.length);
......
...@@ -245,7 +245,7 @@ cr.define('model_settings_availability_test', function() { ...@@ -245,7 +245,7 @@ cr.define('model_settings_availability_test', function() {
assertTrue(model.settings.mediaSize.available); assertTrue(model.settings.mediaSize.available);
// Remove capability. // Remove capability.
let capabilities = const capabilities =
print_preview_test_utils.getCddTemplate(model.destination.id) print_preview_test_utils.getCddTemplate(model.destination.id)
.capabilities; .capabilities;
delete capabilities.printer.media_size; delete capabilities.printer.media_size;
......
...@@ -90,7 +90,8 @@ cr.define('model_test', function() { ...@@ -90,7 +90,8 @@ cr.define('model_test', function() {
* reset to its default value. * reset to its default value.
*/ */
const testStickySetting = function(setting, field) { const testStickySetting = function(setting, field) {
let promise = test_util.eventToPromise('sticky-setting-changed', model); const promise =
test_util.eventToPromise('sticky-setting-changed', model);
model.setSetting(setting, stickySettingsChange[field]); model.setSetting(setting, stickySettingsChange[field]);
settingsSet.push(field); settingsSet.push(field);
return promise.then( return promise.then(
...@@ -99,18 +100,19 @@ cr.define('model_test', function() { ...@@ -99,18 +100,19 @@ cr.define('model_test', function() {
* @return {!Promise} Promise that resolves when setting is reset. * @return {!Promise} Promise that resolves when setting is reset.
*/ */
function(e) { function(e) {
let settings = JSON.parse(e.detail); const settings = JSON.parse(e.detail);
Object.keys(stickySettingsDefault).forEach(settingName => { Object.keys(stickySettingsDefault).forEach(settingName => {
let set = settingsSet.includes(settingName); const set = settingsSet.includes(settingName);
assertEquals(set, settings[settingName] !== undefined); assertEquals(set, settings[settingName] !== undefined);
if (set) { if (set) {
let toCompare = settingName == field ? stickySettingsChange : const toCompare = settingName == field ?
stickySettingsDefault; stickySettingsChange :
stickySettingsDefault;
assertDeepEquals( assertDeepEquals(
toCompare[settingName], settings[settingName]); toCompare[settingName], settings[settingName]);
} }
}); });
let restorePromise = const restorePromise =
test_util.eventToPromise('sticky-setting-changed', model); test_util.eventToPromise('sticky-setting-changed', model);
model.setSetting(setting, stickySettingsDefault[field]); model.setSetting(setting, stickySettingsDefault[field]);
return restorePromise; return restorePromise;
......
...@@ -33,7 +33,7 @@ cr.define('print_button_test', function() { ...@@ -33,7 +33,7 @@ cr.define('print_button_test', function() {
print_preview.NativeLayer.setInstance(nativeLayer); print_preview.NativeLayer.setInstance(nativeLayer);
PolymerTest.clearBody(); PolymerTest.clearBody();
nativeLayer.setInitialSettings(initialSettings); nativeLayer.setInitialSettings(initialSettings);
let localDestinationInfos = [ const localDestinationInfos = [
{printerName: 'FooName', deviceName: 'FooDevice'}, {printerName: 'FooName', deviceName: 'FooDevice'},
]; ];
nativeLayer.setLocalDestinations(localDestinationInfos); nativeLayer.setLocalDestinations(localDestinationInfos);
......
...@@ -257,7 +257,7 @@ cr.define('print_preview_test_utils', function() { ...@@ -257,7 +257,7 @@ cr.define('print_preview_test_utils', function() {
* @return {!Array<!print_preview.Destination>} * @return {!Array<!print_preview.Destination>}
*/ */
function getDestinations(nativeLayer, localDestinations) { function getDestinations(nativeLayer, localDestinations) {
let destinations = []; const destinations = [];
const origin = cr.isChromeOS ? print_preview.DestinationOrigin.CROS : const origin = cr.isChromeOS ? print_preview.DestinationOrigin.CROS :
print_preview.DestinationOrigin.LOCAL; print_preview.DestinationOrigin.LOCAL;
// Five destinations. FooDevice is the system default. // Five destinations. FooDevice is the system default.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment