@@ -116,7 +116,7 @@ const jsonSchema: StandardJSONSchema = {
116
116
required : [ 'name' , 'age' ]
117
117
} ;
118
118
119
- describe . only ( 'toTypescriptTypeDefinition' , function ( ) {
119
+ describe ( 'toTypescriptTypeDefinition' , function ( ) {
120
120
it ( 'converts a MongoDB JSON schema to TypeScript' , async function ( ) {
121
121
const databaseName = 'myDb' ;
122
122
const collectionName = 'myCollection' ;
@@ -125,7 +125,45 @@ describe.only('toTypescriptTypeDefinition', function() {
125
125
126
126
console . log ( inspect ( schema , { depth : null } ) ) ;
127
127
128
- assert . equal ( toTypescriptTypeDefinition ( databaseName , collectionName , schema ) , '' ) ;
128
+ assert . equal ( toTypescriptTypeDefinition ( databaseName , collectionName , schema ) , `module myDb {
129
+ type myCollection = {
130
+ _id?: bson.ObjectId;
131
+ array?: bson.Double[];
132
+ binaries?: {
133
+ binaryOld?: bson.Binary;
134
+ compressedTimeSeries?: bson.Binary;
135
+ custom?: bson.Binary;
136
+ encrypted?: bson.Binary;
137
+ functionData?: bson.Binary;
138
+ generic?: bson.Binary;
139
+ md5?: bson.Binary;
140
+ uuid?: bson.Binary;
141
+ uuidOld?: bson.Binary
142
+ };
143
+ binData?: bson.Binary;
144
+ boolean?: boolean;
145
+ date?: bson.Date;
146
+ dbRef?: bson.DBPointer;
147
+ decimal?: bson.Decimal128;
148
+ double?: bson.Double;
149
+ doubleThatIsAlsoAnInteger?: bson.Double;
150
+ int?: bson.Int32;
151
+ javascript?: bson.Code;
152
+ javascriptWithScope?: bson.Code;
153
+ long?: bson.Long;
154
+ maxKey?: bson.MaxKey;
155
+ minKey?: bson.MinKey;
156
+ null?: null;
157
+ object?: {
158
+ key?: string
159
+ };
160
+ objectId?: bson.ObjectId;
161
+ regex?: bson.BSONRegExp;
162
+ string?: string;
163
+ symbol?: bson.BSONSymbol;
164
+ timestamp?: bson.Timestamp
165
+ };
166
+ };` ) ;
129
167
} ) ;
130
168
131
169
it ( 'converts a standard JSON schema to TypeScript' , function ( ) {
@@ -134,6 +172,18 @@ describe.only('toTypescriptTypeDefinition', function() {
134
172
135
173
console . log ( inspect ( jsonSchema , { depth : null } ) ) ;
136
174
137
- assert . equal ( toTypescriptTypeDefinition ( databaseName , collectionName , jsonSchema ) , '' ) ;
175
+ assert . equal ( toTypescriptTypeDefinition ( databaseName , collectionName , jsonSchema ) , `module myDb {
176
+ type myCollection = {
177
+ name?: string;
178
+ age?: number;
179
+ address?: {
180
+ street?: string;
181
+ city?: string;
182
+ state?: string;
183
+ postalCode?: string
184
+ };
185
+ hobbies?: string[]
186
+ };
187
+ };` ) ;
138
188
} ) ;
139
189
} ) ;
0 commit comments