Add tests for added light specs (#8063)

* Add tests for added light specs

* Full path

* Exclude deps

* fs: false
This commit is contained in:
Jaco 2022-08-28 10:50:26 +02:00 committed by GitHub
parent 3044bcff3e
commit 4ee33fdac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 11 deletions

View File

@ -173,6 +173,7 @@ function createWebpack (context, mode = 'production') {
fallback: {
assert: require.resolve('assert/'),
crypto: require.resolve('crypto-browserify'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),

View File

@ -12,6 +12,10 @@
"sideEffects": true,
"type": "module",
"version": "0.121.2-16-x",
"browser": {
"fs": false,
"path": false
},
"dependencies": {
"@babel/runtime": "^7.18.9",
"@polkadot/api": "^9.2.3",

View File

@ -0,0 +1,22 @@
// Copyright 2017-2022 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import fs from 'fs';
import path from 'path';
import { assert } from '@polkadot/util';
import { lightSpecs } from './light';
describe('lightSpecs', (): void => {
describe.each(Object.keys(lightSpecs))('%s', (r): void => {
it.each(Object.keys(lightSpecs[r]))('%s', (s): void => {
assert(
fs.existsSync(
path.join(__dirname, lightSpecs[r][s])
),
`packages/react-api/src/${lightSpecs[r][s].slice(2)} does not exist`
);
});
});
});

View File

@ -7,15 +7,13 @@ import { specs as kusama } from './kusama';
export const lightSpecs: Record<string, Record<string, string>> =
Object
.entries<Record<string, string>>({ kusama })
.entries({ kusama })
.reduce((all: Record<string, Record<string, string>>, [r, v]) => {
all[r] = Object
.entries<string>(v)
.reduce((specs: Record<string, string>, [k, v]) => {
specs[k] = `./light/${r}/${v}`;
all[r] = v.reduce((specs: Record<string, string>, k) => {
specs[k] = `./light/${r}/${k}.json`;
return specs;
}, {});
return specs;
}, {});
return all;
}, {});

View File

@ -4,7 +4,7 @@
// Add your imported spec here in alphabetical order.
// The key here reflects the URL of the light client endpoint.
// e.g. light://substrate-connect/kusama/gm
export const specs: Record<string, string> = {
gm: 'gm.json',
tinkernet: 'tinkernet.json'
};
export const specs: string[] = [
'gm',
'tinkernet'
];