Skip to content

Commit 2c8ade5

Browse files
committed
[benc/tstyche] Migrate remaining tests
1 parent 10116be commit 2c8ade5

File tree

6 files changed

+58
-86
lines changed

6 files changed

+58
-86
lines changed

packages/perseus-core/src/parse-perseus-json/general-purpose-parsers/test-helpers.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ export function parseFailureWith(
2727
export function summon<T>(): T {
2828
return "fake summoned value" as any;
2929
}
30-
31-
export type RecursiveRequired<T> = T extends object
32-
? RecursiveRequiredObject<T>
33-
: T;
34-
35-
type RecursiveRequiredObject<T extends object> = {
36-
[K in keyof T]-?: RecursiveRequired<T[K]>;
37-
};
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
// FIXME: update these tests to use tstyche. Follow the example of other tests
2-
// in this directory that import tstyche.
1+
import {describe, it, expect} from "tstyche";
32

4-
import {summon} from "../general-purpose-parsers/test-helpers";
3+
import {ctx} from "../general-purpose-parsers/test-helpers";
54

6-
import type {parseHint} from "./hint";
7-
import type {Hint} from "../../data-schema";
8-
import type {RecursiveRequired} from "../general-purpose-parsers/test-helpers";
9-
import type {ParsedValue} from "../parser-types";
10-
11-
type Parsed = ParsedValue<typeof parseHint>;
5+
import {parseHint} from "./hint";
126

13-
summon<Parsed>() satisfies Hint;
14-
summon<Hint>() satisfies Parsed;
7+
import type {Hint} from "../../data-schema";
8+
import type {ParseResult} from "../parser-types";
159

16-
// The `RecursiveRequired` test ensures that any new optional properties added
17-
// to the types in data-schema.ts are also added to the parser.
18-
summon<RecursiveRequired<Parsed>>() satisfies RecursiveRequired<Hint>;
10+
describe("the Hint parser", () => {
11+
it("should return the type defined in data-schema.ts", () => {
12+
expect(parseHint({}, ctx())).type.toBe<ParseResult<Hint>>();
13+
});
14+
});
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
// FIXME: update these tests to use tstyche. Follow the example of other tests
2-
// in this directory that import tstyche.
1+
import {describe, it, expect} from "tstyche";
32

4-
import {summon} from "../general-purpose-parsers/test-helpers";
3+
import {ctx} from "../general-purpose-parsers/test-helpers";
54

6-
import type {parseLegacyButtonSets} from "./legacy-button-sets";
7-
import type {LegacyButtonSets} from "../../data-schema";
8-
import type {RecursiveRequired} from "../general-purpose-parsers/test-helpers";
9-
import type {ParsedValue} from "../parser-types";
10-
11-
type Parsed = ParsedValue<typeof parseLegacyButtonSets>;
5+
import {parseLegacyButtonSets} from "./legacy-button-sets";
126

13-
summon<Parsed>() satisfies LegacyButtonSets;
14-
summon<LegacyButtonSets>() satisfies Parsed;
7+
import type {LegacyButtonSets} from "../../data-schema";
8+
import type {ParseResult} from "../parser-types";
159

16-
// The `RecursiveRequired` test ensures that any new optional properties added
17-
// to the types in data-schema.ts are also added to the parser.
18-
summon<
19-
RecursiveRequired<Parsed>
20-
>() satisfies RecursiveRequired<LegacyButtonSets>;
10+
describe("the LegacyButtonSets parser", () => {
11+
it("should return the type defined in data-schema.ts", () => {
12+
expect(parseLegacyButtonSets({}, ctx())).type.toBe<
13+
ParseResult<LegacyButtonSets>
14+
>();
15+
});
16+
});
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
// FIXME: update these tests to use tstyche. Follow the example of other tests
2-
// in this directory that import tstyche.
1+
import {describe, it, expect} from "tstyche";
32

4-
import {summon} from "../general-purpose-parsers/test-helpers";
3+
import {ctx} from "../general-purpose-parsers/test-helpers";
54

6-
import type {parsePerseusAnswerArea} from "./perseus-answer-area";
7-
import type {PerseusAnswerArea} from "../../data-schema";
8-
import type {RecursiveRequired} from "../general-purpose-parsers/test-helpers";
9-
import type {ParsedValue} from "../parser-types";
10-
11-
type Parsed = ParsedValue<typeof parsePerseusAnswerArea>;
5+
import {parsePerseusAnswerArea} from "./perseus-answer-area";
126

13-
summon<Parsed>() satisfies PerseusAnswerArea;
14-
summon<PerseusAnswerArea>() satisfies Parsed;
7+
import type {PerseusAnswerArea} from "../../data-schema";
8+
import type {ParseResult} from "../parser-types";
159

16-
// The `RecursiveRequired` test ensures that any new optional properties added
17-
// to the types in data-schema.ts are also added to the parser.
18-
summon<
19-
RecursiveRequired<Parsed>
20-
>() satisfies RecursiveRequired<PerseusAnswerArea>;
10+
describe("the PerseusAnswerArea parser", () => {
11+
it("should return the type defined in data-schema.ts", () => {
12+
expect(parsePerseusAnswerArea({}, ctx())).type.toBe<
13+
ParseResult<PerseusAnswerArea>
14+
>();
15+
});
16+
});
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
// FIXME: update these tests to use tstyche. Follow the example of other tests
2-
// in this directory that import tstyche.
1+
import {describe, it, expect} from "tstyche";
32

4-
import {summon} from "../general-purpose-parsers/test-helpers";
3+
import {ctx} from "../general-purpose-parsers/test-helpers";
54

6-
import type {parsePerseusImageBackground} from "./perseus-image-background";
7-
import type {PerseusImageBackground} from "../../data-schema";
8-
import type {RecursiveRequired} from "../general-purpose-parsers/test-helpers";
9-
import type {ParsedValue} from "../parser-types";
10-
11-
type Parsed = ParsedValue<typeof parsePerseusImageBackground>;
5+
import {parsePerseusImageBackground} from "./perseus-image-background";
126

13-
summon<Parsed>() satisfies PerseusImageBackground;
14-
summon<PerseusImageBackground>() satisfies Parsed;
7+
import type {PerseusImageBackground} from "../../data-schema";
8+
import type {ParseResult} from "../parser-types";
159

16-
// The `RecursiveRequired` test ensures that any new optional properties added
17-
// to the types in data-schema.ts are also added to the parser.
18-
summon<
19-
RecursiveRequired<Parsed>
20-
>() satisfies RecursiveRequired<PerseusImageBackground>;
10+
describe("the PerseusImageBackground parser", () => {
11+
it("should return the type defined in data-schema.ts", () => {
12+
expect(parsePerseusImageBackground({}, ctx())).type.toBe<
13+
ParseResult<PerseusImageBackground>
14+
>();
15+
});
16+
});
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
// FIXME: update these tests to use tstyche. Follow the example of other tests
2-
// in this directory that import tstyche.
1+
import {describe, it, expect} from "tstyche";
32

4-
import {summon} from "../general-purpose-parsers/test-helpers";
3+
import {ctx} from "../general-purpose-parsers/test-helpers";
54

6-
import type {parsePerseusImageDetail} from "./perseus-image-detail";
7-
import type {PerseusImageDetail} from "../../data-schema";
8-
import type {RecursiveRequired} from "../general-purpose-parsers/test-helpers";
9-
import type {ParsedValue} from "../parser-types";
10-
11-
type Parsed = ParsedValue<typeof parsePerseusImageDetail>;
5+
import {parsePerseusImageDetail} from "./perseus-image-detail";
126

13-
summon<Parsed>() satisfies PerseusImageDetail;
14-
summon<PerseusImageDetail>() satisfies Parsed;
7+
import type {PerseusImageDetail} from "../../data-schema";
8+
import type {ParseResult} from "../parser-types";
159

16-
// The `RecursiveRequired` test ensures that any new optional properties added
17-
// to the types in data-schema.ts are also added to the parser.
18-
summon<
19-
RecursiveRequired<Parsed>
20-
>() satisfies RecursiveRequired<PerseusImageDetail>;
10+
describe("the PerseusImageDetail parser", () => {
11+
it("should return the type defined in data-schema.ts", () => {
12+
expect(parsePerseusImageDetail({}, ctx())).type.toBe<
13+
ParseResult<PerseusImageDetail>
14+
>();
15+
});
16+
});

0 commit comments

Comments
 (0)