Fix unit tests (#248)

* Fix tests

- Remove jest tests and add coverage

- Rebase master and fix tests

* Ignore local .vscode

Add clean script

* Fix deps

- Upgrade deps
- Switch to esnext

* Move tests to the right folder

* Deps cleanup and bump up

* Remove root level package.json

* Fix grumbles

* Remove the labeler action due to https://github.com/actions/labeler/issues/12

* Fix grumbles
This commit is contained in:
Chevdor
2020-04-21 16:36:33 +02:00
committed by GitHub
parent d03679a78a
commit 3cbad1c0b3
17 changed files with 2567 additions and 1910 deletions
+1
View File
@@ -1,5 +1,6 @@
import { Types } from './common';
import { State, UpdateBound } from './state';
import { ConsensusDetail } from './common/types';
// Number of blocks which are kept in memory
const BLOCKS_LIMIT = 50;
-9
View File
@@ -1,9 +0,0 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
+24 -6
View File
@@ -17,6 +17,12 @@ import { ACTIONS } from './common/feed';
const TIMEOUT_BASE = (1000 * 5) as Types.Milliseconds; // 5 seconds
const TIMEOUT_MAX = (1000 * 60 * 5) as Types.Milliseconds; // 5 minutes
declare global {
interface Window {
process_env: string;
}
}
export class Connection {
public static async create(
pins: PersistentSet<Types.NodeName>,
@@ -26,11 +32,25 @@ export class Connection {
}
private static readonly utf8decoder = new TextDecoder('utf-8');
private static readonly address = Connection.getAddress();
private static readonly address =
window.location.protocol === 'https:'
? `wss://${window.location.hostname}/feed/`
: `ws://127.0.0.1:8000/feed`;
private static getAddress(): string {
const ENV_URL = 'SUBSTRATE_TELEMETRY_URL';
if (process.env && process.env[ENV_URL]) {
return process.env[ENV_URL] as string;
}
if (window.process_env && window.process_env[ENV_URL]) {
return window.process_env[ENV_URL];
}
if (window.location.protocol === 'https:') {
return `wss://${window.location.hostname}/feed/`;
}
return `ws://127.0.0.1:8000/feed`;
}
private static async socket(): Promise<WebSocket> {
let socket = await Connection.trySocket();
@@ -63,7 +83,6 @@ export class Connection {
clean();
resolve(null);
}
const socket = new WebSocket(Connection.address);
socket.binaryType = 'arraybuffer';
@@ -82,7 +101,6 @@ export class Connection {
private state: Readonly<State>;
private readonly update: Update;
private readonly pins: PersistentSet<Types.NodeName>;
constructor(
socket: WebSocket,
update: Update,
@@ -17,7 +17,7 @@
width: 100%;
}
.Consensus .flexContainerLargeRow .firstInRow .emptylegend,
.Consensus .flexContainerLargeRow .firstInRow .emptyLegend,
.Consensus .flexContainerLargeRow .firstInRow .nameLegend {
width: 99%;
flex-grow: 1000000000;
@@ -134,7 +134,7 @@
width: auto !important;
}
.Consensus .flexContainerLargeRow .noStretchOnLastRow .firstInRow .emptylegend {
.Consensus .flexContainerLargeRow .noStretchOnLastRow .firstInRow .emptyLegend {
width: auto !important;
}