@@ -16,35 +16,66 @@ describe('externalValue', () => {
16
16
} ) ;
17
17
18
18
beforeEach ( ( ) => {
19
- externalValue . clearCache ( )
19
+ externalValue . clearCache ( ) ;
20
20
} ) ;
21
21
22
22
describe ( 'ExternalValueError' , ( ) => {
23
23
test ( 'should contain the externalValue error details' , ( ) => {
24
24
try {
25
25
throw new externalValue . ExternalValueError ( 'Probe' , {
26
26
externalValue : 'http://test.com/probe' ,
27
- fullPath : " probe" ,
27
+ fullPath : ' probe' ,
28
28
} ) ;
29
29
} catch ( e ) {
30
30
expect ( e . toString ( ) ) . toEqual ( 'ExternalValueError: Probe' ) ;
31
31
expect ( e . externalValue ) . toEqual ( 'http://test.com/probe' ) ;
32
- expect ( e . fullPath ) . toEqual ( " probe" ) ;
32
+ expect ( e . fullPath ) . toEqual ( ' probe' ) ;
33
33
}
34
34
} ) ;
35
35
test ( '.wrapError should wrap an error in ExternalValueError' , ( ) => {
36
36
try {
37
37
throw externalValue . wrapError ( new Error ( 'hi' ) , {
38
38
externalValue : 'http://test.com/probe' ,
39
- fullPath : " probe" ,
39
+ fullPath : ' probe' ,
40
40
} ) ;
41
41
} catch ( e ) {
42
42
expect ( e . message ) . toMatch ( / e x t e r n a l V a l u e / ) ;
43
43
expect ( e . message ) . toMatch ( / h i / ) ;
44
44
expect ( e . externalValue ) . toEqual ( 'http://test.com/probe' ) ;
45
- expect ( e . fullPath ) . toEqual ( " probe" ) ;
45
+ expect ( e . fullPath ) . toEqual ( ' probe' ) ;
46
46
}
47
47
} ) ;
48
48
} ) ;
49
49
50
- } ) ;
50
+ describe ( 'externalValue Plugin value collision' , ( ) => {
51
+ const spec = {
52
+ paths : {
53
+ '/probe' : {
54
+ get : {
55
+ responses : {
56
+ 200 : {
57
+ content : {
58
+ '*/*' : {
59
+ examples : {
60
+ probe : {
61
+ externalValue : 'http://test.com/probe' ,
62
+ value : 'test'
63
+ } ,
64
+ } ,
65
+ } ,
66
+ } ,
67
+ } ,
68
+ } ,
69
+ } ,
70
+ } ,
71
+ } ,
72
+ } ;
73
+ test ( 'should skip resolution of externalValue if value is defined' , ( ) =>
74
+ mapSpec ( {
75
+ spec,
76
+ plugins : [ externalValue ] ,
77
+ } ) . then ( ( res ) => {
78
+ expect ( res . spec ) . toEqual ( spec ) ;
79
+ } ) ) ;
80
+ } ) ;
81
+ } ) ;
0 commit comments