22/*global assert:false, console:true*/
33'use strict' ;
44
5- var _Raven = require ( '../src/raven' ) ;
6- var TraceKit = require ( '../vendor/TraceKit/tracekit' ) ;
7- var joinRegExp = require ( '../src/utils' ) . joinRegExp ;
5+ var proxyquire = require ( 'proxyquireify' ) ( require ) ;
86
9- window . crypto . getRandomValues = function ( arr ) {
10- console . log ( 'getRandomValues' ) ;
11- return [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
12- } ;
7+ var TraceKit = require ( '../vendor/TraceKit/tracekit' ) ;
8+ var _Raven = proxyquire ( '../src/raven' , {
9+ './utils' : {
10+ // patched to return a predictable result
11+ uuid4 : function ( ) {
12+ return 'abc123' ;
13+ }
14+ } ,
15+
16+ // Ensure same TraceKit obj is shared (without specifying this, proxyquire
17+ // seems to clone dependencies or something weird)
18+ '../vendor/TraceKit/tracekit' : TraceKit
19+ } ) ;
1320
14- // uuid4 return value generated by stubbed getRandomValues above
15- var CONST_UUID4 = "00000000000040008000000000000000" ;
21+ var joinRegExp = require ( '../src/utils' ) . joinRegExp ;
1622
1723// window.console must be stubbed in for browsers that don't have it
1824if ( typeof window . console === 'undefined' ) {
@@ -27,10 +33,6 @@ function setupRaven() {
2733 Raven . globalOptions . fetchContext = true ;
2834}
2935
30- // patched to return a predictable result
31- // Raven._uuid4 = function() {
32- // return CONST_UUID4;
33- // };
3436
3537var Raven ;
3638
@@ -720,7 +722,7 @@ describe('globals', function() {
720722 'User-Agent' : 'lolbrowser'
721723 }
722724 } ,
723- event_id : CONST_UUID4 ,
725+ event_id : 'abc123' ,
724726 message : 'bar' ,
725727 extra : { 'session:duration' : 100 }
726728 } ) ;
@@ -752,7 +754,7 @@ describe('globals', function() {
752754 'User-Agent' : 'lolbrowser'
753755 }
754756 } ,
755- event_id : CONST_UUID4 ,
757+ event_id : 'abc123' ,
756758 user : {
757759 name : 'Matt'
758760 } ,
@@ -787,7 +789,7 @@ describe('globals', function() {
787789 'User-Agent' : 'lolbrowser'
788790 }
789791 } ,
790- event_id : CONST_UUID4 ,
792+ event_id : 'abc123' ,
791793 message : 'bar' ,
792794 tags : { tag1 : 'value1' , tag2 : 'value2' } ,
793795 extra : { 'session:duration' : 100 }
@@ -830,7 +832,7 @@ describe('globals', function() {
830832 }
831833 } ,
832834
833- event_id : CONST_UUID4 ,
835+ event_id : 'abc123' ,
834836 message : 'bar' ,
835837 extra : { key1 : 'value1' , key2 : 'value2' , 'session:duration' : 100 }
836838 } ) ;
@@ -861,7 +863,7 @@ describe('globals', function() {
861863 Raven . _send ( { message : 'bar' } ) ;
862864 assert . deepEqual ( Raven . _makeRequest . lastCall . args [ 0 ] . data , {
863865 message : 'ibrokeit' ,
864- event_id : CONST_UUID4
866+ event_id : 'abc123'
865867 } ) ;
866868 } ) ;
867869
@@ -893,7 +895,7 @@ describe('globals', function() {
893895 'User-Agent' : 'lolbrowser'
894896 }
895897 } ,
896- event_id : CONST_UUID4 ,
898+ event_id : 'abc123' ,
897899 message : 'bar' ,
898900 extra : { 'session:duration' : 100 }
899901 } ) ;
@@ -925,7 +927,7 @@ describe('globals', function() {
925927 'User-Agent' : 'lolbrowser'
926928 }
927929 } ,
928- event_id : CONST_UUID4 ,
930+ event_id : 'abc123' ,
929931 message : 'bar' ,
930932 extra : { 'session:duration' : 100 }
931933 } ) ;
@@ -958,7 +960,7 @@ describe('globals', function() {
958960 'User-Agent' : 'lolbrowser'
959961 }
960962 } ,
961- event_id : CONST_UUID4 ,
963+ event_id : 'abc123' ,
962964 message : 'bar' ,
963965 extra : { 'session:duration' : 100 }
964966 } ) ;
@@ -991,7 +993,7 @@ describe('globals', function() {
991993 'User-Agent' : 'lolbrowser'
992994 }
993995 } ,
994- event_id : CONST_UUID4 ,
996+ event_id : 'abc123' ,
995997 message : 'bar' ,
996998 extra : { 'session:duration' : 100 }
997999 } ) ;
@@ -1030,7 +1032,7 @@ describe('globals', function() {
10301032 'User-Agent' : 'lolbrowser'
10311033 }
10321034 } ,
1033- event_id : CONST_UUID4 ,
1035+ event_id : 'abc123' ,
10341036 message : 'bar' ,
10351037 extra : { 'session:duration' : 100 } ,
10361038 } ) ;
@@ -1071,7 +1073,7 @@ describe('globals', function() {
10711073 'User-Agent' : 'lolbrowser'
10721074 }
10731075 } ,
1074- event_id : CONST_UUID4 ,
1076+ event_id : 'abc123' ,
10751077 message : 'bar' ,
10761078 extra : { 'session:duration' : 100 }
10771079 } ) ;
@@ -1753,12 +1755,12 @@ describe('Raven (public API)', function() {
17531755
17541756 describe ( '.setRelease' , function ( ) {
17551757 it ( 'should set the globalOptions.release attribute' , function ( ) {
1756- Raven . setRelease ( CONST_UUID4 ) ;
1757- assert . equal ( Raven . globalOptions . release , CONST_UUID4 ) ;
1758+ Raven . setRelease ( 'abc123' ) ;
1759+ assert . equal ( Raven . globalOptions . release , 'abc123' ) ;
17581760 } ) ;
17591761
17601762 it ( 'should clear globalOptions.release with no arguments' , function ( ) {
1761- Raven . globalOptions . release = CONST_UUID4 ;
1763+ Raven . globalOptions . release = 'abc123' ;
17621764 Raven . setRelease ( ) ;
17631765 assert . isUndefined ( Raven . globalOptions . release ) ;
17641766 } ) ;
@@ -1831,7 +1833,7 @@ describe('Raven (public API)', function() {
18311833 it ( 'should tag lastEventId #integration' , function ( ) {
18321834 setupRaven ( ) ;
18331835 Raven . captureMessage ( 'lol' ) ;
1834- assert . equal ( Raven . lastEventId ( ) , CONST_UUID4 ) ;
1836+ assert . equal ( Raven . lastEventId ( ) , 'abc123' ) ;
18351837 } ) ;
18361838
18371839 it ( 'should respect `ignoreErrors`' , function ( ) {
0 commit comments