Prefer static checking (#43)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user