-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a getEntity function for convenience/syntax sugar
- Loading branch information
1 parent
d71373b
commit 6c8335d
Showing
4 changed files
with
68 additions
and
3 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 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 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,40 @@ | ||
import ECS from '../ecs.js' | ||
import tap from 'tap' | ||
|
||
|
||
{ | ||
const w = ECS.createWorld() | ||
|
||
const h = ECS.getEntity(w, [ 'hero' ]) | ||
|
||
tap.equal(h, undefined, 'no match returns undefined') | ||
} | ||
|
||
|
||
{ | ||
const w = ECS.createWorld() | ||
|
||
const e = ECS.createEntity(w) | ||
ECS.addComponentToEntity(w, e, 'hero') | ||
|
||
const h = ECS.getEntity(w, [ 'hero' ]) | ||
|
||
tap.equal(h, e, 'finds 1 matching entity') | ||
} | ||
|
||
|
||
{ | ||
const w = ECS.createWorld() | ||
|
||
const e = ECS.createEntity(w) | ||
ECS.addComponentToEntity(w, e, 'hero') | ||
ECS.addComponentToEntity(w, e, 'a') | ||
|
||
const e2 = ECS.createEntity(w) | ||
ECS.addComponentToEntity(w, e2, 'hero') | ||
ECS.addComponentToEntity(w, e2, 'b') | ||
|
||
const h = ECS.getEntity(w, [ 'hero' ]) | ||
|
||
tap.equal(h, e, 'returns the first match even if there are more than one') | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.