Skip to content

Commit 43fe4b6

Browse files
committed
Test hybrid object
1 parent 644383f commit 43fe4b6

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

package/src/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
import { testHybridObject } from './test/TestHybridObject'
2+
13
export * from './FilamentView'
4+
5+
const TEST_HYBRID_OBJECT = true
6+
if (__DEV__ && TEST_HYBRID_OBJECT) {
7+
testHybridObject()
8+
}

package/src/test/TestHybridObject.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,38 @@ interface TestHybridObject {
1010
createNewHybridObject: () => TestHybridObject
1111
}
1212

13-
const hybridObject = FilamentProxy.createTestObject() as TestHybridObject
14-
console.log(hybridObject.int)
13+
export function testHybridObject() {
14+
console.log('------ BEGIN HybridObject tests...')
15+
// 1. Creation
16+
console.log('Creating HybridObject...')
17+
const hybridObject = FilamentProxy.createTestObject() as TestHybridObject
18+
console.log('Created HybridObject!')
19+
20+
// 2. Logging the entire thing as JSON
21+
console.log(hybridObject)
22+
23+
// 3. Int Getter & Setter
24+
console.log(`Int: ${hybridObject.int}`)
25+
hybridObject.int = 6723
26+
console.log(`New Int: ${hybridObject.int}`)
27+
28+
// 4. String Getter & Setter
29+
console.log(`String: ${hybridObject.string}`)
30+
hybridObject.string = 'new string value!'
31+
console.log(`New String: ${hybridObject.string}`)
32+
33+
// 5. Testing multiple arguments and maps
34+
const result = hybridObject.multipleArguments(5, true, 'hahah!')
35+
console.log(`multipleArguments() -> ${JSON.stringify(result)}`)
36+
37+
// 6. Testing callbacks
38+
hybridObject.sayHelloCallback(() => 'hello from JS!')
39+
const getter = hybridObject.getIntGetter()
40+
console.log(`Int getter: ${getter()}`)
41+
42+
// 7. Create a new one
43+
const newObject = hybridObject.createNewHybridObject()
44+
console.log(`Created new hybrid object!`, newObject)
45+
46+
console.log('------ END HybridObject tests!')
47+
}

0 commit comments

Comments
 (0)