mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
chore: apply prefer-const rule fixes in mocha tests (#5682)
This commit is contained in:
@@ -45,7 +45,7 @@ suite('WidgetDiv', function() {
|
||||
anchorBBox, rtl, expectedX, expectedY, expectedHeight) {
|
||||
Blockly.WidgetDiv.positionWithAnchor(
|
||||
this.viewportBBox, anchorBBox, this.widgetSize, rtl);
|
||||
let style = Blockly.WidgetDiv.getDiv().style;
|
||||
const style = Blockly.WidgetDiv.getDiv().style;
|
||||
chai.assert.equal(style.left, expectedX + 'px', 'Left');
|
||||
chai.assert.equal(style.top, expectedY + 'px', 'Top');
|
||||
chai.assert.equal(style.height, expectedHeight + 'px', 'Height');
|
||||
@@ -55,57 +55,57 @@ suite('WidgetDiv', function() {
|
||||
suite('LTR', function() {
|
||||
test('noConflict', function() {
|
||||
// Anchor placed in the middle.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed just below at the left side of the
|
||||
// anchor.
|
||||
let expectedX = anchorBBox.left;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = anchorBBox.left;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, false, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('topConflict', function() {
|
||||
// Anchor close to the top.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 50, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed just below the anchor.
|
||||
let expectedX = anchorBBox.left;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = anchorBBox.left;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, false, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('bottomConflict', function() {
|
||||
// Anchor placed close to the bottom.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 900, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed just above the anchor.
|
||||
let expectedX = anchorBBox.left;
|
||||
let expectedY = anchorBBox.top - this.widgetSize.height;
|
||||
const expectedX = anchorBBox.left;
|
||||
const expectedY = anchorBBox.top - this.widgetSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, false, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('leftConflict', function() {
|
||||
// Anchor placed close to the left side.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(50, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed at the anchor.
|
||||
let expectedX = anchorBBox.left;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = anchorBBox.left;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, false, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('rightConflict', function() {
|
||||
// Anchor placed close to the right side.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(950, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed as far right as possible--at the edge of
|
||||
// the screen.
|
||||
let expectedX = this.viewportBBox.width - this.widgetSize.width;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = this.viewportBBox.width - this.widgetSize.width;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, false, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
@@ -113,57 +113,57 @@ suite('WidgetDiv', function() {
|
||||
suite('RTL', function() {
|
||||
test('noConflict', function() {
|
||||
// Anchor placed in the middle
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed at the right side of the anchor.
|
||||
let expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, true, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('topConflict', function() {
|
||||
// Anchor close to the top.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 50, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed just below the anchor.
|
||||
let expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, true, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('bottomConflict', function() {
|
||||
// Anchor placed close to the bottom.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(500, 900, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed just above the anchor.
|
||||
let expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
let expectedY = anchorBBox.top - this.widgetSize.height;
|
||||
const expectedX = anchorBBox.right - this.widgetSize.width;
|
||||
const expectedY = anchorBBox.top - this.widgetSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, true, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('leftConflict', function() {
|
||||
// Anchor placed close to the left side.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(10, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed as far left as possible--at the edge of
|
||||
// the screen.
|
||||
let expectedX = 0;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = 0;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, true, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
test('rightConflict', function() {
|
||||
// Anchor placed close to the right side.
|
||||
let anchorBBox =
|
||||
const anchorBBox =
|
||||
makeBBox(950, 500, this.anchorSize.width, this.anchorSize.height);
|
||||
// The widget div should be placed as far right as possible--at the edge of
|
||||
// the screen.
|
||||
let expectedX = this.viewportBBox.width - this.widgetSize.width;
|
||||
let expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
const expectedX = this.viewportBBox.width - this.widgetSize.width;
|
||||
const expectedY = anchorBBox.top + this.anchorSize.height;
|
||||
this.testWidgetPosition(
|
||||
anchorBBox, true, expectedX, expectedY, this.widgetSize.height);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user