1
1
import { getCanonicalQuery } from "./getCanonicalQuery" ;
2
2
import { HttpRequest } from "@aws-sdk/protocol-http" ;
3
3
4
- const request = new HttpRequest ( {
4
+ const httpRequestOptions = {
5
5
method : "POST" ,
6
6
protocol : "https:" ,
7
7
path : "/" ,
8
8
headers : { } ,
9
9
hostname : "foo.us-east-1.amazonaws.com"
10
- } ) ;
10
+ } ;
11
11
12
12
describe ( "getCanonicalQuery" , ( ) => {
13
13
it ( "should return an empty string for requests with no querystring" , ( ) => {
14
- expect ( getCanonicalQuery ( request ) ) . toBe ( "" ) ;
14
+ expect ( getCanonicalQuery ( new HttpRequest ( httpRequestOptions ) ) ) . toBe ( "" ) ;
15
15
} ) ;
16
16
17
17
it ( "should serialize simple key => value pairs" , ( ) => {
18
18
expect (
19
19
getCanonicalQuery (
20
20
new HttpRequest ( {
21
- ...request ,
21
+ ...httpRequestOptions ,
22
22
query : { fizz : "buzz" , foo : "bar" }
23
23
} )
24
24
)
@@ -29,7 +29,7 @@ describe("getCanonicalQuery", () => {
29
29
expect (
30
30
getCanonicalQuery (
31
31
new HttpRequest ( {
32
- ...request ,
32
+ ...httpRequestOptions ,
33
33
query : { foo : "bar" , baz : "quux" , fizz : "buzz" }
34
34
} )
35
35
)
@@ -40,7 +40,7 @@ describe("getCanonicalQuery", () => {
40
40
expect (
41
41
getCanonicalQuery (
42
42
new HttpRequest ( {
43
- ...request ,
43
+ ...httpRequestOptions ,
44
44
query : { "🐎" : "🦄" , "💩" : "☃️" }
45
45
} )
46
46
)
@@ -51,7 +51,7 @@ describe("getCanonicalQuery", () => {
51
51
expect (
52
52
getCanonicalQuery (
53
53
new HttpRequest ( {
54
- ...request ,
54
+ ...httpRequestOptions ,
55
55
query : {
56
56
"x-amz-signature" : "foo" ,
57
57
"X-Amz-Signature" : "bar" ,
@@ -66,7 +66,7 @@ describe("getCanonicalQuery", () => {
66
66
expect (
67
67
getCanonicalQuery (
68
68
new HttpRequest ( {
69
- ...request ,
69
+ ...httpRequestOptions ,
70
70
query : { foo : [ "bar" , "baz" ] }
71
71
} )
72
72
)
@@ -77,7 +77,7 @@ describe("getCanonicalQuery", () => {
77
77
expect (
78
78
getCanonicalQuery (
79
79
new HttpRequest ( {
80
- ...request ,
80
+ ...httpRequestOptions ,
81
81
query : { snap : [ "pop" , "crackle" ] }
82
82
} )
83
83
)
@@ -88,7 +88,7 @@ describe("getCanonicalQuery", () => {
88
88
expect (
89
89
getCanonicalQuery (
90
90
new HttpRequest ( {
91
- ...request ,
91
+ ...httpRequestOptions ,
92
92
query : { "🐎" : [ "💩" , "🦄" ] }
93
93
} )
94
94
)
@@ -99,7 +99,7 @@ describe("getCanonicalQuery", () => {
99
99
expect (
100
100
getCanonicalQuery (
101
101
new HttpRequest ( {
102
- ...request ,
102
+ ...httpRequestOptions ,
103
103
query : { foo : "bar" , baz : new Uint8Array ( 0 ) as any }
104
104
} )
105
105
)
0 commit comments