Update functional test dependencies

This commit is contained in:
Claudemiro
2018-11-25 21:24:05 +01:00
parent 8da763ec2f
commit 964df8a5dd
3 changed files with 32 additions and 21 deletions
+5 -6
View File
@@ -2,22 +2,21 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Pusher Spec</title> <title>Pusher Spec</title>
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet"/> <link href="//cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.css" rel="stylesheet"/>
</head> </head>
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.3.4/mocha.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.4.1/chai.min.js"></script>
<script src="//js.pusher.com/3.2/pusher.min.js"></script> <script src="//js.pusher.com/4.3.1/pusher.min.js"></script>
<script>mocha.setup('bdd')</script> <script>mocha.setup('bdd')</script>
<script src="test.pusher.js"></script> <script src="test.pusher.js"></script>
<script> <script>
mocha.checkLeaks(); mocha.checkLeaks();
mocha.globals(['jQuery', 'Pusher']); mocha.globals(['Pusher']);
mocha.run(); mocha.run();
</script> </script>
</body> </body>
+17 -6
View File
@@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
@@ -14,11 +15,10 @@ var client pusher.Client
func init() { func init() {
client = pusher.Client{ client = pusher.Client{
AppId: "1", AppId: "1",
Key: "278d525bdf162c739803", Key: "278d525bdf162c739803",
Secret: "7ad3753142a6693b25b9", Secret: "7ad3753142a6693b25b9",
Host: ":8080", Host: ":8080",
Cluster: "hello",
} }
} }
@@ -69,7 +69,18 @@ func hookcallback(res http.ResponseWriter, r *http.Request) {
} }
fmt.Println(string(bytes)) fmt.Println(string(bytes))
_, err = client.Trigger("private-webhook", "mywebhook", "The Webhoook from server") event := struct {
Events []struct {
Name string `json:"name"`
} `json:"events"`
}{}
err = json.NewDecoder(r.Body).Decode(&event)
if err != nil {
panic(err)
}
_, err = client.Trigger("private-webhook", event.Events[0].Name, "The Webhoook from server")
if err != nil { if err != nil {
panic(err) panic(err)
} }
+10 -9
View File
@@ -1,3 +1,5 @@
"use strict";
let assert = chai.assert; let assert = chai.assert;
let APP_KEY = "278d525bdf162c739803"; let APP_KEY = "278d525bdf162c739803";
@@ -17,7 +19,6 @@ function getPusher(auth) {
authEndpoint: auth, authEndpoint: auth,
enabledTransports: ["ws"], enabledTransports: ["ws"],
disabledTransports: ["flash"], disabledTransports: ["flash"],
cluster: "hello", // Should be ignored
}); });
} }
@@ -53,7 +54,7 @@ describe("Pusher", function () {
let pusher = getPusher(AUTH); let pusher = getPusher(AUTH);
let channel = pusher.subscribe('public-channel'); let channel = pusher.subscribe('public-channel');
channel.bind("pusher:subscription_succeeded", function (data) { channel.bind("pusher:subscription_succeeded", function () {
assert.ok(true, "Connected to the channel"); assert.ok(true, "Connected to the channel");
done(); done();
}); });
@@ -63,7 +64,7 @@ describe("Pusher", function () {
let pusher = getPusher(AUTH); let pusher = getPusher(AUTH);
let channel = pusher.subscribe('private-channel'); let channel = pusher.subscribe('private-channel');
channel.bind("pusher:subscription_succeeded", function (data) { channel.bind("pusher:subscription_succeeded", function () {
assert.ok(true, "Connected to the channel"); assert.ok(true, "Connected to the channel");
done(); done();
}); });
@@ -73,7 +74,7 @@ describe("Pusher", function () {
let pusher = getPusher(AUTH_PRESENCE); let pusher = getPusher(AUTH_PRESENCE);
let channel = pusher.subscribe('presence-channel'); let channel = pusher.subscribe('presence-channel');
channel.bind("pusher:subscription_succeeded", function (data) { channel.bind("pusher:subscription_succeeded", function () {
assert.ok(true, "Connected to the channel"); assert.ok(true, "Connected to the channel");
done(); done();
}); });
@@ -85,13 +86,13 @@ describe("Pusher", function () {
let pusher = getPusher(AUTH); let pusher = getPusher(AUTH);
let channel = pusher.subscribe('private-webhook'); let channel = pusher.subscribe('private-webhook');
channel.bind("pusher:subscription_succeeded", function (data) { channel.bind("pusher:subscription_succeeded", function () {
console.log("subscribed"); console.log("subscribed");
}); });
channel.bind("mywebhook", function (data) { channel.bind("channel_occupied", function (data) {
console.log(data);
assert.equal(data, "The Webhoook from server"); assert.equal(data, "The Webhoook from server");
pusher.unsubscribe('private-webhook');
done(); done();
}); });
}); });
@@ -102,11 +103,11 @@ describe("Pusher", function () {
let pusher = getPusher(AUTH); let pusher = getPusher(AUTH);
let channel = pusher.subscribe('public-channel'); let channel = pusher.subscribe('public-channel');
channel.bind("pusher:subscription_succeeded", function (data) { channel.bind("pusher:subscription_succeeded", function () {
channel.trigger("client-message", "The message"); channel.trigger("client-message", "The message");
}); });
pusher.bind("pusher:error", function (data) { pusher.bind("pusher:error", function () {
assert.ok(true, "Expected error"); assert.ok(true, "Expected error");
done(); done();
}); });