Files
blockly/tests/mocha/zoom_controls_test.js
Aaron Dodson 57a5d0d49c refactor: Remove more uses of AnyDuringMigration (#6378)
* refactor: Remove uses of AnyDuringMigration from flyout_vertical.ts.

* refactor: Remove uses of AnyDuringMigration in flyout_horizontal.ts.

* refactor: Remove uses of AnyDuringMigration from zoom_controls.ts.

* refactor: Remove uses of AnyDuringMigration from comment.ts.

* refactor: Remove uses of AnyDuringMigration from dialog.ts.

* refactor: Remove uses of AnyDuringMigration from icon.ts.

* refactor: Remove uses of AnyDuringMigration from scrollbar_pair.ts.

* refactor: Remove uses of AnyDuringMigration from workspace_audio.ts.

* refactor: Remove uses of AnyDuringMigration from workspace_drag_surface_svg.ts.
2022-08-23 15:36:52 -07:00

67 lines
2.3 KiB
JavaScript

/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.declareModuleId('Blockly.test.zoomControls');
import {assertEventFired, assertEventNotFired} from './test_helpers/events.js';
import * as eventUtils from '../../build/src/core/events/utils.js';
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
import {simulateClick} from './test_helpers/user_input.js';
suite("Zoom Controls", function() {
setup(function() {
sharedTestSetup.call(this);
this.workspace = Blockly.inject('blocklyDiv',
{'zoom': {'controls': true}});
this.zoomControls = this.workspace.zoomControls_;
});
teardown(function() {
sharedTestTeardown.call(this);
});
suite("Events", function() {
function closeToMatcher(expectedValue, delta) {
return sinon.match(function(value) {
return Math.abs(value - expectedValue) <= delta;
});
}
test("Zoom in", function() {
simulateClick(this.zoomControls.zoomInGroup);
assertEventFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'zoom_controls', type: eventUtils.CLICK}, this.workspace.id, null);
assertEventNotFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'workspace', type: eventUtils.CLICK});
chai.assert.closeTo(this.workspace.getScale(), 1.2, 0.05);
});
test("Zoom out", function() {
simulateClick(this.zoomControls.zoomOutGroup);
assertEventFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'zoom_controls', type: eventUtils.CLICK}, this.workspace.id, null);
assertEventNotFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'workspace', type: eventUtils.CLICK});
chai.assert.closeTo(this.workspace.getScale(), 0.8, 0.05);
});
test("Reset zoom", function() {
simulateClick(this.zoomControls.zoomResetGroup);
assertEventFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'zoom_controls', type: eventUtils.CLICK}, this.workspace.id, null);
assertEventNotFired(
this.eventsFireStub, Blockly.Events.Click,
{targetType: 'workspace', type: eventUtils.CLICK});
chai.assert.equal(this.workspace.getScale(), 1);
});
});
});