Skip to content

Commit

Permalink
Update textinputruntimeobject.pixiruntimegamewithassets.spec.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NeylMahfouf2608 committed Jan 20, 2025
1 parent 9898f2a commit ec48bb4
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,33 @@ describe('gdjs.TextInputRuntimeObject (using a PixiJS RuntimeGame with DOM eleme
object,
} = await setupObjectAndGetDomElementContainer();

const inputElement = gameDomElementContainer.querySelector('input');
if (!inputElement) throw new Error('Expected input element to be found');
const formElement = gameDomElementContainer.querySelector('form');
if (!formElement) throw new Error('Expected form element to be found');

// Check visibility of the DOM element is visible by default, if it should be visible
// on the screen.
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

// Check visibility of the DOM element is updated at each frame,
// according to the object visibility.
object.hide(true);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('none');
expect(formElement.style.display).to.be('none');

object.hide(false);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

// Check visibility of the DOM element is updated at each frame,
// according to the layer visibility.
runtimeScene.getLayer('').show(false);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('none');
expect(formElement.style.display).to.be('none');

runtimeScene.getLayer('').show(true);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

// Clean up - not mandatory but to avoid overloading the testing browser.
runtimeScene.unloadScene();
Expand All @@ -208,31 +208,31 @@ describe('gdjs.TextInputRuntimeObject (using a PixiJS RuntimeGame with DOM eleme
object,
} = await setupObjectAndGetDomElementContainer();

const inputElement = gameDomElementContainer.querySelector('input');
if (!inputElement) throw new Error('Expected input element to be found');
const formElement = gameDomElementContainer.querySelector('form');
if (!formElement) throw new Error('Expected input element to be found');

// Check visibility of the DOM element is visible by default, if it should be visible
// on the screen.
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

// Check visibility of the DOM element is updated at each frame,
// according to the object position of screen.
object.setX(-500); // -500 + 300 (object default width) = -200, still outside the camera.
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('none');
expect(formElement.style.display).to.be('none');

object.setWidth(600); // -500 + 600 = 100, inside the camera
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

runtimeScene.getLayer('').setCameraX(900);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('none');
expect(formElement.style.display).to.be('none');

runtimeScene.getLayer('').setCameraX(400);
runtimeScene.renderAndStep(1000 / 60);
expect(inputElement.style.display).to.be('initial');
expect(formElement.style.display).to.be('initial');

// Clean up - not mandatory but to avoid overloading the testing browser.
runtimeScene.unloadScene();
Expand Down

0 comments on commit ec48bb4

Please sign in to comment.