File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ export default class Echo {
48
48
this . connector = new NullConnector ( this . options ) ;
49
49
} else if ( typeof this . options . broadcaster == 'function' ) {
50
50
this . connector = new this . options . broadcaster ( this . options ) ;
51
+ } else {
52
+ throw new Error (
53
+ `Broadcaster ${ typeof this . options . broadcaster } ${ this . options . broadcaster } is not supported.`
54
+ ) ;
51
55
}
52
56
}
53
57
Original file line number Diff line number Diff line change
1
+ import Echo from '../src/echo' ;
2
+
3
+ describe ( 'Echo' , ( ) => {
4
+ test ( 'it will not throw error for supported driver' , ( ) => {
5
+ expect ( ( ) => new Echo ( { broadcaster : 'reverb' } ) ) . not . toThrowError (
6
+ 'Broadcaster string reverb is not supported.'
7
+ ) ;
8
+
9
+ expect ( ( ) => new Echo ( { broadcaster : 'pusher' } ) ) . not . toThrowError (
10
+ 'Broadcaster string pusher is not supported.'
11
+ ) ;
12
+
13
+ expect ( ( ) => new Echo ( { broadcaster : 'socket.io' } ) ) . not . toThrowError (
14
+ 'Broadcaster string socket.io is not supported.'
15
+ ) ;
16
+
17
+ expect ( ( ) => new Echo ( { broadcaster : 'null' } ) ) . not . toThrowError ( 'Broadcaster string null is not supported.' ) ;
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
20
+ expect ( ( ) => new Echo ( { broadcaster : ( ) => { } } ) ) . not . toThrowError ( 'Broadcaster function is not supported.' ) ;
21
+ } ) ;
22
+
23
+ test ( 'it will throw error for unsupported driver' , ( ) => {
24
+ expect ( ( ) => new Echo ( { broadcaster : 'foo' } ) ) . toThrowError ( 'Broadcaster string foo is not supported.' ) ;
25
+ } ) ;
26
+ } ) ;
You can’t perform that action at this time.
0 commit comments