File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ global . window = {
2
+ location : {
3
+ host : 'localhost:8081' ,
4
+ port : 8081 ,
5
+ protocol : 'http:'
6
+ }
7
+ } ;
8
+
9
+ var noop = function ( ) { } ;
10
+ global . window . XMLHttpRequest = function ( ) {
11
+ this . open = noop ;
12
+ this . send = noop ;
13
+ } ;
14
+
15
+ var test = require ( 'tape' ) . test ;
16
+ var http = require ( '../index.js' ) ;
17
+
18
+
19
+ test ( 'Test simple url string' , function ( t ) {
20
+ var url = { path : '/api/foo' } ;
21
+ var request = http . get ( url , noop ) ;
22
+
23
+ t . equal ( request . uri , 'http://localhost:8081/api/foo' , 'Url should be correct' ) ;
24
+ t . end ( ) ;
25
+
26
+ } ) ;
27
+
28
+
29
+ test ( 'Test full url object' , function ( t ) {
30
+ var url = {
31
+ host : "localhost:8081" ,
32
+ hostname : "localhost" ,
33
+ href : "http://localhost:8081/api/foo?bar=baz" ,
34
+ method : "GET" ,
35
+ path : "/api/foo?bar=baz" ,
36
+ pathname : "/api/foo" ,
37
+ port : "8081" ,
38
+ protocol : "http:" ,
39
+ query : "bar=baz" ,
40
+ search : "?bar=baz" ,
41
+ slashes : true
42
+ } ;
43
+
44
+ var request = http . get ( url , noop ) ;
45
+
46
+ t . equal ( request . uri , 'http://localhost:8081/api/foo?bar=baz' , 'Url should be correct' ) ;
47
+ t . end ( ) ;
48
+
49
+ } ) ;
You can’t perform that action at this time.
0 commit comments