| 172 | } |
| 173 | |
| 174 | async function createWithSubdocs() { |
| 175 | const schema = new Schema({ |
| 176 | name: String, |
| 177 | subdoc: new Schema({ |
| 178 | prop: { type: String, required: true }, |
| 179 | otherProp: { type: String, required: true } |
| 180 | }) |
| 181 | }); |
| 182 | const TestModel = model('Test', schema); |
| 183 | |
| 184 | const doc = await TestModel.create({ name: 'test', subdoc: { prop: 'test 1' } }); |
| 185 | expect(doc.name).type.toBe<string | null | undefined>(); |
| 186 | expect(doc.subdoc!.prop).type.toBe<string>(); |
| 187 | expect(doc.subdoc!.otherProp).type.toBe<string>(); |
| 188 | } |
| 189 | |
| 190 | async function createWithRawDocTypeNo_id() { |
| 191 | interface RawDocType { |