@@ -15,7 +15,7 @@ describe('#parseServerVariableObject', () => {
1515 it ( 'provides warning when server variable is non-object' , ( ) => {
1616 const serverVariable = new namespace . elements . String ( ) ;
1717
18- const parseResult = parse ( context ) ( serverVariable ) ;
18+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
1919
2020 expect ( parseResult . length ) . to . equal ( 1 ) ;
2121 expect ( parseResult ) . to . contain . warning ( "'Server Variable Object' is not an object" ) ;
@@ -26,7 +26,7 @@ describe('#parseServerVariableObject', () => {
2626 const serverVariable = new namespace . elements . Object ( {
2727 } ) ;
2828
29- const parseResult = parse ( context ) ( serverVariable ) ;
29+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
3030 expect ( parseResult . length ) . to . equal ( 1 ) ;
3131 expect ( parseResult ) . to . contain . warning ( "'Server Variable Object' is missing required property 'default'" ) ;
3232 } ) ;
@@ -37,7 +37,7 @@ describe('#parseServerVariableObject', () => {
3737 description : 'API user name' ,
3838 } ) ;
3939
40- const parseResult = parse ( context ) ( serverVariable ) ;
40+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
4141 expect ( parseResult ) . to . contain . error ( "'Server Variable Object' 'default' is not a string" ) ;
4242 } ) ;
4343
@@ -46,12 +46,13 @@ describe('#parseServerVariableObject', () => {
4646 default : 'Mario' ,
4747 } ) ;
4848
49- const parseResult = parse ( context ) ( serverVariable ) ;
49+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
5050 expect ( parseResult ) . to . not . contain . annotations ;
5151
5252 const member = parseResult . get ( 0 ) ;
53- expect ( member ) . to . be . instanceof ( namespace . elements . String ) ;
54- expect ( member . attributes . get ( 'default' ) . toValue ( ) ) . to . be . equal ( 'Mario' ) ;
53+ expect ( member ) . to . be . instanceof ( namespace . elements . Member ) ;
54+ expect ( member . value ) . to . be . instanceof ( namespace . elements . String ) ;
55+ expect ( member . value . attributes . get ( 'default' ) . toValue ( ) ) . to . be . equal ( 'Mario' ) ;
5556 } ) ;
5657 } ) ;
5758
@@ -62,22 +63,24 @@ describe('#parseServerVariableObject', () => {
6263 description : 1234 ,
6364 } ) ;
6465
65- const parseResult = parse ( context ) ( serverVariable ) ;
66- expect ( parseResult . get ( 0 ) ) . to . be . instanceof ( namespace . elements . String ) ;
66+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
67+ expect ( parseResult . get ( 0 ) ) . to . be . instanceof ( namespace . elements . Member ) ;
68+ expect ( parseResult . get ( 0 ) . value ) . to . be . instanceof ( namespace . elements . String ) ;
69+ expect ( parseResult . get ( 1 ) ) . to . be . instanceof ( namespace . elements . Annotation ) ;
6770 expect ( parseResult ) . to . contain . warning ( "'Server Variable Object' 'description' is not a string" ) ;
6871 } ) ;
6972
70- it ( 'parse server variable object with description ' , ( ) => {
73+ it ( 'attaches description to member ' , ( ) => {
7174 const serverVariable = new namespace . elements . Object ( {
7275 default : 'Mario' ,
7376 description : 'API user name' ,
7477 } ) ;
7578
76- const parseResult = parse ( context ) ( serverVariable ) ;
79+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
7780 expect ( parseResult ) . to . not . contain . annotations ;
7881
7982 const member = parseResult . get ( 0 ) ;
80- expect ( member ) . to . be . instanceof ( namespace . elements . String ) ;
83+ expect ( member ) . to . be . instanceof ( namespace . elements . Member ) ;
8184
8285 const description = member . description . toValue ( ) ;
8386 expect ( description ) . to . be . equal ( 'API user name' ) ;
@@ -90,7 +93,7 @@ describe('#parseServerVariableObject', () => {
9093 default : 'Mario' ,
9194 enum : 1 ,
9295 } ) ;
93- const parseResult = parse ( context ) ( serverVariable ) ;
96+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
9497
9598 expect ( parseResult ) . to . contain . warning (
9699 "'Server Variable Object' 'enum' is not an array"
@@ -103,13 +106,14 @@ describe('#parseServerVariableObject', () => {
103106 enum : [ 'Tony' , 'Nina' ] ,
104107 } ) ;
105108
106- const parseResult = parse ( context ) ( serverVariable ) ;
109+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
107110 expect ( parseResult ) . to . not . contain . annotations ;
108111
109- const enumElement = parseResult . get ( 0 ) ;
110- expect ( enumElement ) . to . be . instanceof ( namespace . elements . Enum ) ;
112+ const member = parseResult . get ( 0 ) ;
113+ expect ( member ) . to . be . instanceof ( namespace . elements . Member ) ;
114+ expect ( member . value ) . to . be . instanceof ( namespace . elements . Enum ) ;
111115
112- const { enumerations } = enumElement ;
116+ const { enumerations } = member . value ;
113117 expect ( enumerations ) . to . be . instanceof ( namespace . elements . Array ) ;
114118 expect ( enumerations . length ) . to . equal ( 2 ) ;
115119 expect ( enumerations . toValue ( ) ) . to . deep . equal ( [ 'Tony' , 'Nina' ] ) ;
@@ -125,17 +129,18 @@ describe('#parseServerVariableObject', () => {
125129 enum : [ 'Tony' , 1 , 'Nina' , true ] ,
126130 } ) ;
127131
128- const parseResult = parse ( context ) ( serverVariable ) ;
132+ const parseResult = parse ( context ) ( serverVariable , 'name' ) ;
129133 expect ( parseResult ) . to . contain . annotations ;
130134
131135 const { annotations } = parseResult ;
132136 expect ( annotations . length ) . to . equal ( 2 ) ;
133137 expect ( annotations . get ( 0 ) . toValue ( ) ) . to . deep . equal ( "'Server Variable Object' 'enum' array value is not a string" ) ;
134138
135- const enumElement = parseResult . get ( 0 ) ;
136- expect ( enumElement ) . to . be . instanceof ( namespace . elements . Enum ) ;
139+ const member = parseResult . get ( 0 ) ;
140+ expect ( member ) . to . be . instanceof ( namespace . elements . Member ) ;
141+ expect ( member . value ) . to . be . instanceof ( namespace . elements . Enum ) ;
137142
138- const { enumerations } = enumElement ;
143+ const { enumerations } = member . value ;
139144 expect ( enumerations ) . to . be . instanceof ( namespace . elements . Array ) ;
140145 expect ( enumerations . length ) . to . equal ( 2 ) ;
141146 expect ( enumerations . toValue ( ) ) . to . deep . equal ( [ 'Tony' , 'Nina' ] ) ;
0 commit comments