@@ -32,22 +32,28 @@ describe("EndpointsConfig", () => {
32
32
it ( "returns output of urlParser if endpoint is of type string" , async ( ) => {
33
33
const endpoint = "endpoint" ;
34
34
urlParser . mockReturnValueOnce ( mockEndpoint ) ;
35
- const endpointOutput = await resolveEndpointsConfig ( { ...input , endpoint } ) . endpoint ( ) ;
35
+ const { endpoint : endpointProvider , isCustomEndpoint } = resolveEndpointsConfig ( { ...input , endpoint } ) ;
36
+ expect ( isCustomEndpoint ) . toBe ( true ) ;
37
+ const endpointOutput = await endpointProvider ( ) ;
36
38
expect ( endpointOutput ) . toStrictEqual ( mockEndpoint ) ;
37
39
expect ( urlParser ) . toHaveBeenCalledTimes ( 1 ) ;
38
40
expect ( urlParser ) . toHaveBeenCalledWith ( endpoint ) ;
39
41
} ) ;
40
42
41
43
it ( "returns promisified endpoint if it's of type object" , async ( ) => {
42
44
const endpoint = mockEndpoint ;
43
- const endpointOutput = await resolveEndpointsConfig ( { ...input , endpoint } ) . endpoint ( ) ;
45
+ const { endpoint : endpointProvider , isCustomEndpoint } = resolveEndpointsConfig ( { ...input , endpoint } ) ;
46
+ expect ( isCustomEndpoint ) . toBe ( true ) ;
47
+ const endpointOutput = await endpointProvider ( ) ;
44
48
expect ( endpointOutput ) . toStrictEqual ( endpoint ) ;
45
49
expect ( urlParser ) . not . toHaveBeenCalled ( ) ;
46
50
} ) ;
47
51
48
52
it ( "returns endpoint if it's already Provider<Endpoint>" , async ( ) => {
49
53
const endpoint = ( ) => Promise . resolve ( mockEndpoint ) ;
50
- const endpointOutput = await resolveEndpointsConfig ( { ...input , endpoint } ) . endpoint ( ) ;
54
+ const { endpoint : endpointProvider , isCustomEndpoint } = resolveEndpointsConfig ( { ...input , endpoint } ) ;
55
+ expect ( isCustomEndpoint ) . toBe ( true ) ;
56
+ const endpointOutput = await endpointProvider ( ) ;
51
57
expect ( endpointOutput ) . toStrictEqual ( mockEndpoint ) ;
52
58
expect ( urlParser ) . not . toHaveBeenCalled ( ) ;
53
59
} ) ;
@@ -58,6 +64,11 @@ describe("EndpointsConfig", () => {
58
64
const mockHostname = "mockHostname" ;
59
65
const mockEndpoint : Endpoint = { protocol : "protocol" , hostname : "hostname" , path : "path" } ;
60
66
67
+ it ( "isCustomEndpoint should be false" , ( ) => {
68
+ const { isCustomEndpoint } = resolveEndpointsConfig ( { ...input } ) ;
69
+ expect ( isCustomEndpoint ) . toBe ( false ) ;
70
+ } ) ;
71
+
61
72
describe ( "returns endpoint" , ( ) => {
62
73
beforeEach ( ( ) => {
63
74
region . mockResolvedValueOnce ( mockRegion ) ;
0 commit comments