23
23
import * as BSON from "bson" ;
24
24
import Realm from "realm" ;
25
25
26
+ // Simple Unmanaged remapping tests
27
+ type MyObj = {
28
+ stringProp1 : Realm . Types . String ;
29
+ stringProp2 : Realm . Types . String ;
30
+ nullableStringProp1 : Realm . Types . String | null ;
31
+ nullableStringProp2 : Realm . Types . String | null ;
32
+ stringOrUndefined1 ?: Realm . Types . String ;
33
+ stringOrUndefined2 ?: Realm . Types . String ;
34
+
35
+ listStringProp1 : Realm . Types . List < Realm . Types . String > ;
36
+ listStringProp2 : Realm . Types . List < Realm . Types . String > ;
37
+ listStringProp3 : Realm . Types . List < Realm . Types . String > ;
38
+ nullableListStringProp1 : Realm . Types . List < Realm . Types . String > | null ;
39
+ nullableListStringProp2 : Realm . Types . List < Realm . Types . String > | null ;
40
+ nullableListStringProp3 : Realm . Types . List < Realm . Types . String > | null ;
41
+ listStringOrUndefinedProp1 ?: Realm . Types . List < Realm . Types . String > ;
42
+ listStringOrUndefinedProp2 ?: Realm . Types . List < Realm . Types . String > ;
43
+ listStringOrUndefinedProp3 ?: Realm . Types . List < Realm . Types . String > ;
44
+ } ;
45
+ const test : Realm . Unmanaged < MyObj > = {
46
+ stringProp1 : "test" ,
47
+ // @ts -expect-error - Expected: invalid
48
+ stringProp2 : null ,
49
+ nullableStringProp1 : null ,
50
+ nullableStringProp2 : "blah" ,
51
+ stringOrUndefined1 : undefined ,
52
+ stringOrUndefined2 : "sad" ,
53
+
54
+ someExtraPropertyNotSpecifiedOnMyObj : "string" ,
55
+
56
+ listStringProp1 : [ "test" ] ,
57
+ // @ts -expect-error - Expected: invalid
58
+ listStringProp2 : [ 1 ] ,
59
+ // @ts -expect-error - Expected: invalid
60
+ listStringProp3 : null ,
61
+ nullableListStringProp1 : null ,
62
+ nullableListStringProp2 : [ "test" ] ,
63
+ // @ts -expect-error - Expected: invalid
64
+ nullableListStringProp3 : [ 1 ] ,
65
+ listStringOrUndefinedProp1 : undefined ,
66
+ listStringOrUndefinedProp2 : [ "test" ] ,
67
+ // @ts -expect-error - Expected: invalid
68
+ listStringOrUndefinedProp3 : [ 1 ] ,
69
+ } ;
70
+ test ;
71
+
72
+ // Extended functionality tests (ensure RequiredProperties work)
26
73
class RealmClassWithRequiredParams extends Realm . Object <
27
74
RealmClassWithRequiredParams ,
28
75
| "aMandatoryString"
@@ -120,10 +167,12 @@ const realm = new Realm({ schema: [RealmClassWithRequiredParams, RealmClassWitho
120
167
// @ts -expect-error - a String shouldn't be accepted as 'values'
121
168
new RealmClassWithRequiredParams ( realm , "this shouldn't be accepted" ) ;
122
169
123
- // FIXME - this doesn't error and it should
124
- // @xxxts -expect-error - a String shouldn't be accepted as 'values'
170
+ // TODO - this doesn't error and it should
171
+ // should-be-@ts -expect-error - a String shouldn't be accepted as 'values'
125
172
new RealmClassWithoutRequiredParams ( realm , "this shouldn't be accepted" ) ;
126
173
174
+ // Realm.create() tests
175
+
127
176
realm . write ( ( ) => {
128
177
// === Realm.Object classes ===
129
178
// @ts -expect-error - Empty object not allowed due to being required params
@@ -150,8 +199,8 @@ realm.write(() => {
150
199
realm . create ( RealmClassWithoutRequiredParams , new RealmClassWithoutRequiredParams ( realm , { } ) ) ;
151
200
152
201
// === Unmanaged objects ===
153
- // FIXME - Should this be erroring? The class has required types so shouldn't they be automatically required in the Unmanaged version too? Is this possible
154
- // @xxxts -expect-error - Empty object not allowed due to being required params
202
+ // TODO - Should this be erroring? The class has required types so shouldn't they be automatically required in the Unmanaged version too? Is this possible
203
+ // should-be-@ts -expect-error - Empty object not allowed due to being required params
155
204
realm . create ( RealmClassWithRequiredParams , { } ) ;
156
205
157
206
realm . create ( RealmClassWithRequiredParams , {
0 commit comments