@media-quest/builder 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +15 -15
  2. package/src/Builder-option.ts +64 -64
  3. package/src/Builder-page.spec.ts +2 -160
  4. package/src/Builder-page.ts +6 -83
  5. package/src/Builder-question.spec.ts +68 -68
  6. package/src/Builder-question.ts +102 -102
  7. package/src/Builder-schema.spec.ts +86 -114
  8. package/src/Builder-schema.ts +13 -9
  9. package/src/Builder-text.spec.ts +24 -24
  10. package/src/Builder-text.ts +57 -57
  11. package/src/BuilderObject.ts +30 -29
  12. package/src/BuilderTag.ts +96 -96
  13. package/src/builder-compiler.ts +1 -1
  14. package/src/code-book/codebook-variable.ts +29 -0
  15. package/src/{codebook.ts → code-book/codebook.ts} +72 -72
  16. package/src/primitives/ID.spec.ts +39 -39
  17. package/src/primitives/ID.ts +138 -119
  18. package/src/primitives/page-prefix.ts +59 -59
  19. package/src/primitives/varID.ts +12 -12
  20. package/src/public-api.ts +28 -26
  21. package/src/rulebuilder/Builder-rule.spec.ts +323 -323
  22. package/src/rulebuilder/Builder-rule.ts +191 -191
  23. package/src/rulebuilder/RuleBuilder-test-utils.ts +320 -320
  24. package/src/rulebuilder/RuleInput.ts +30 -30
  25. package/src/rulebuilder/RuleVariable.ts +34 -48
  26. package/src/rulebuilder/SingleSelectItem.ts +9 -8
  27. package/src/rulebuilder/condition/Builder-condition-group.ts +14 -6
  28. package/src/rulebuilder/condition/Builder-condition.spec.ts +12 -12
  29. package/src/rulebuilder/condition/Builder-condition.ts +17 -13
  30. package/src/rulebuilder/index.ts +16 -3
  31. package/src/rulebuilder/page-action-manager.ts +33 -33
  32. package/src/rulebuilder/rule2/Rule2.ts +211 -215
  33. package/src/schema-config.ts +25 -25
  34. package/src/sum-score/sum-score-answer.ts +6 -0
  35. package/src/sum-score/sum-score-manager.spec.ts +189 -0
  36. package/src/sum-score/sum-score-manager.ts +154 -0
  37. package/src/sum-score/sum-score-membership.ts +45 -0
  38. package/src/sum-score/sum-score-variable.spec.ts +151 -0
  39. package/src/sum-score/sum-score-variable.ts +36 -0
  40. package/src/{variable → sum-score}/sum-score.ts +122 -130
  41. package/tsconfig.tsbuildinfo +1 -1
  42. package/src/variable/b-variable.ts +0 -68
  43. package/src/variable/mq-variable.spec.ts +0 -147
  44. package/src/variable/sum-score-variable.ts +0 -50
