tjson-js
Version:
Tagged JSON (TJSON): a JSON-based microformat with rich type annotations
20 lines (16 loc) • 485 B
text/typescript
import { suite, test } from "mocha-typescript";
import { expect } from "chai";
import { DataType } from "../src/datatype";
const EXAMPLE_TAG = "example";
class ExampleType extends DataType {
tag(): string {
return EXAMPLE_TAG;
}
}
class DataTypeTest {
"registering data types"() {
expect(() => DataType.get(EXAMPLE_TAG)).to.throw(Error);
DataType.register(new ExampleType);
expect(DataType.get(EXAMPLE_TAG)).to.be.a.instanceOf(ExampleType);
}
}