-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move tests to other directory, add tests dependencies.
- Loading branch information
Showing
7 changed files
with
89 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/pixi/utils/builders.kt → src/main/kotlin/utils/builders.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pixi.utils | ||
package utils | ||
|
||
import kotlinext.js.jso | ||
import pixi.typings.app.Application | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package tests | ||
|
||
import kotlinx.browser.document | ||
import kotlinx.browser.window | ||
import pixi.typings.app.Application | ||
import pixi.typings.loaders.Loader | ||
import pixi.typings.sprite.Sprite | ||
import pixi.typings.ticker.Ticker | ||
import utils.Application | ||
import kotlin.random.Random | ||
import kotlin.test.Test | ||
import kotlin.test.assertContains | ||
import kotlin.test.assertNotNull | ||
|
||
lateinit var app: Application | ||
|
||
class Tests { | ||
lateinit var sprite: Sprite | ||
|
||
init { | ||
println("executing main") | ||
pixi.typings.require("pixi.js") | ||
app = Application { | ||
backgroundColor = (0xf0f0f0).toDouble() | ||
resizeTo = window | ||
} | ||
|
||
Loader.shared.add("test", "test.png").load { _, _ -> start() } | ||
document.getElementById("root")!!.appendChild(app.view) | ||
} | ||
|
||
fun start() { | ||
val size = 250.0 | ||
sprite = Sprite.from("test.png").apply { | ||
width = size | ||
height = size | ||
anchor.set(0.5) | ||
} | ||
|
||
Ticker.shared.add<Any>({ _, _ -> | ||
sprite.apply { | ||
x = (Random.nextDouble() * window.innerWidth).coerceIn(size / 2, window.innerWidth - size / 2) | ||
y = (Random.nextDouble() * window.innerHeight).coerceIn(size / 2, window.innerHeight - size / 2) | ||
} | ||
}) | ||
|
||
app.stage.addChild(sprite) | ||
} | ||
|
||
@Test | ||
fun testAppAdded() { | ||
assertNotNull(document.querySelector("canvas")) | ||
} | ||
|
||
@Test | ||
fun testSprite() { | ||
assertContains(app.stage.children, sprite) | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
src/main/resources/index.css → src/test/resources/index.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
overflow: hidden; | ||
} | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
overflow: hidden; | ||
} |
24 changes: 12 additions & 12 deletions
24
src/main/resources/index.html → src/test/resources/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>JS Client</title> | ||
<link href="index.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<script defer src="dist.js"></script> | ||
<div id="root"></div> | ||
</body> | ||
</html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>JS Client</title> | ||
<link href="index.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<script defer src="dist.js"></script> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
File renamed without changes