Skip to content

Commit

Permalink
chore: Unit testing on minimap position (#1853)
Browse files Browse the repository at this point in the history
* suite scaffold

* extensive test cases (scaffold)

* options

* square one

* LTR done

* RTL done

* feedback refactoring

* split method for unit testing

* added internal tag

* rounding feedback
  • Loading branch information
cesarades authored Aug 15, 2023
1 parent ff1cb10 commit 200701e
Show file tree
Hide file tree
Showing 4 changed files with 404 additions and 167 deletions.
1 change: 1 addition & 0 deletions plugins/workspace-minimap/src/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class Minimap {
minScale: null,
},
readOnly: true,
theme: this.primaryWorkspace.getTheme(),
});

this.minimapWorkspace.scrollbar.setContainerVisible(false);
Expand Down
42 changes: 26 additions & 16 deletions plugins/workspace-minimap/src/positioned_minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,31 @@ export class PositionedMinimap extends Minimap implements Blockly.IPositionable
*/
position(metrics: Blockly.MetricsManager.UiMetrics,
savedPositions: Blockly.utils.Rect[]): void {
this.resize();
this.setSize();
this.setPosition(metrics, savedPositions);
this.setAttributes();
}


/**
* Sizes the minimap.
* @internal
*/
setSize(): void {
const viewWidth = this.primaryWorkspace.getMetrics().viewWidth;
this.width = Math.max(minWidth, viewWidth / 5);
this.height = this.width * 2 / 3;
}


/**
* Calculates the position of the minimap over the primary workspace.
* @param metrics The workspace metrics.
* @param savedPositions List of rectangles already on the workspace.
* @internal
*/
setPosition(metrics: Blockly.MetricsManager.UiMetrics,
savedPositions: Blockly.utils.Rect[]): void {
// Aliases.
const workspace = this.primaryWorkspace;
const scrollbars = workspace.scrollbar;
Expand Down Expand Up @@ -130,26 +153,13 @@ export class PositionedMinimap extends Minimap implements Blockly.IPositionable
i = -1;
}
}

// Update the Css.
this.setMinimapCss();
}


/**
* Sizes the minimap.
*/
resize(): void {
const viewWidth = this.primaryWorkspace.getMetrics().viewWidth;
this.width = Math.max(minWidth, viewWidth / 5);
this.height = this.width * 2 / 3;
}


/**
* Updates the CSS attribute for the minimap.
* Sets the CSS attribute for the minimap.
*/
private setMinimapCss(): void {
private setAttributes(): void {
const injectDiv = this.minimapWorkspace.getInjectionDiv();
// TODO: Styling properties will be added later this is a placeholder.
injectDiv.parentElement.setAttribute('style',
Expand Down
151 changes: 0 additions & 151 deletions plugins/workspace-minimap/test/coordinate_conversion.mocha.js

This file was deleted.

Loading

0 comments on commit 200701e

Please sign in to comment.