File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const db = require('./db')
22
33module . exports = function handleSseConnection ( connection ) {
44 const subscription = db . subscribe ( ( event ) => {
5- connection . send ( { event : 'new-event ' , data : JSON . stringify ( event ) } )
5+ connection . send ( { event : 'micro-analytics-ping ' , data : JSON . stringify ( event ) } )
66 } )
77
88 connection . on ( 'close' , function ( ) {
Original file line number Diff line number Diff line change 1+ exports [` sse should publish events with correct structure 1` ] = `
2+ Array [
3+ Array [
4+ Object {
5+ " data" : " {\" key\" :\" superview\" ,\" value\" :{\" views\" :[{\" time\" :1490432584312}]}}" ,
6+ " event" : " micro-analytics-ping" ,
7+ } ,
8+ ],
9+ ]
10+ ` ;
Original file line number Diff line number Diff line change @@ -20,4 +20,14 @@ describe('sse', () => {
2020
2121 expect ( sendMock ) . toHaveBeenCalled ( )
2222 } )
23+
24+ it ( "should publish events with correct structure" , ( ) => {
25+ const sendMock = jest . fn ( )
26+ const eventListenerMock = jest . fn ( )
27+ sseHandler ( { send : sendMock , on : eventListenerMock } )
28+
29+ db . put ( 'superview' , { views : [ { time : 1490432584312 } ] } )
30+
31+ expect ( sendMock . mock . calls ) . toMatchSnapshot ( )
32+ } )
2333} )
You can’t perform that action at this time.
0 commit comments