@@ -3,7 +3,6 @@ $(document).ready(function() {
33 module ( "Raven.config" ) ;
44
55 test ( "should parse dsn as only argument" , function ( ) {
6- // TODO: this test isnt isolated
76 var dsn = "http://public:secret@example.com:80/project-id" ;
87
98 Raven . config ( dsn ) ;
@@ -13,16 +12,43 @@ $(document).ready(function() {
1312 equal ( config [ 'secretKey' ] , 'secret' ) ;
1413 equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/api/project-id/store/' ) ;
1514 equal ( config [ 'projectId' ] , 'project-id' ) ;
15+ } ) ;
16+
17+ test ( "should accept servers as base URLs and add API info" , function ( ) {
18+ Raven . config ( {
19+ "publicKey" : "public" ,
20+ "servers" : [ "http://mysentry.com/" ] ,
21+ "projectId" : "project-id"
22+ } ) ;
23+
24+ var config = Raven . options ;
25+
26+ equal ( config [ 'publicKey' ] , 'public' ) ;
27+ equal ( config [ 'servers' ] [ 0 ] , 'http://mysentry.com/api/project-id/store/' ) ;
28+ equal ( config [ 'projectId' ] , 'project-id' ) ;
29+ } ) ;
30+
31+ test ( "should handle base URLs without a trailing slash" , function ( ) {
32+ Raven . config ( {
33+ "publicKey" : "public" ,
34+ "servers" : [ "http://mysentry.com" ] ,
35+ "projectId" : "project-id"
36+ } ) ;
37+
38+ var config = Raven . options ;
1639
40+ equal ( config [ 'publicKey' ] , 'public' ) ;
41+ equal ( config [ 'servers' ] [ 0 ] , 'http://mysentry.com/api/project-id/store/' ) ;
42+ equal ( config [ 'projectId' ] , 'project-id' ) ;
1743 } ) ;
1844
1945 module ( "Raven.parseHeaders" ) ;
2046
2147 test ( "should parse headers into an object" , function ( ) {
22- var hstring = "Date: Mon, 06 Feb 2012 17:25:42 GMT\n"
23- hstring += "Server: WSGIServer/0.1 Python/2.7.2\n"
24- hstring += "Vary: Cookie\n"
25- hstring += "Content-Type: text/html; charset=utf-8\n"
48+ var hstring = "Date: Mon, 06 Feb 2012 17:25:42 GMT\n" ;
49+ hstring += "Server: WSGIServer/0.1 Python/2.7.2\n" ;
50+ hstring += "Vary: Cookie\n" ;
51+ hstring += "Content-Type: text/html; charset=utf-8\n" ;
2652
2753 var headers = Raven . parseHeaders ( hstring ) ;
2854 equal ( headers [ 'Date' ] , "Mon, 06 Feb 2012 17:25:42 GMT" ) ;
@@ -51,7 +77,7 @@ $(document).ready(function() {
5177 var config = Raven . parseDSN ( dsn ) ;
5278 equal ( config [ 'publicKey' ] , 'public' ) ;
5379 equal ( config [ 'secretKey' ] , 'secret' ) ;
54- equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/api/project-id/store/ ' ) ;
80+ equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/' ) ;
5581 equal ( config [ 'projectId' ] , 'project-id' ) ;
5682 } ) ;
5783
@@ -62,7 +88,7 @@ $(document).ready(function() {
6288 var config = Raven . parseDSN ( dsn ) ;
6389 equal ( config [ 'publicKey' ] , 'public' ) ;
6490 equal ( config [ 'secretKey' ] , 'secret' ) ;
65- equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/path/api/project-id/store/ ' ) ;
91+ equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/path/' ) ;
6692 equal ( config [ 'projectId' ] , 'project-id' ) ;
6793 } ) ;
6894
@@ -72,7 +98,7 @@ $(document).ready(function() {
7298 var config = Raven . parseDSN ( dsn ) ;
7399 equal ( config [ 'publicKey' ] , 'public' ) ;
74100 equal ( config [ 'secretKey' ] , '' ) ;
75- equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/path/api/project-id/store/ ' ) ;
101+ equal ( config [ 'servers' ] [ 0 ] , 'http://example.com:80/path/' ) ;
76102 equal ( config [ 'projectId' ] , 'project-id' ) ;
77103 } ) ;
78104
0 commit comments