Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit ad61775

Browse files
author
Eric Andrews
committed
Fix pause and disconnect tests
1 parent 0063e57 commit ad61775

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

test/test.streamr-client.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -830,17 +830,17 @@ describe('StreamrClient', function() {
830830
var sub2 = client.subscribe("stream2", function(message) {})
831831
client.connect()
832832

833+
client.connection.on('disconnected', function() {
834+
throw "Should not have disconnected!"
835+
})
836+
833837
client.connection.on('subscribed', function(response) {
834838
if (sub1.isSubscribed() && sub2.isSubscribed()) {
835839
client.unsubscribe(sub1)
836840
client.unsubscribe(sub2)
837841
done()
838842
}
839843
})
840-
841-
client.connection.on('disconnect', function() {
842-
throw "Should not have disconnected!"
843-
})
844844
})
845845
})
846846

@@ -850,19 +850,19 @@ describe('StreamrClient', function() {
850850
client.connect()
851851
client.connection.disconnect = done
852852

853-
client.connection.once('connect', function() {
853+
client.connection.once('connected', function() {
854854
client.disconnect()
855855
})
856856
})
857857

858858
it('should report that it is not connected and not connecting after disconnecting', function(done) {
859859
client.connect()
860860

861-
client.connection.once('connect', function() {
861+
client.connection.once('connected', function() {
862862
client.disconnect()
863863
})
864864

865-
client.connection.once('disconnect', function() {
865+
client.connection.once('disconnected', function() {
866866
assert(!client.isConnected())
867867
assert(!client.connecting)
868868
done()
@@ -877,7 +877,7 @@ describe('StreamrClient', function() {
877877
client.disconnect()
878878
})
879879

880-
client.connection.once('disconnect', function() {
880+
client.connection.once('disconnected', function() {
881881
assert.equal(client.getSubscriptions('stream1').length, 0)
882882
done()
883883
})
@@ -891,14 +891,13 @@ describe('StreamrClient', function() {
891891
client.disconnect()
892892
})
893893

894-
client.connection.once('disconnect', function() {
894+
client.connection.once('disconnected', function() {
895895
client.subscribe("stream2", function(message) {})
896896
client.connect()
897897

898898
client.connection.once('subscribed', function(response) {
899-
if (response.channel === 'stream2')
900-
done()
901-
else throw "Unexpected response: "+JSON.stringify(response)
899+
assert.equal(response.channel, 'stream2')
900+
done()
902901
})
903902
})
904903
})
@@ -910,19 +909,19 @@ describe('StreamrClient', function() {
910909

911910
client.connection.disconnect = done
912911

913-
client.connection.once('connect', function() {
912+
client.connection.once('connected', function() {
914913
client.pause()
915914
})
916915
})
917916

918917
it('should report that its not connected after pausing', function(done) {
919918
client.connect()
920919

921-
client.connection.once('connect', function() {
920+
client.connection.once('connected', function() {
922921
client.pause()
923922
})
924923

925-
client.connection.once('disconnect', function() {
924+
client.connection.once('disconnected', function() {
926925
assert(!client.isConnected())
927926
done()
928927
})
@@ -936,7 +935,7 @@ describe('StreamrClient', function() {
936935
client.pause()
937936
})
938937

939-
client.connection.once('disconnect', function() {
938+
client.connection.once('disconnected', function() {
940939
assert.equal(client.getSubscriptions('stream1').length, 1)
941940
done()
942941
})
@@ -952,12 +951,7 @@ describe('StreamrClient', function() {
952951
client.pause()
953952
})
954953

955-
client.connection.on('connect', function() {
956-
console.log("connect event")
957-
})
958-
959-
client.connection.once('disconnect', function() {
960-
console.log("sub2")
954+
client.connection.once('disconnected', function() {
961955
sub2 = client.subscribe("stream2", function(message) {})
962956

963957
assert(!sub1.isSubscribed())
@@ -966,12 +960,12 @@ describe('StreamrClient', function() {
966960
assert.equal(client.getSubscriptions('stream1').length, 1)
967961
assert.equal(client.getSubscriptions('stream2').length, 1)
968962

969-
console.log("conn")
970963
client.connect()
971-
972964
client.connection.on('subscribed', function(response) {
973-
if (sub1.isSubscribed() && sub2.isSubscribed())
965+
if (sub1.isSubscribed() && sub2.isSubscribed()) {
966+
socket.done = true
974967
done()
968+
}
975969
})
976970
})
977971
})

0 commit comments

Comments
 (0)