@@ -33,6 +33,36 @@ const docItem = new Server(doc.production, { asyncapi: {} as any, pointer: '', i
3333const emptyItem = new Server ( serializeInput < v3 . ServerObject > ( { } ) , { asyncapi : { } as any , pointer : '' , id : '' } ) ;
3434
3535describe ( 'Server Model' , function ( ) {
36+ describe ( '.title() and .summary()' , function ( ) {
37+ it ( 'should return title and summary from ServerObject' , function ( ) {
38+ const doc = serializeInput < v3 . ServerObject > ( {
39+ host : 'example.com' ,
40+ protocol : 'https' ,
41+ title : 'Production Server' ,
42+ summary : 'Production environment server' ,
43+ } ) ;
44+ const d = new Server ( doc , { asyncapi : { } as any , pointer : '/servers/production' , id : 'production' } ) ;
45+ expect ( d . hasTitle ( ) ) . toEqual ( true ) ;
46+ expect ( d . title ( ) ) . toEqual ( 'Production Server' ) ;
47+ expect ( d . hasSummary ( ) ) . toEqual ( true ) ;
48+ expect ( d . summary ( ) ) . toEqual ( 'Production environment server' ) ;
49+ expect ( d . json ( ) . title ) . toEqual ( 'Production Server' ) ;
50+ expect ( d . json ( ) . summary ) . toEqual ( 'Production environment server' ) ;
51+ } ) ;
52+
53+ it ( 'should return false and undefined when title and summary are absent' , function ( ) {
54+ const doc = serializeInput < v3 . ServerObject > ( {
55+ host : 'example.com' ,
56+ protocol : 'https' ,
57+ } ) ;
58+ const d = new Server ( doc , { asyncapi : { } as any , pointer : '/servers/production' , id : 'production' } ) ;
59+ expect ( d . hasTitle ( ) ) . toEqual ( false ) ;
60+ expect ( d . title ( ) ) . toBeUndefined ( ) ;
61+ expect ( d . hasSummary ( ) ) . toEqual ( false ) ;
62+ expect ( d . summary ( ) ) . toBeUndefined ( ) ;
63+ } ) ;
64+ } ) ;
65+
3666 describe ( '.id()' , function ( ) {
3767 it ( 'should return name if present' , function ( ) {
3868 expect ( docItem . id ( ) ) . toEqual ( 'production' ) ;
0 commit comments