@@ -1,57 +1,57 @@
1
- import { BuilderObject } from "./BuilderObject";
2
- import { TextID } from "./primitives/ID";
3
-
4
- export interface BuilderTextDto {
5
- readonly id: TextID;
6
- text: string;
7
- name: string;
8
- translationRequired: boolean;
9
- }
10
-
11
- export class BuilderText extends BuilderObject<"builder-text", BuilderTextDto> {
12
- readonly objectType = "builder-text";
13
- id: TextID;
14
- text = "";
15
- name = "";
16
- translateRequired = false;
17
- // audio: {id: B}
18
- private constructor(dto: BuilderTextDto) {
19
- super(dto);
20
- this.id = dto.id;
21
- this.translateRequired = dto.translationRequired;
22
- this.name = dto.name;
23
- this.text = dto.text;
24
- }
25
-
26
- public static create(name: string) {
27
- const id = TextID.create();
28
- const dto: BuilderTextDto = {
29
- id,
30
- name,
31
- text: "",
32
- translationRequired: false,
33
- };
34
- const instance = new BuilderText(dto);
35
- return instance;
36
- }
37
- public static fromJson(dto: BuilderTextDto) {
38
- const instance = new BuilderText(dto);
39
- return instance;
40
- }
41
-
42
- clone(): BuilderTextDto {
43
- const dto = this.toJson();
44
- const withNewId: BuilderTextDto = { ...dto, id: TextID.create() };
45
- return withNewId;
46
- }
47
-
48
- toJson(): BuilderTextDto {
49
- const dto: BuilderTextDto = {
50
- id: this.id,
51
- name: this.name,
52
- text: this.text,
53
- translationRequired: this.translateRequired,
54
- };
55
- return dto;
56
- }
57
- }
1
+ import { BuilderObject } from "./BuilderObject";
2
+ import { TextID } from "./primitives/ID";
3
+
4
+ export interface BuilderTextDto {
5
+ readonly id: TextID;
6
+ text: string;
7
+ name: string;
8
+ translationRequired: boolean;
9
+ }
10
+
11
+ export class BuilderText extends BuilderObject<"builder-text", BuilderTextDto> {
12
+ readonly objectType = "builder-text";
13
+ id: TextID;
14
+ text = "";
15
+ name = "";
16
+ translateRequired = false;
17
+ // audio: {id: B}
18
+ private constructor(dto: BuilderTextDto) {
19
+ super(dto);
20
+ this.id = dto.id;
21
+ this.translateRequired = dto.translationRequired;
22
+ this.name = dto.name;
23
+ this.text = dto.text;
24
+ }
25
+
26
+ public static create(name: string) {
27
+ const id = TextID.create();
28
+ const dto: BuilderTextDto = {
29
+ id,
30
+ name,
31
+ text: "",
32
+ translationRequired: false,
33
+ };
34
+ const instance = new BuilderText(dto);
35
+ return instance;
36
+ }
37
+ public static fromJson(dto: BuilderTextDto) {
38
+ const instance = new BuilderText(dto);
39
+ return instance;
40
+ }
41
+
42
+ clone(): BuilderTextDto {
43
+ const dto = this.toJson();
44
+ const withNewId: BuilderTextDto = { ...dto, id: TextID.create() };
45
+ return withNewId;
46
+ }
47
+
48
+ toJson(): BuilderTextDto {
49
+ const dto: BuilderTextDto = {
50
+ id: this.id,
51
+ name: this.name,
52
+ text: this.text,
53
+ translationRequired: this.translateRequired,
54
+ };
55
+ return dto;
56
+ }
57
+ }
@@ -1,29 +1,30 @@
1
- /**
2
- * Builder objects are complex objects that are embedded inside
3
- * a Builder-schema, and needs to be serialized to json. Often these objects
4
- * are used in collections, and that is why most of them need an id.
5
- */
6
- type BuilderObjectType =
7
- | "builder-page"
8
- | "builder-question-option"
9
- | "builder-question"
10
- | "builder-main-text"
11
- | "builder-text"
12
- | "builder-rule"
13
- | "builder-tag"
14
- | "builder-sum-score-variable"
15
- | "builder-condition"
16
- | "builder-variable"
17
- | "builder-condition-group";
18
-
19
- export abstract class BuilderObject<T extends BuilderObjectType, Dto extends {}> {
20
- // abstract readonly id: string;
21
- abstract readonly objectType: T;
22
- abstract toJson(): Dto;
23
- abstract clone(): Dto;
24
- protected readonly originalDto: Dto;
25
- protected constructor(dto: Dto) {
26
- this.originalDto = dto;
27
- // this.objectId = dto.objectId;
28
- }
29
- }
1
+ /**
2
+ * Builder objects are complex objects that are embedded inside
3
+ * a Builder-schema, and needs to be serialized to json. Often these objects
4
+ * are used in collections, and that is why most of them need an id.
5
+ */
6
+ type BuilderObjectType =
7
+ | "builder-page"
8
+ | "builder-question-option"
9
+ | "builder-question"
10
+ | "builder-main-text"
11
+ | "builder-text"
12
+ | "builder-rule"
13
+ | "builder-tag"
14
+ | "builder-sum-score-variable"
15
+ | "builder-sum-score-membership"
16
+ | "builder-condition"
17
+ | "builder-variable"
18
+ | "builder-condition-group";
19
+
20
+ export abstract class BuilderObject<T extends BuilderObjectType, Dto extends {}> {
21
+ // abstract readonly id: string;
22
+ abstract readonly objectType: T;
23
+ abstract toJson(): Dto;
24
+ abstract clone(): Dto;
25
+ protected readonly originalDto: Dto;
26
+ protected constructor(dto: Dto) {
27
+ this.originalDto = dto;
28
+ // this.objectId = dto.objectId;
29
+ }
30
+ }
package/src/BuilderTag.ts CHANGED
@@ -1,96 +1,96 @@
1
- import { BuilderObject } from "./BuilderObject";
2
- import { TagID } from "./primitives/ID";
3
-
4
- export interface BuilderTagDto {
5
- readonly id: TagID;
6
- readonly tag: string;
7
- readonly description: string;
8
- }
9
-
10
- export class BuilderTag extends BuilderObject<"builder-tag", BuilderTagDto> {
11
- readonly objectType: "builder-tag" = "builder-tag";
12
- readonly id: TagID;
13
- tagText = "";
14
- tagDescription = "";
15
- public static readonly MAX_LENGTH = 20;
16
- public static readonly MIN_LENGTH = 1;
17
-
18
- public static readonly create = (tag: string, description: string = "") => {
19
- const id = TagID.create();
20
- const dto: BuilderTagDto = {
21
- id,
22
- tag,
23
- description,
24
- };
25
- return new BuilderTag(dto);
26
- };
27
- public static readonly fromDto = (dto: BuilderTagDto) => {
28
- return new BuilderTag(dto);
29
- };
30
- protected constructor(dto: BuilderTagDto) {
31
- const id = TagID.validateOrCreate(dto.id);
32
- const withId = { ...dto, id };
33
- super(withId);
34
- this.id = id;
35
- this.tagText = dto.tag ?? "";
36
- this.tagDescription = dto.description ?? "";
37
- }
38
- clone(): BuilderTagDto {
39
- return this.toJson();
40
- }
41
-
42
- toJson(): BuilderTagDto {
43
- return { tag: this.tagText, description: this.tagDescription, id: this.id };
44
- }
45
- }
46
-
47
- export class TagCollection implements Iterable<BuilderTag> {
48
- private readonly _tags = new Set<BuilderTag>();
49
- public static readonly create = () => {
50
- return new TagCollection([]);
51
- };
52
-
53
- [Symbol.iterator]() {
54
- const list = [...this._tags];
55
- return list[Symbol.iterator]();
56
- }
57
- private constructor(initialTags: ReadonlyArray<BuilderTag>) {
58
- initialTags.forEach((tag) => {
59
- this._tags.add(tag);
60
- });
61
- }
62
-
63
- init(tags: ReadonlyArray<BuilderTagDto>) {
64
- const dtoList: ReadonlyArray<BuilderTagDto> = Array.isArray(tags) ? tags : [];
65
- const all = dtoList.map(BuilderTag.fromDto);
66
- all.forEach((tag) => {
67
- this._tags.add(tag);
68
- });
69
- }
70
-
71
- add(tag: BuilderTag) {
72
- this._tags.add(tag);
73
- }
74
-
75
- /**
76
- * Delete this tag from collection;
77
- * @param tag
78
- */
79
- delete(tag: BuilderTag) {
80
- this._tags.delete(tag);
81
- }
82
-
83
- toJson(): ReadonlyArray<BuilderTagDto> {
84
- const list = [...this._tags];
85
- const dtoList = list.map((t) => t.toJson());
86
- return dtoList;
87
- }
88
-
89
- deleteAll(tags: Iterable<BuilderTag>) {
90
- const l = tags[Symbol.iterator]();
91
- const asList = [...tags];
92
- asList.forEach((t) => {
93
- this.delete(t);
94
- });
95
- }
96
- }
1
+ import { BuilderObject } from "./BuilderObject";
2
+ import { TagID } from "./primitives/ID";
3
+
4
+ export interface BuilderTagDto {
5
+ readonly id: TagID;
6
+ readonly tag: string;
7
+ readonly description: string;
8
+ }
9
+
10
+ export class BuilderTag extends BuilderObject<"builder-tag", BuilderTagDto> {
11
+ readonly objectType: "builder-tag" = "builder-tag";
12
+ readonly id: TagID;
13
+ tagText = "";
14
+ tagDescription = "";
15
+ public static readonly MAX_LENGTH = 20;
16
+ public static readonly MIN_LENGTH = 1;
17
+
18
+ public static readonly create = (tag: string, description: string = "") => {
19
+ const id = TagID.create();
20
+ const dto: BuilderTagDto = {
21
+ id,
22
+ tag,
23
+ description,
24
+ };
25
+ return new BuilderTag(dto);
26
+ };
27
+ public static readonly fromDto = (dto: BuilderTagDto) => {
28
+ return new BuilderTag(dto);
29
+ };
30
+ protected constructor(dto: BuilderTagDto) {
31
+ const id = TagID.validateOrCreate(dto.id);
32
+ const withId = { ...dto, id };
33
+ super(withId);
34
+ this.id = id;
35
+ this.tagText = dto.tag ?? "";
36
+ this.tagDescription = dto.description ?? "";
37
+ }
38
+ clone(): BuilderTagDto {
39
+ return this.toJson();
40
+ }
41
+
42
+ toJson(): BuilderTagDto {
43
+ return { tag: this.tagText, description: this.tagDescription, id: this.id };
44
+ }
45
+ }
46
+
47
+ export class TagCollection implements Iterable<BuilderTag> {
48
+ private readonly _tags = new Set<BuilderTag>();
49
+ public static readonly create = () => {
50
+ return new TagCollection([]);
51
+ };
52
+
53
+ [Symbol.iterator]() {
54
+ const list = [...this._tags];
55
+ return list[Symbol.iterator]();
56
+ }
57
+ private constructor(initialTags: ReadonlyArray<BuilderTag>) {
58
+ initialTags.forEach((tag) => {
59
+ this._tags.add(tag);
60
+ });
61
+ }
62
+
63
+ init(tags: ReadonlyArray<BuilderTagDto>) {
64
+ const dtoList: ReadonlyArray<BuilderTagDto> = Array.isArray(tags) ? tags : [];
65
+ const all = dtoList.map(BuilderTag.fromDto);
66
+ all.forEach((tag) => {
67
+ this._tags.add(tag);
68
+ });
69
+ }
70
+
71
+ add(tag: BuilderTag) {
72
+ this._tags.add(tag);
73
+ }
74
+
75
+ /**
76
+ * Delete this tag from collection;
77
+ * @param tag
78
+ */
79
+ delete(tag: BuilderTag) {
80
+ this._tags.delete(tag);
81
+ }
82
+
83
+ toJson(): ReadonlyArray<BuilderTagDto> {
84
+ const list = [...this._tags];
85
+ const dtoList = list.map((t) => t.toJson());
86
+ return dtoList;
87
+ }
88
+
89
+ deleteAll(tags: Iterable<BuilderTag>) {
90
+ const l = tags[Symbol.iterator]();
91
+ const asList = [...tags];
92
+ asList.forEach((t) => {
93
+ this.delete(t);
94
+ });
95
+ }
96
+ }
@@ -1,5 +1,5 @@
1
1
  import { SchemaDto } from "@media-quest/engine";
