-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconstructor.test.ts
More file actions
69 lines (52 loc) 路 1.54 KB
/
Copy pathconstructor.test.ts
File metadata and controls
69 lines (52 loc) 路 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { test } from "uvu";
import assert from "uvu/assert";
import { exomeId } from "./constants";
import { Exome } from "./constructor";
test("exports `Exome`", () => {
assert.instance(Exome, Function);
});
test("exome instance have `exomeId`", () => {
const instance = new Exome();
assert.is(typeof instance[exomeId], "string");
});
test("extended exome instance have `exomeId`", () => {
class Person extends Exome {}
const instance = new Person();
assert.is(typeof instance[exomeId], "string");
});
test('exome instance has "Exome" in id', () => {
const instance = new Exome();
assert.match(instance[exomeId], /^Exome-[A-Z0-9]+$/);
});
test('extended exome instance has "Person" in id', () => {
class Person extends Exome {}
const instance = new Person();
assert.match(instance[exomeId], /^Person-[A-Z0-9]+$/);
});
test('extended exome instance has "Person" in id', () => {
class Person extends Exome {}
const instance = new Person();
assert.match(instance[exomeId], /^Person-[A-Z0-9]+$/);
});
test("extended another class has same id", () => {
class PersonParent extends Exome {}
class Person extends PersonParent {}
const instance = new Person();
assert.match(instance[exomeId], /^Person-[A-Z0-9]+$/);
});
test("throws error for async action", async () => {
class TestStore extends Exome {
public async run() {
throw new Error("Poop");
}
}
const test1 = new TestStore();
try {
await test1.run();
assert.unreachable();
} catch (err) {
assert.instance(err, Error);
assert.equal(err.message, "Poop");
}
});
test.run();