-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.test.js
50 lines (34 loc) · 1.1 KB
/
variables.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { substituteString, convertHeaders} from "./variables";
test('var substitution', ()=>{
let str = "http://{{address}}:{{port}}";
const dict = new Map();
dict.set("address", "foo");
dict.set("port", "12345");
dict.set("nothere", "not in use");
let result = substituteString(str, dict);
expect(result).toBe("http://foo:12345");
});
test('var substitution with unknowns', ()=>{
let str = "http://{{address}}:{{port}}/{{notfound}}";
const dict = new Map();
dict.set("address", "foo");
dict.set("port", "12345");
dict.set("nothere", "not in use");
let result = substituteString(str, dict);
expect(result).toBe("http://foo:12345/{{notfound}}");
});
test('keyvalue headers', () => {
let headers = [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Parameter",
"value": "someValue"
}
];
let dict = convertHeaders(headers);
expect(dict["Content-Type"]).toBe("application/json");
expect(dict["Parameter"]).toBe("someValue");
});