Skip to content

Commit

Permalink
Don't emit STAGE_SIZE_CHANGED if stage size didn't change
Browse files Browse the repository at this point in the history
and also fix the other STAGE_SIZE_CHANGED event test to
actually test that it is being fired when there is a change
  • Loading branch information
GarboMuffin committed Jul 31, 2024
1 parent 658ef8a commit 99ff662
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/engine/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2719,8 +2719,9 @@ class Runtime extends EventEmitter {
height / 2
);
}

this.emit(Runtime.STAGE_SIZE_CHANGED, width, height);
}
this.emit(Runtime.STAGE_SIZE_CHANGED, width, height);
}

// eslint-disable-next-line no-unused-vars
Expand Down
10 changes: 10 additions & 0 deletions test/unit/engine_runtime_tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ test('setStageSize preserves monitor position relative to center of stage', t =>
});

test('setStageSize argument range', t => {
t.plan(6);
const rt = new Runtime();

rt.once('STAGE_SIZE_CHANGED', (width, height) => {
Expand All @@ -194,6 +195,15 @@ test('setStageSize argument range', t => {
t.end();
});

test('STAGE_SIZE_CHANGED does not fire if no change', t => {
const rt = new Runtime();
rt.on('STAGE_SIZE_CHANGED', () => {
t.fail('STAGE_SIZE_CHANGED emitted');
});
rt.setStageSize(rt.stageWidth, rt.stageHeight);
t.end();
});

test('getNumberOfCloudVariables', t => {
const rt = new Runtime();

Expand Down

0 comments on commit 99ff662

Please sign in to comment.