Add tests for added light specs (#8063)
* Add tests for added light specs * Full path * Exclude deps * fs: false
This commit is contained in:
parent
3044bcff3e
commit
4ee33fdac4
@ -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'),
|
||||
|
||||
@ -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",
|
||||
|
||||
22
packages/react-api/src/light.spec.ts
Normal file
22
packages/react-api/src/light.spec.ts
Normal 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`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -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;
|
||||
}, {});
|
||||
|
||||
@ -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'
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user