Prefer static checking (#43)

This commit is contained in:
Jaco Greeff
2017-12-18 20:08:16 +01:00
committed by GitHub
parent 34be54abaf
commit c980d3e69b
17 changed files with 49 additions and 80 deletions
-1
View File
@@ -14,7 +14,6 @@ module.exports = class HttpProvider extends JsonRpcCoder implements ProviderInte
constructor (endpoint: string) {
super();
assert(endpoint, 'Endpoint should be provided');
assert(/^http:\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`);
this._endpoint = endpoint;
+4 -12
View File
@@ -27,18 +27,10 @@ describe('Http', () => {
}
});
describe('constructor', () => {
it('requires the endpoint to be set', () => {
expect(
() => new Http()
).toThrow(/should be provided/);
});
it('requires an http:// prefixed endpoint', () => {
expect(
() => new Http('ws://')
).toThrow(/with 'http/);
});
it('requires an http:// prefixed endpoint', () => {
expect(
() => new Http('ws://')
).toThrow(/with 'http/);
});
describe('isConnected', () => {
-1
View File
@@ -27,7 +27,6 @@ module.exports = class WsProvider extends JsonRpcCoder implements ProviderInterf
constructor (endpoint: string, autoConnect: boolean = true) {
super();
assert(endpoint, 'Endpoint should be provided');
assert(/^ws:\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`);
this._endpoint = endpoint;
+4 -12
View File
@@ -37,18 +37,10 @@ describe('Ws', () => {
}
});
describe('constructor', () => {
it('requires the endpoint to be set', () => {
expect(
() => new Ws()
).toThrow(/should be provided/);
});
it('requires an ws:// prefixed endpoint', () => {
expect(
() => new Ws('http://')
).toThrow(/with 'ws/);
});
it('requires an ws:// prefixed endpoint', () => {
expect(
() => new Ws('http://')
).toThrow(/with 'ws/);
});
describe('websocket', () => {