mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Use existing toolbox position enum
This commit is contained in:
@@ -43,15 +43,14 @@ suite('Flyout', function() {
|
||||
viewWidth: 100,
|
||||
});
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
Blockly.utils.toolbox.Position.RIGHT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT;
|
||||
chai.assert.equal(this.flyout.getX(), 100, 'x should be right of workspace');
|
||||
});
|
||||
test('x is 0 if flyout at left', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.LEFT;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.LEFT;
|
||||
Blockly.utils.toolbox.Position.LEFT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT;
|
||||
chai.assert.equal(this.flyout.getX(), 0, 'x should be 0 if the flyout is on the left');
|
||||
});
|
||||
});
|
||||
@@ -72,8 +71,8 @@ suite('Flyout', function() {
|
||||
toolboxWidth: 20,
|
||||
});
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.LEFT;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.LEFT;
|
||||
Blockly.utils.toolbox.Position.LEFT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT;
|
||||
chai.assert.equal(this.flyout.getX(), 20, 'x should be aligned with toolbox');
|
||||
});
|
||||
test('x is aligned with toolbox at right', function() {
|
||||
@@ -83,9 +82,8 @@ suite('Flyout', function() {
|
||||
});
|
||||
this.flyout.width_ = 10;
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
Blockly.utils.toolbox.Position.RIGHT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT;
|
||||
chai.assert.equal(this.flyout.getX(), 90,'x + width should be aligned with toolbox');
|
||||
});
|
||||
});
|
||||
@@ -100,8 +98,8 @@ suite('Flyout', function() {
|
||||
viewWidth: 100,
|
||||
});
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.LEFT;
|
||||
Blockly.utils.toolbox.Position.RIGHT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.LEFT;
|
||||
chai.assert.equal(this.flyout.getX(), 0, 'x should be aligned with left edge');
|
||||
});
|
||||
test('trashcan on right covers right edge of workspace', function() {
|
||||
@@ -111,9 +109,8 @@ suite('Flyout', function() {
|
||||
absoluteLeft: 10,
|
||||
});
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.LEFT;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.RIGHT;
|
||||
Blockly.utils.toolbox.Position.LEFT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT;
|
||||
chai.assert.equal(this.flyout.getX(), 90, 'x + width should be aligned with right edge');
|
||||
});
|
||||
});
|
||||
@@ -139,15 +136,14 @@ suite('Flyout', function() {
|
||||
});
|
||||
test('y is 0 if flyout at top', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.TOP;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.TOP;
|
||||
Blockly.utils.toolbox.Position.TOP;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP;
|
||||
chai.assert.equal(this.flyout.getY(), 0, 'y should be 0 if flyout is at the top');
|
||||
});
|
||||
test('y is below workspace if flyout at bottom', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
Blockly.utils.toolbox.Position.BOTTOM;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.BOTTOM;
|
||||
sinon.stub(this.flyout.targetWorkspace, 'getMetrics').returns({
|
||||
viewHeight: 50,
|
||||
});
|
||||
@@ -172,8 +168,8 @@ suite('Flyout', function() {
|
||||
toolboxHeight: 20,
|
||||
});
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.TOP;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.TOP;
|
||||
Blockly.utils.toolbox.Position.TOP;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP;
|
||||
chai.assert.equal(this.flyout.getY(), 20, 'y should be aligned with toolbox');
|
||||
});
|
||||
test('y is aligned with toolbox at bottom', function() {
|
||||
@@ -183,9 +179,8 @@ suite('Flyout', function() {
|
||||
});
|
||||
this.flyout.height_ = 30;
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
Blockly.utils.toolbox.Position.BOTTOM;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.BOTTOM;
|
||||
chai.assert.equal(this.flyout.getY(), 70, 'y + height should be aligned with toolbox');
|
||||
});
|
||||
});
|
||||
@@ -197,15 +192,14 @@ suite('Flyout', function() {
|
||||
});
|
||||
test('y is 0 if trashcan at top', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
this.flyout.toolboxPosition_ = Blockly.constants.toolboxPosition.TOP;
|
||||
Blockly.utils.toolbox.Position.BOTTOM;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.TOP;
|
||||
chai.assert.equal(this.flyout.getY(), 0, 'y should be aligned with top');
|
||||
});
|
||||
test('trashcan on bottom covers bottom of workspace', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.constants.toolboxPosition.TOP;
|
||||
this.flyout.toolboxPosition_ =
|
||||
Blockly.constants.toolboxPosition.BOTTOM;
|
||||
Blockly.utils.toolbox.Position.TOP;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.BOTTOM;
|
||||
sinon.stub(this.flyout.targetWorkspace, 'getMetrics').returns({
|
||||
viewHeight: 50,
|
||||
absoluteTop: 10,
|
||||
|
||||
@@ -444,7 +444,7 @@ suite('Toolbox', function() {
|
||||
});
|
||||
test('Horizontal toolbox at top -> Should anchor horizontal toolbox to top', function() {
|
||||
var toolbox = this.toolbox;
|
||||
toolbox.toolboxPosition = Blockly.constants.toolboxPosition.TOP;
|
||||
toolbox.toolboxPosition = Blockly.utils.toolbox.Position.TOP;
|
||||
toolbox.horizontalLayout_ = true;
|
||||
toolbox.position();
|
||||
checkHorizontalToolbox(toolbox);
|
||||
@@ -452,7 +452,7 @@ suite('Toolbox', function() {
|
||||
});
|
||||
test('Horizontal toolbox at bottom -> Should anchor horizontal toolbox to bottom', function() {
|
||||
var toolbox = this.toolbox;
|
||||
toolbox.toolboxPosition = Blockly.constants.toolboxPosition.BOTTOM;
|
||||
toolbox.toolboxPosition = Blockly.utils.toolbox.Position.BOTTOM;
|
||||
toolbox.horizontalLayout_ = true;
|
||||
toolbox.position();
|
||||
checkHorizontalToolbox(toolbox);
|
||||
@@ -460,7 +460,7 @@ suite('Toolbox', function() {
|
||||
});
|
||||
test('Vertical toolbox at right -> Should anchor to right', function() {
|
||||
var toolbox = this.toolbox;
|
||||
toolbox.toolboxPosition = Blockly.constants.toolboxPosition.RIGHT;
|
||||
toolbox.toolboxPosition = Blockly.utils.toolbox.Position.RIGHT;
|
||||
toolbox.horizontalLayout_ = false;
|
||||
toolbox.position();
|
||||
chai.assert.equal(toolbox.HtmlDiv.style.right, '0px', 'Check right');
|
||||
@@ -468,7 +468,7 @@ suite('Toolbox', function() {
|
||||
});
|
||||
test('Vertical toolbox at left -> Should anchor to left', function() {
|
||||
var toolbox = this.toolbox;
|
||||
toolbox.toolboxPosition = Blockly.constants.toolboxPosition.LEFT;
|
||||
toolbox.toolboxPosition = Blockly.utils.toolbox.Position.LEFT;
|
||||
toolbox.horizontalLayout_ = false;
|
||||
toolbox.position();
|
||||
chai.assert.equal(toolbox.HtmlDiv.style.left, '0px', 'Check left');
|
||||
|
||||
Reference in New Issue
Block a user