@@ -13,14 +13,38 @@ describe('extractSampleForParam', () => {
1313 expect ( extractSampleForParam ( { example : 'xxx' } , 'key' ) ) . toEqual ( 'xxx' )
1414 } )
1515
16+ it ( 'should extract value from example object with value field' , ( ) => {
17+ expect ( extractSampleForParam ( { example : { value : 'xxx' } } , 'key' ) ) . toEqual ( 'xxx' )
18+ } )
19+
20+ it ( 'should extract numeric value from example object with value field' , ( ) => {
21+ expect ( extractSampleForParam ( { example : { value : 42 } } , 'key' ) ) . toEqual ( 42 )
22+ } )
23+
1624 it ( 'should return example from schema' , ( ) => {
1725 expect ( extractSampleForParam ( { schema : { examples : [ 'xxx' ] } } , 'key' ) ) . toEqual ( 'xxx' )
1826 } )
1927
28+ it ( 'should extract value from schema examples object with value field' , ( ) => {
29+ expect ( extractSampleForParam ( { schema : { examples : [ { value : 'xxx' } ] } } , 'key' ) ) . toEqual ( 'xxx' )
30+ } )
31+
32+ it ( 'should return schema example if present' , ( ) => {
33+ expect ( extractSampleForParam ( { schema : { example : 'xxx' } } , 'key' ) ) . toEqual ( 'xxx' )
34+ } )
35+
36+ it ( 'should extract value from schema example object with value field' , ( ) => {
37+ expect ( extractSampleForParam ( { schema : { example : { value : 99 } } } , 'key' ) ) . toEqual ( 99 )
38+ } )
39+
2040 it ( 'should handle examples array' , ( ) => {
2141 expect ( extractSampleForParam ( { examples : [ 'xxx' ] } , 'key' ) ) . toEqual ( 'xxx' )
2242 } )
2343
44+ it ( 'should extract value from examples array object with value field' , ( ) => {
45+ expect ( extractSampleForParam ( { examples : [ { value : 'xxx' } ] } , 'key' ) ) . toEqual ( 'xxx' )
46+ } )
47+
2448 it ( 'should return first element of enum' , ( ) => {
2549 expect ( extractSampleForParam ( { enum : [ 'a' , 'b' ] } , 'key' ) ) . toEqual ( 'a' )
2650 } )
0 commit comments