Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Aug 8, 2024
1 parent 017b974 commit 97be1a5
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/unit/tileEngine.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import TileEngine, { TileEngineClass } from '../../src/tileEngine.js';
import { _reset, init, getContext } from '../../src/core.js';
import {
_reset,
init,
getContext,
getCanvas
} from '../../src/core.js';
import { noop } from '../../src/utils.js';

// test-context:start
Expand Down Expand Up @@ -1555,8 +1560,14 @@ describe(
// tileEngine.getPosition
// --------------------------------------------------
describe('getPosition', () => {
let tileEngine;
let tileEngine,
canvas;
beforeEach(() => {
canvas = getCanvas();
canvas.style.position = 'absolute';
canvas.style.left = '0px';
canvas.style.top = '0px';

tileEngine = TileEngine({
tilewidth: 10,
tileheight: 10,
Expand Down Expand Up @@ -1588,9 +1599,8 @@ describe(
});

it('should take into account canvas position', () => {
tileEngine.context.canvas.style.position = 'absolute';
tileEngine.context.canvas.style.left = '100px';
tileEngine.context.canvas.style.top = '50px';
canvas.style.left = '100px';
canvas.style.top = '50px';
let position = tileEngine.getPosition({ x: 100, y: 100 });

expect(position).to.deep.equal({
Expand Down

0 comments on commit 97be1a5

Please sign in to comment.