summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-01-25 15:56:49 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-01-25 15:56:49 +0900
commit92b45d1a9d4b121e2b975318b84ef466a25b7710 (patch)
tree27ccbe7bc2271caf2a51f469175de2a994ebd7cc
parentMerge branch 'develop' of https://github.com/syuilo/misskey into develop (diff)
downloadmisskey-92b45d1a9d4b121e2b975318b84ef466a25b7710.tar.gz
misskey-92b45d1a9d4b121e2b975318b84ef466a25b7710.tar.bz2
misskey-92b45d1a9d4b121e2b975318b84ef466a25b7710.zip
Refactoring
-rw-r--r--test/streaming.ts48
1 files changed, 24 insertions, 24 deletions
diff --git a/test/streaming.ts b/test/streaming.ts
index 1f4b593e2f..6186e348a7 100644
--- a/test/streaming.ts
+++ b/test/streaming.ts
@@ -45,37 +45,37 @@ describe('Streaming', () => {
server.close();
});
- it('投稿がタイムラインに流れる', done => {
+ it('投稿がタイムラインに流れる', () => new Promise(async done => {
const post = {
text: 'foo'
};
- signup().then(me => {
- const ws = new WebSocket(`ws://localhost/streaming?i=${me.token}`);
+ const me = await signup();
- ws.on('open', () => {
- ws.on('message', data => {
- const msg = JSON.parse(data.toString());
- if (msg.type == 'channel' && msg.body.id == 'a') {
- if (msg.body.type == 'note') {
- expect(msg.body.body.text).eql(post.text);
- ws.close();
- done();
- }
- } else if (msg.type == 'connected' && msg.body.id == 'a') {
- request('/notes/create', post, me);
- }
- });
+ const ws = new WebSocket(`ws://localhost/streaming?i=${me.token}`);
- ws.send(JSON.stringify({
- type: 'connect',
- body: {
- channel: 'homeTimeline',
- id: 'a',
- pong: true
+ ws.on('open', () => {
+ ws.on('message', data => {
+ const msg = JSON.parse(data.toString());
+ if (msg.type == 'channel' && msg.body.id == 'a') {
+ if (msg.body.type == 'note') {
+ expect(msg.body.body.text).eql(post.text);
+ ws.close();
+ done();
}
- }));
+ } else if (msg.type == 'connected' && msg.body.id == 'a') {
+ request('/notes/create', post, me);
+ }
});
+
+ ws.send(JSON.stringify({
+ type: 'connect',
+ body: {
+ channel: 'homeTimeline',
+ id: 'a',
+ pong: true
+ }
+ }));
});
- });
+ }));
});