Skip to content

Commit

Permalink
refactor(render): tidy exports
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 10, 2024
1 parent 6d9704a commit 393b2ea
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/element/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { createElement } from './create';
export { jsx } from './jsx';
export * from './create';
export * from './jsx';
export * from './valid';
6 changes: 2 additions & 4 deletions src/render/gameobject.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Phaser from 'phaser';
import type { JSX } from 'react';

import { isValidElement } from '../element/valid';
import { createContainer } from './container';
import { setProps } from './props';
import { attachRef } from './ref';
import { isValidElement } from '../element';
import { attachRef, createContainer, setProps } from '.';

/**
* Creates Phaser game object and adds it to the container.
Expand Down
6 changes: 5 additions & 1 deletion src/render/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { render } from './render';
export * from './container';
export * from './gameobject';
export * from './props';
export * from './ref';
export * from './render';
3 changes: 3 additions & 0 deletions src/render/render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ jest.mock('./container', () => ({
}));

it('does not render element into the scene', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation();
const scene = new Phaser.Scene();
scene.add = {} as Phaser.GameObjects.GameObjectFactory;
scene.add.existing = jest.fn();
const element = {} as JSX.Element;
expect(render(element, scene)).toBe(undefined);
expect(scene.add.existing).not.toBeCalled();
expect(mockContainerAdd).not.toBeCalled();
expect(spy).toBeCalledTimes(1);
spy.mockRestore();
});

it('renders element into the scene', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/render/render.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Phaser from 'phaser';
import type { JSX } from 'react';

import { createContainer } from './container';
import { createGameObject } from './gameobject';
import { createContainer, createGameObject } from '.';

/**
* Renders a piece of JSX into a Phaser scene.
Expand Down

0 comments on commit 393b2ea

Please sign in to comment.