-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathrenderFieldsOnly.test.ts
More file actions
67 lines (63 loc) · 1.73 KB
/
renderFieldsOnly.test.ts
File metadata and controls
67 lines (63 loc) · 1.73 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
import renderFieldsOnly from "../../src/renderers/renderFieldsOnly"
import { ContentType, Sys } from "contentful"
describe("renderFieldsOnly()", () => {
const contentTypes: ContentType[] = [
{
sys: {
id: "myContentType",
} as Sys,
fields: [
{
id: "arrayField",
name: "Array field",
required: true,
validations: [{}],
items: {
type: "Symbol",
validations: [
{
in: ["one", "of", "the", "above"],
},
],
},
disabled: false,
omitted: false,
localized: false,
type: "Array",
},
],
description: "",
displayField: "",
name: "",
toPlainObject: () => ({} as ContentType),
},
]
it("renders a given content type", async () => {
expect(await renderFieldsOnly(contentTypes)).toMatchInlineSnapshot(`
"export interface IMyContentType {
fields: {
/** Array field */
arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[]
}
[otherKeys: string]: unknown
}
"
`)
})
it("renders a given content type inside a namespace", async () => {
expect(await renderFieldsOnly(contentTypes, { namespace: "Codegen" })).toMatchInlineSnapshot(`
"declare namespace Codegen {
export interface IMyContentType {
fields: {
/** Array field */
arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[]
}
[otherKeys: string]: unknown
}
}
export as namespace Codegen
export = Codegen
"
`)
})
})