Skip to content

Commit ba10b04

Browse files
author
ionut.stan
committed
Testing improvements.
1 parent 91ff93d commit ba10b04

File tree

10 files changed

+75
-12
lines changed

10 files changed

+75
-12
lines changed

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
// Configure glob patterns for excluding files and folders.
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.svn": true,
7+
"**/.hg": true,
8+
"**/CVS": true,
9+
"**/.DS_Store": true,
10+
"*.min.js": true,
11+
"*.js.map": true
12+
}
13+
}

builds/browser/es5/jsonrpc.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

builds/browser/es5/jsonrpc.js renamed to builds/browser/es5/jsonrpc.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builds/browser/es5/jsonrpc.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jsonrpc-bidirectional",
33
"description": "Bidirectional JSONRPC over web sockets or HTTP with extensive plugin support.",
4-
"version": "2.1.4",
4+
"version": "2.1.5",
55
"scripts": {
66
"build": "node build.js",
77
"test": "node tests/main.js",
@@ -61,4 +61,4 @@
6161
"bufferutil": "^3.0.0",
6262
"utf-8-validate": "^3.0.1"
6363
}
64-
}
64+
}

tests/AllTests.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ class AllTests
111111

112112
if(!this._bWebSocketMode)
113113
{
114-
this._jsonrpcServerSiteA.addPlugin(this._serverAuthorizeAllPlugin);
115-
this._jsonrpcServerSiteA.addPlugin(this._serverAuthenticationSkipPlugin);
114+
this.disableServerSecuritySiteA();
116115
}
117116
else
118117
{
@@ -299,6 +298,16 @@ class AllTests
299298
}
300299

301300

301+
/**
302+
* @returns {undefined}
303+
*/
304+
async disableServerSecuritySiteA()
305+
{
306+
this._jsonrpcServerSiteA.addPlugin(this._serverAuthorizeAllPlugin);
307+
this._jsonrpcServerSiteA.addPlugin(this._serverAuthenticationSkipPlugin);
308+
}
309+
310+
302311
/**
303312
* @returns {undefined}
304313
*/
@@ -881,7 +890,7 @@ class AllTests
881890

882891
async callRPCMethodFromWebPage()
883892
{
884-
assert(fs.existsSync(path.resolve(path.dirname(__dirname) + "/builds/browser/es5/jsonrpc.js")));
893+
assert(fs.existsSync(path.resolve(path.dirname(__dirname) + "/builds/browser/es5/jsonrpc.min.js")));
885894
assert(fs.existsSync(path.resolve(__dirname + "/Browser/index.html")));
886895

887896
const phantom = await Phantom.create(

tests/Browser/index.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<title>Tests</title>
55

6-
<script type="text/javascript" src="/builds/browser/es5/jsonrpc.js"></script>
6+
<script type="text/javascript" src="/builds/browser/es5/jsonrpc.min.js"></script>
77

88
<script>
99
var arrErrors = [];
@@ -22,6 +22,22 @@
2222
.then(function(result){arrErrors.push(result)})
2323
.catch(function(error){arrErrors.push(error)})
2424
;
25+
26+
if(!console)
27+
console = {};
28+
if(!console.log)
29+
console.log = function(){};
30+
if(!console.info)
31+
console.info = console.log;
32+
if(!console.debug)
33+
console.debug = console.log;
34+
if(!console.error)
35+
console.error = console.log;
36+
37+
console.info('JSONRPC.Client instantiated as window.client.');
38+
console.info('Example call: ');
39+
console.debug('client.rpc("ping", ["Calling from browser ES5 client."]).then(console.log).catch(console.error);');
40+
console.info('The above command is known to work in at least Internet Explorer 10.');
2541
}
2642
);
2743
</script>

tests/Browser/main_server.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Use this CLI server to support browser development, debugging or manual testing.
2+
3+
const AllTests = require("../AllTests");
4+
5+
process.on(
6+
"unhandledRejection",
7+
(reason, promise) =>
8+
{
9+
console.log("[" + process.pid + "] Unhandled Rejection at: Promise", promise, "reason", reason);
10+
11+
process.exit(1);
12+
}
13+
);
14+
15+
(
16+
async () =>
17+
{
18+
const allTests = new AllTests(/*bWebSocketMode*/ true);
19+
await allTests.setupHTTPServer();
20+
await allTests.setupWebsocketServerSiteA();
21+
await allTests.disableServerSecuritySiteA();
22+
23+
console.log("Go to http://localhost:8324/tests/Browser/index.html");
24+
}
25+
)();

tests/TestEndpoint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TestEndpoint extends JSONRPC.EndpointBase
4040
{
4141
if(bRandomSleep)
4242
{
43-
// await sleep(parseInt(Math.random() * 1000 /*milliseconds*/, 10));
43+
await sleep(parseInt(Math.random() * 1000 /*milliseconds*/, 10));
4444
}
4545

4646
if(typeof strATeamCharacterName === "string")

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = [
1919
],
2020
output: {
2121
path: path.join(__dirname, "builds", "browser", "es5"),
22-
filename: "jsonrpc.js",
22+
filename: "jsonrpc.min.js",
2323
libraryTarget: "umd"
2424
},
2525
devtool: "source-map",
@@ -72,7 +72,7 @@ module.exports = [
7272
],
7373
output: {
7474
path: path.join(__dirname, "builds", "browser", "es7"),
75-
filename: "jsonrpc.js",
75+
filename: "jsonrpc.min.js",
7676
libraryTarget: "umd"
7777
},
7878
devtool: "source-map",

0 commit comments

Comments
 (0)