forked from kyliepace/kafka-transform-events
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kylie Pace
committed
Jan 14, 2021
1 parent
b105014
commit 6a55c30
Showing
8 changed files
with
95 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import WebSocket from 'ws'; | ||
import MongoRepository from '../src/repositories/MongoRepository'; | ||
|
||
|
||
describe('websocket http request', () => { | ||
const database = new MongoRepository(); | ||
const session_id = "e6fa79ca-d142-4046-a134-5134f16a0b5e"; | ||
let clients; | ||
async function run() { | ||
clients[0].send( | ||
JSON.stringify([{ | ||
timestamp: 1569972082, | ||
type: "SESSION_START", | ||
session_id | ||
}]) | ||
); | ||
|
||
clients[0].send( | ||
JSON.stringify([{ | ||
timestamp: 1569972085, | ||
type: "EVENT", | ||
name: "basket_removed" | ||
}]) | ||
); | ||
|
||
clients[0].send( | ||
JSON.stringify([{ | ||
timestamp: 1569972083, | ||
type: "EVENT", | ||
name: "purchase_completed" | ||
}]) | ||
); | ||
|
||
console.log('client sent message') | ||
|
||
clients[0].send( | ||
JSON.stringify([{ | ||
timestamp: 1569972086, | ||
type: "SESSION_END", | ||
session_id | ||
}]) | ||
); | ||
console.log('client sent final message') | ||
|
||
return; | ||
} | ||
|
||
before(async () => { | ||
// clean up data | ||
await database.delete({ | ||
session_id | ||
}); | ||
|
||
clients = [ | ||
new WebSocket('ws://localhost:8080/websocket?session_id="e6fa79ca-d142-4046-a134-5134f16a0b5e"') | ||
]; | ||
|
||
// Wait for the client to connect using async/await | ||
await new Promise(resolve => clients[0].once('open', resolve)); | ||
console.log('connected'); | ||
|
||
// send messages | ||
await run(); | ||
}); | ||
|
||
it('saves data', () => { | ||
|
||
}) | ||
}); | ||
|
||
|