2
- import { Codebook } from "./codebook";
2
+ import { Codebook } from "./code-book/codebook";
3
3
  import { SchemaConfig } from "./schema-config";
4
4
 
5
5
  export interface CompilerOutput {
@@ -0,0 +1,29 @@
1
+ import { PageID } from "../primitives/ID";
2
+
3
+ /**
4
+ * Interface representing a code book question sum-score.
5
+ *
6
+ * @interface
7
+ */
8
+ export interface CodeBookQuestionVariable {
9
+ readonly kind: "codebook-question-variable";
10
+ readonly label: string;
11
+ readonly varId: string;
12
+ readonly pageId: PageID;
13
+ readonly pagePrefix: string;
14
+ readonly modulePrefix: string;
15
+ /**
16
+ * Show the position of the question on page (a, b, c, d, ...)
17
+ */
18
+ readonly questionPrefix: string;
19
+ readonly pagePosition: number;
20
+ readonly options: ReadonlyArray<{ label: string; value: number }>;
21
+ }
22
+
23
+ export interface CodebookPredefinedVariable {
24
+ readonly kind: "codebook-predefined-variable";
25
+ readonly modulePrefix: string;
26
+ readonly moduleID: string;
27
+ defaultValue: number;
28
+ options: Array<{ label: string; value: number }>;
29
+ }
@@ -1,72 +1,72 @@
1
- import { BuilderPageDto } from "./Builder-page";
2
- import { BuilderSchemaDto } from "./Builder-schema";
3
- import { PageVariable, PredefinedVariable } from "./variable/b-variable";
4
-
5
- export interface Codebook {
6
- readonly predefinedVariables: ReadonlyArray<PredefinedVariable>;
7
- readonly pageVariables: ReadonlyArray<PageVariable>;
8
- }
9
-
10
- const fromPage = (
11
- page: BuilderPageDto,
12
- pagePosition: number,
13
- modulePrefix: string,
14
- ): PageVariable[] => {
15
- const variables: PageVariable[] = [];
16
-
17
- if (page._type !== "question") {
18
- // TODO Implement form field variables
19
- return [];
20
- }
21
-
22
- const options: PageVariable["options"] = page.defaultQuestion.options.map((o) => {
23
- return { value: o.value, label: o.label };
24
- });
25
-
26
- const variable: PageVariable = {
27
- kind: "numeric-variable",
28
- label: page.mainText.text,
29
- options,
30
- modulePrefix,
31
- origin: "question",
32
- pageId: page.id,
33
- pagePosition,
34
- pagePrefix: page.prefix,
35
- varId: modulePrefix + "_" + page.prefix,
36
- };
37
-
38
- variables.push(variable);
39
-
40
- return variables;
41
- };
42
-
43
- /**
44
- * Converts a list of pages into a list of question-variables
45
- * @param pages
46
- * @param modulePrefix
47
- */
48
- const getPageVariablesFromPages = (
49
- pages: BuilderPageDto[],
50
- modulePrefix: string,
51
- ): PageVariable[] => {
52
- const variables: PageVariable[] = [];
53
- pages.forEach((page, index) => {
54
- const pageVariables = fromPage(page, index, modulePrefix);
55
- variables.push(...pageVariables);
56
- });
57
- return variables;
58
- };
59
-
60
- const fromSchema = (schema: BuilderSchemaDto): Codebook => {
61
- const modulePrefix = schema.prefix;
62
- const pageVariables = getPageVariablesFromPages(schema.pages, modulePrefix);
63
- const vs = schema.predefinedVariables;
64
- const predefinedVariables: PredefinedVariable[] = vs ? [...vs] : [];
65
- return { pageVariables, predefinedVariables };
66
- };
67
-
68
- export const _CodeBook = {
69
- fromSchema,
70
- } as const;
71
-
72
- export const CodeBook = Object.freeze(_CodeBook);
1
+ import { BuilderPageDto } from "../Builder-page";
2
+ import { BuilderSchemaDto } from "../Builder-schema";
3
+ import { CodeBookQuestionVariable, CodebookPredefinedVariable } from "./codebook-variable";
4
+
5
+ export interface Codebook {
6
+ readonly predefinedVariables: ReadonlyArray<CodebookPredefinedVariable>;
7
+ readonly pageVariables: ReadonlyArray<CodeBookQuestionVariable>;
8
+ }
9
+
10
+ const fromPage = (
11
+ page: BuilderPageDto,
12
+ pagePosition: number,
13
+ modulePrefix: string,
14
+ ): CodeBookQuestionVariable[] => {
15
+ const variables: CodeBookQuestionVariable[] = [];
16
+
17
+ if (page._type !== "question") {
18
+ // TODO Implement form field variables
19
+ return [];
20
+ }
21
+
22
+ const options: CodeBookQuestionVariable["options"] = page.defaultQuestion.options.map((o) => {
23
+ return { value: o.value, label: o.label };
24
+ });
25
+
26
+ const variable: CodeBookQuestionVariable = {
27
+ kind: "codebook-question-variable",
28
+ label: page.mainText.text,
29
+ pageId: page.id,
30
+ pagePrefix: page.prefix,
31
+ options,
32
+ modulePrefix,
33
+ pagePosition,
34
+ questionPrefix: "",
35
+ varId: modulePrefix + "_" + page.prefix,
36
+ };
37
+
38
+ variables.push(variable);
39
+
40
+ return variables;
41
+ };
42
+
43
+ /**
44
+ * Converts a list of pages into a list of question-variables
45
+ * @param pages
46
+ * @param modulePrefix
47
+ */
48
+ const getPageVariablesFromPages = (
49
+ pages: BuilderPageDto[],
50
+ modulePrefix: string,
51
+ ): CodeBookQuestionVariable[] => {
52
+ const variables: CodeBookQuestionVariable[] = [];
53
+ pages.forEach((page, index) => {
54
+ const pageVariables = fromPage(page, index, modulePrefix);
55
+ variables.push(...pageVariables);
56
+ });
57
+ return variables;
58
+ };
59
+
60
+ const fromSchema = (schema: BuilderSchemaDto): Codebook => {
61
+ const modulePrefix = schema.prefix;
62
+ const pageVariables = getPageVariablesFromPages(schema.pages, modulePrefix);
63
+ const vs = schema.predefinedVariables;
64
+ const predefinedVariables: CodebookPredefinedVariable[] = vs ? [...vs] : [];
65
+ return { pageVariables, predefinedVariables };
66
+ };
67
+
68
+ export const _CodeBook = {
69
+ fromSchema,
70
+ } as const;
71
+
72
+ export const CodeBook = Object.freeze(_CodeBook);
@@ -1,39 +1,39 @@
1
- import { PageID, SchemaID } from "./ID";
2
-
3
- describe("ID Functions work", () => {
4
- //Generate test for schema prefix
5
- test("SCHEMA_ID isFunction works", () => {
6
- const id = SchemaID.create();
7
- expect(SchemaID.is(id)).toBe(true);
8
- expect(SchemaID.is("")).toBe(false);
9
- expect(SchemaID.is("a")).toBe(false);
10
- expect(SchemaID.is("a".repeat(10))).toBe(true);
11
- expect(SchemaID.is("a".repeat(9))).toBe(false);
12
- });
13
- test("SCHEMA_ID ensure works", () => {
14
- const id = SchemaID.create();
15
- expect(SchemaID.validateOrCreate(id)).toBe(id);
16
- expect(SchemaID.validateOrCreate("")).not.toBe("");
17
- expect(SchemaID.validateOrCreate("")).not.toBe("a");
18
- expect(SchemaID.validateOrCreate("a".repeat(10))).toBe("a".repeat(10));
19
- expect(SchemaID.validateOrCreate("a".repeat(9))).not.toBe("a".repeat(9));
20
- expect(SchemaID.validateOrCreate("ABcdefghigKLML")).toBe("ABcdefghigKLML");
21
- });
22
- test("PageID isFunction works", () => {
23
- const id = PageID.create();
24
- expect(PageID.is(id)).toBe(true);
25
- expect(PageID.is("")).toBe(false);
26
- expect(PageID.is("a")).toBe(false);
27
- expect(PageID.is("a".repeat(10))).toBe(true);
28
- expect(PageID.is("a".repeat(9))).toBe(false);
29
- });
30
- test("PageID ensure works", () => {
31
- const id = PageID.create();
32
- expect(PageID.validateOrCreate(id)).toBe(id);
33
- expect(PageID.validateOrCreate("")).not.toBe("");
34
- expect(PageID.validateOrCreate("")).not.toBe("a");
35
- expect(PageID.validateOrCreate("a".repeat(10))).toBe("a".repeat(10));
36
- expect(PageID.validateOrCreate("a".repeat(9))).not.toBe("a".repeat(9));
37
- expect(PageID.validateOrCreate("ABcdefghigKLML")).toBe("ABcdefghigKLML");
38
- });
39
- });
1
+ import { PageID, SchemaID } from "./ID";
2
+
3
+ describe("ID Functions work", () => {
4
+ //Generate test for schema prefix
5
+ test("SCHEMA_ID isFunction works", () => {
6
+ const id = SchemaID.create();
7
+ expect(SchemaID.is(id)).toBe(true);
8
+ expect(SchemaID.is("")).toBe(false);
9
+ expect(SchemaID.is("a")).toBe(false);
10
+ expect(SchemaID.is("a".repeat(10))).toBe(true);
11
+ expect(SchemaID.is("a".repeat(9))).toBe(false);
12
+ });
13
+ test("SCHEMA_ID ensure works", () => {
14
+ const id = SchemaID.create();
15
+ expect(SchemaID.validateOrCreate(id)).toBe(id);
16
+ expect(SchemaID.validateOrCreate("")).not.toBe("");
17
+ expect(SchemaID.validateOrCreate("")).not.toBe("a");
18
+ expect(SchemaID.validateOrCreate("a".repeat(10))).toBe("a".repeat(10));
19
+ expect(SchemaID.validateOrCreate("a".repeat(9))).not.toBe("a".repeat(9));
20
+ expect(SchemaID.validateOrCreate("ABcdefghigKLML")).toBe("ABcdefghigKLML");
21
+ });
22
+ test("PageID isFunction works", () => {
23
+ const id = PageID.create();
24
+ expect(PageID.is(id)).toBe(true);
25
+ expect(PageID.is("")).toBe(false);
26
+ expect(PageID.is("a")).toBe(false);
27
+ expect(PageID.is("a".repeat(10))).toBe(true);
28
+ expect(PageID.is("a".repeat(9))).toBe(false);
29
+ });
30
+ test("PageID ensure works", () => {
31
+ const id = PageID.create();
32
+ expect(PageID.validateOrCreate(id)).toBe(id);
33
+ expect(PageID.validateOrCreate("")).not.toBe("");
34
+ expect(PageID.validateOrCreate("")).not.toBe("a");
35
+ expect(PageID.validateOrCreate("a".repeat(10))).toBe("a".repeat(10));
36
+ expect(PageID.validateOrCreate("a".repeat(9))).not.toBe("a".repeat(9));
37
+ expect(PageID.validateOrCreate("ABcdefghigKLML")).toBe("ABcdefghigKLML");
38
+ });
39
+ });