File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ import Emitter from './Emitter'
33export  default  class  { 
44  constructor  ( connectionUrl ,  opts  =  { } )  { 
55    this . format  =  opts . format  &&  opts . format . toLowerCase ( ) 
6+     if ( connectionUrl . startsWith ( '//' ) ) { 
7+       const  scheme  =  window . location . protocol  ===  'https:'  ? 'wss'  : 'ws' ; 
8+       connectionUrl  =  `${ scheme } ${ connectionUrl }  
9+     } 
610    this . connectionUrl  =  connectionUrl 
711    this . opts  =  opts 
812
Original file line number Diff line number Diff line change @@ -23,6 +23,20 @@ describe('Observer.js', () => {
2323    } ,  vm ) 
2424  } ) 
2525
26+   it ( 'fires onopen event skip scheme' ,  ( done )  =>  { 
27+     mockServer  =  new  Server ( wsUrl ) 
28+     mockServer . on ( 'connection' ,  ws  =>  { 
29+       ws . send ( 'hi' ) 
30+     } ) 
31+     Vue . use ( VueNativeSock ,  '//localhost:8080' ) 
32+     let  vm  =  new  Vue ( ) 
33+     observer  =  new  Observer ( wsUrl ) 
34+     Emitter . addListener ( 'onopen' ,  ( data )  =>  { 
35+       expect ( data . type ) . to . equal ( 'open' ) 
36+       mockServer . stop ( done ) 
37+     } ,  vm ) 
38+   } ) 
39+ 
2640  // TODO: DRY 
2741  it ( 'passes a json commit to the provided vuex store' ,  ( done )  =>  { 
2842    let  expectedMsg  =  {  mutation : 'setName' ,  value : 'steve'  } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments