@quatrain/core 1.2.14 → 1.2.15
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.
package/package.json
CHANGED
|
@@ -71,4 +71,43 @@ describe('Object Uri', () => {
|
|
|
71
71
|
uri.collection = 'collection'
|
|
72
72
|
expect(uri.collection).toBe('collection')
|
|
73
73
|
})
|
|
74
|
+
|
|
75
|
+
test('exceptions and error boundaries', () => {
|
|
76
|
+
// 1. Odd number of path parts (> 1) and not a file
|
|
77
|
+
expect(() => new ObjectUri('part1/part2/part3')).toThrow("Path parts number must be 1 or even")
|
|
78
|
+
|
|
79
|
+
const uri = new ObjectUri('collection/uid')
|
|
80
|
+
|
|
81
|
+
// 2. class setter/getter
|
|
82
|
+
uri.class = { name: 'MyClass' }
|
|
83
|
+
expect(uri.collection).toBe('myclass')
|
|
84
|
+
expect(uri.class).toEqual({ name: 'MyClass' })
|
|
85
|
+
|
|
86
|
+
uri.class = null
|
|
87
|
+
expect(uri.collection).toBeUndefined()
|
|
88
|
+
|
|
89
|
+
// 3. ownPath getter
|
|
90
|
+
const parentUri = new ObjectUri('collection1/uid1/collection2/uid2')
|
|
91
|
+
expect(parentUri.ownPath).toBe('collection2/uid2')
|
|
92
|
+
|
|
93
|
+
// 4. collection setter exception
|
|
94
|
+
const lockedUri = new ObjectUri('collection/uid')
|
|
95
|
+
expect(() => { lockedUri.collection = 'new-collection' }).toThrow('Collection value already set')
|
|
96
|
+
|
|
97
|
+
// 5. toReference and toJSON
|
|
98
|
+
const refUri = new ObjectUri('@s3:collection/uid', 'my label')
|
|
99
|
+
refUri.path = 'collection/uid'
|
|
100
|
+
expect(refUri.toReference()).toEqual({
|
|
101
|
+
ref: 'collection/uid',
|
|
102
|
+
uri: '@s3:collection/uid',
|
|
103
|
+
label: 'my label'
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
expect(refUri.toJSON()).toEqual({
|
|
107
|
+
ref: 'collection/uid',
|
|
108
|
+
label: 'my label',
|
|
109
|
+
backend: '@s3'
|
|
110
|
+
})
|
|
111
|
+
})
|
|
74
112
|
})
|
|
113
|
+
|