Skip to content

Commit 2c3a097

Browse files
committed
add TypeContext test file
1 parent fce2eed commit 2c3a097

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/TypeContext.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Schema, type, MapSchema, TypeContext } from "../src";
2+
import * as assert from "assert";
3+
import { entity } from "../src/annotations";
4+
5+
describe("TypeContext", () => {
6+
it("should register all inherited classes", () => {
7+
class Pokemon extends Schema {
8+
@type("string") name: string;
9+
}
10+
11+
class Unown extends Pokemon {
12+
@type("number") power: number;
13+
}
14+
15+
@entity class UnownA extends Unown {}
16+
@entity class UnownB extends Unown {}
17+
18+
class MyState extends Schema {
19+
@type({ map: Pokemon }) pokemons = new MapSchema<Pokemon>();
20+
}
21+
22+
const context = new TypeContext(MyState);
23+
24+
assert.strictEqual(context.schemas.size, 5);
25+
})
26+
27+
});

0 commit comments

Comments
 (0)