Skip to content

Commit

Permalink
Fix: Support sprite options no texture
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed May 13, 2024
1 parent 78824e4 commit e5ccb9f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scene/sprite/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Sprite extends Container implements View
}

// split out
const { texture, anchor, roundPixels, width, height, ...rest } = options;
const { texture = Texture.EMPTY, anchor, roundPixels, width, height, ...rest } = options;

super({
label: 'Sprite',
Expand Down
23 changes: 23 additions & 0 deletions tests/renderering/sprite/Sprite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ import { getTexture } from '../../utils/getTexture';

describe('Sprite', () =>
{
describe('constructor', () =>
{
it('should support no arguments', () =>
{
const sprite = new Sprite();

expect(sprite).toBeDefined();
expect(sprite.texture).toEqual(Texture.EMPTY);

sprite.destroy();
});

it('should support options with no texture', () =>
{
const sprite = new Sprite({});

expect(sprite).toBeDefined();
expect(sprite.texture).toEqual(Texture.EMPTY);

sprite.destroy();
});
});

describe('destroy', () =>
{
it('should not throw when destroyed', () =>
Expand Down

0 comments on commit e5ccb9f

Please sign in to comment.