-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathrenderInterfaceProperty.test.ts
33 lines (28 loc) · 1.15 KB
/
renderInterfaceProperty.test.ts
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
import renderInterfaceProperty from "../../../src/renderers/typescript/renderInterfaceProperty"
describe("renderInterfaceProperty()", () => {
it("works with unrequired properties", () => {
expect(renderInterfaceProperty("property", "type", false, false, false).trim()).toMatchInlineSnapshot(
`"property?: type | undefined;"`,
)
})
it("works with required properties", () => {
expect(renderInterfaceProperty("property", "type", true, false, false).trim()).toMatchInlineSnapshot(
`"property: type;"`,
)
})
it("adds descriptions", () => {
expect(renderInterfaceProperty("property", "type", false, false, false,"Description").trim())
.toMatchInlineSnapshot(`
"/** Description */
property?: type | undefined;"
`)
})
it("supports localized fields", () => {
expect(renderInterfaceProperty("property", "type", false, true, true).trim()).toMatchInlineSnapshot(
`"property?: LocalizedField<type> | undefined;"`,
)
expect(renderInterfaceProperty("property", "type", false, true, false).trim()).toMatchInlineSnapshot(
`"property?: DefaultLocalizedField<type> | undefined;"`,
)
})
})