@@ -32,6 +32,10 @@ describe('TypeScript Mongo', () => {
3232 nullableEmbedded: [EmbeddedType] @embedded
3333 mappedEmbedded: EmbeddedType @embedded @map(path: "innerEmbedded.moreLevel")
3434 changeName: String @column @map(path: "other_name")
35+ nonNullableColumnMap: String! @column @map(path: "nonNullableColumn")
36+ nullableLinkMap: LinkType @link @map(path: "nullableLinkId")
37+ nullableColumnMapPath: String @column @map(path: "nullableColumnMap.level")
38+ nonNullableColumnMapPath: String! @column @map(path: "nonNullableColumnMap.level")
3539 }
3640
3741 type EmbeddedType @entity {
@@ -229,18 +233,28 @@ describe('TypeScript Mongo', () => {
229233
230234 it ( 'Should output the correct values for @map directive' , async ( ) => {
231235 const result = await plugin ( schema , [ ] , { } , { outputFile : '' } ) ;
232- expect ( result ) . toContain ( `myInnerArray: Maybe<Array<Maybe<number>>>` ) ; // simple @column with array and @map
233- expect ( result ) . toContain ( `other_name: Maybe<string>` ) ; // simple @map scalar
236+ expect ( result ) . toContain ( `myInnerArray? : Maybe<Array<Maybe<number>>>` ) ; // simple @column with array and @map
237+ expect ( result ) . toContain ( `other_name? : Maybe<string>` ) ; // simple @map scalar
234238 expect ( result ) . toBeSimilarStringTo ( `
235239 profile: {
236240 inner: {
237- field: Maybe<string>,
241+ field? : Maybe<string>,
238242 },
239243 },` ) ; // custom @map with inner fields
240244 expect ( result ) . toBeSimilarStringTo ( `
241245 innerEmbedded: {
242- moreLevel: Maybe<EmbeddedTypeDbObject>,
246+ moreLevel? : Maybe<EmbeddedTypeDbObject>,
243247 },` ) ; // embedded with @map
248+ expect ( result ) . toContain ( `nonNullableColumn: string` ) ; // simple @column with @map
249+ expect ( result ) . toContain ( `nullableLinkId?: Maybe<LinkTypeDbObject['_id']>` ) ; // nullable @link with @map
250+ expect ( result ) . toBeSimilarStringTo ( `
251+ nullableColumnMap: {
252+ level?: Maybe<string>,
253+ },` ) ; // map with ;
254+ expect ( result ) . toBeSimilarStringTo ( `
255+ nonNullableColumnMap: {
256+ level: string,
257+ },` ) ;
244258 await validate ( result , schema , { } ) ;
245259 } ) ;
246260
0 commit comments