Skip to content

Commit

Permalink
rename test files
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Sep 13, 2023
1 parent fff71a3 commit aef7a9a
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "tsc && rollup -c rollup.config.js",
"watch": "tsc -w",
"test": "mocha --require ts-node/register test/*Test.ts test/**/*Test.ts",
"test": "mocha --require ts-node/register test/*.test.ts test/**/*.test.ts",
"coverage": "nyc mocha --require ts-node/register --require source-map-support/register --recursive test/**Test.ts",
"generate-test-1": "bin/schema-codegen test-external/PrimitiveTypes.ts --namespace SchemaTest.PrimitiveTypes --output ../colyseus-unity-sdk/Assets/Editor/ColyseusTests/Schema/PrimitiveTypes",
"generate-test-2": "bin/schema-codegen test-external/ChildSchemaTypes.ts --namespace SchemaTest.ChildSchemaTypes --output ../colyseus-unity-sdk/Assets/Editor/ColyseusTests/Schema/ChildSchemaTypes",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions test/CommunityCases.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as util from "util";
import * as assert from "assert";
import { nanoid } from "nanoid";
import { MapSchema, Schema, type, ArraySchema, defineTypes, Reflection, Context } from "../src";

describe("Community cases", () => {

xit("colyseus/schema/issues/143", () => {
class OptionalSubScheam extends Schema {
@type('number') index: number = 200;
@type('string') my_string: string = 'a good string';
}

class Test extends Schema {
@type('number') size: number = 0; // total number of storage slots in this container.
@type('boolean') transient?: boolean;
@type(OptionalSubScheam) sub?: OptionalSubScheam;
}

const testobj = new Test();
const encoded = testobj.encodeAll(false);
const handshake = Reflection.encode(testobj);

const clientobj = Reflection.decode<Test>(handshake);
assert.strictEqual(clientobj.sub, undefined);
});

});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions test/TypeScriptTypes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as assert from "assert";
import { State, Player, DeepState, DeepMap, DeepChild, Position, DeepEntity } from "./Schema";
import { Schema, ArraySchema, MapSchema, type } from "../src";

describe("TypeScript Types", () => {
it("strict null/undefined checks", () => {
class Player extends Schema {
@type("number") orderPriority: number;
}
class MyState extends Schema {
@type({ map: Player }) players = new MapSchema<Player>();
}

const state = new MyState();
state.players.set("one", new Player().assign({
orderPriority: null,
}));
state.encodeAll();
console.log("DONE!");
});
});
File renamed without changes.
File renamed without changes.

0 comments on commit aef7a9a

Please sign in to comment.