-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-component-property-definitions.test.ts
More file actions
41 lines (35 loc) · 1.21 KB
/
get-component-property-definitions.test.ts
File metadata and controls
41 lines (35 loc) · 1.21 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
import { describe, expect, test } from 'bun:test'
import { getComponentPropertyDefinitions } from '../get-component-property-definitions'
describe('getComponentPropertyDefinitions', () => {
test('returns definitions from a valid node', () => {
const defs = {
status: {
type: 'VARIANT',
defaultValue: 'active',
variantOptions: ['active', 'inactive'],
},
}
const node = {
componentPropertyDefinitions: defs,
} as unknown as ComponentSetNode
expect(getComponentPropertyDefinitions(node)).toBe(
defs as ComponentPropertyDefinitions,
)
})
test('returns empty object when node is null', () => {
expect(getComponentPropertyDefinitions(null)).toEqual({})
})
test('returns empty object when node is undefined', () => {
expect(getComponentPropertyDefinitions(undefined)).toEqual({})
})
test('returns empty object when getter throws', () => {
const node = {
get componentPropertyDefinitions(): never {
throw new Error(
'in get_componentPropertyDefinitions: Component set has existing errors',
)
},
} as unknown as ComponentSetNode
expect(getComponentPropertyDefinitions(node)).toEqual({})
})
})