File tree Expand file tree Collapse file tree 6 files changed +44
-2
lines changed Expand file tree Collapse file tree 6 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,5 @@ package-lock.json
11
11
12
12
* .d.ts
13
13
* .js
14
+ ! jest.config.js
14
15
* .js.map
Original file line number Diff line number Diff line change 2
2
/docs /
3
3
tsconfig.test.json
4
4
* .tsbuildinfo
5
+ jest.config.js
Original file line number Diff line number Diff line change
1
+ import { S3 } from "./S3" ;
2
+ import { SerializeMiddleware } from "@aws-sdk/types" ;
3
+ import { HttpRequest } from "@aws-sdk/protocol-http" ;
4
+
5
+ describe ( "endpoint" , ( ) => {
6
+ it ( "users can override endpoint from client." , async ( ) => {
7
+ //use s3 here but all the clients are generated similarly
8
+ const endpointValidator : SerializeMiddleware < any , any > = next => args => {
9
+ // middleware intercept the request and return it early
10
+ const request = args . request as HttpRequest ;
11
+ expect ( request . protocol ) . toEqual ( "http:" ) ;
12
+ expect ( request . hostname ) . toEqual ( "localhost" ) ;
13
+ expect ( request . port ) . toEqual ( 8080 ) ;
14
+ expect ( request . query ) . toEqual ( { foo : "bar" } ) ;
15
+ expect ( request . path ) . toEqual ( "/path" ) ;
16
+ return Promise . resolve ( { output : { } as any , response : { } as any } ) ;
17
+ } ;
18
+ const client = new S3 ( { endpoint : "http://localhost:8080/path?foo=bar" } ) ;
19
+ client . middlewareStack . add ( endpointValidator , {
20
+ step : "serialize" ,
21
+ name : "endpointValidator" ,
22
+ priority : "low"
23
+ } ) ;
24
+ await client . putObject ( { Bucket : "bucket" , Key : "key" , Body : "body" } ) ;
25
+ } ) ;
26
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const base = require ( "../../jest.config.base.js" ) ;
2
+
3
+ module . exports = {
4
+ ...base ,
5
+ // Only test cjs dist, avoid testing the package twice
6
+ testPathIgnorePatterns : [ "/node_modules/" , "/es/" ] ,
7
+ coveragePathIgnorePatterns : [
8
+ "/node_modules/" ,
9
+ "/commands/" ,
10
+ "/protocols/" , // protocols tested in protocol protocol_tests folder
11
+ "endpoints" // endpoint tested in tests/functional/endpoints
12
+ ]
13
+ } ;
Original file line number Diff line number Diff line change 12
12
"remove-documentation" : " rimraf ./docs" ,
13
13
"remove-js" : " rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js" ,
14
14
"remove-maps" : " rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map" ,
15
- "test" : " exit 0 " ,
15
+ "test" : " jest --passWithNoTests " ,
16
16
"smoke-test" : " npm run pretest && node ./test/smoke/index.spec.js" ,
17
17
"build:es" : " tsc -p tsconfig.es.json" ,
18
18
"build" : " yarn pretest && yarn build:es"
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ module.exports = {
4
4
...base ,
5
5
projects : [
6
6
"<rootDir>/protocol_tests/*/jest.config.js" ,
7
- "<rootDir>/packages/*/jest.config.js"
7
+ "<rootDir>/packages/*/jest.config.js" ,
8
+ "<rootDir>/clients/*/jest.config.js"
8
9
] ,
9
10
testPathIgnorePatterns : [ "/node_modules/" , "<rootDir>/clients/client-.*" ] ,
10
11
coveragePathIgnorePatterns : [
You can’t perform that action at this time.
0 commit comments