Add provider naming tests (#7239)

This commit is contained in:
Jaco 2022-03-26 12:48:59 +01:00 committed by GitHub
parent 55679c430f
commit af16c7b792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 10 deletions

View File

@ -7,10 +7,11 @@ import { createWsEndpoints } from '.';
interface Endpoint {
name: string;
provider: string;
value: string;
}
const allEndpoints = createWsEndpoints((k: string, v?: string) => v || k, false, false);
const allEndpoints = createWsEndpoints((k: string, v?: string, options?: { replace: Record<string, string> }) => (options && options.replace && options.replace.host) || v || k, false, false);
describe('WS urls are all valid', (): void => {
allEndpoints
@ -19,13 +20,14 @@ describe('WS urls are all valid', (): void => {
isString(value) &&
!value.includes('127.0.0.1')
)
.map(({ text, value }): Endpoint => ({
.map(({ text, textBy, value }): Endpoint => ({
name: text as string,
provider: textBy,
value
}))
.forEach(({ name, value }) =>
it(`${name} @ ${value}`, (): void => {
assert(value.startsWith('wss://') || value.startsWith('light://substrate-connect/'), `${name} @ ${value} should start with wss:// or light://`);
.forEach(({ name, provider, value }) =>
it(`${name}:: ${provider}`, (): void => {
assert(value.startsWith('wss://') || value.startsWith('light://substrate-connect/'), `${name}:: ${provider} -> ${value} should start with wss:// or light://`);
})
);
});
@ -39,11 +41,11 @@ describe('urls are sorted', (): void => {
return !hasDevelopment;
});
filtered.forEach(({ isHeader, text }, index): void => {
filtered.forEach(({ isHeader, text, textBy }, index): void => {
if (isHeader) {
lastHeader = text as string;
} else {
it(`${lastHeader}:: ${text as string}`, (): void => {
it(`${lastHeader}:: ${text as string}:: ${textBy}`, (): void => {
assert((
filtered[index - 1].isHeader ||
filtered[index - 1].linked ||
@ -89,3 +91,28 @@ describe('urls are not duplicated', (): void => {
).toEqual([]);
});
});
describe('endpopints do not contain emojis or all uppercase', (): void => {
const emoji = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/;
console.error(allEndpoints);
allEndpoints
.filter(({ value }) =>
value &&
isString(value) &&
!value.includes('127.0.0.1')
)
.map(({ text, textBy, value }): Endpoint => ({
name: text as string,
provider: textBy,
value: value
}))
.forEach(({ name, provider }) =>
it(`${name}:: ${provider}`, (): void => {
assert(!emoji.test(name), `${name} should not contain any emojis`);
assert(!emoji.test(provider), `${name}:: ${provider} should not contain any emojis`);
assert(!provider.includes(' ') || (provider.toLocaleUpperCase() !== provider), `${name}:: ${provider} should not be all uppercase`);
})
);
});

View File

@ -177,7 +177,7 @@ export function createKusama (t: TFunction): EndpointOption {
paraId: 2107,
text: t('rpc.kusama.kico', 'KICO', { ns: 'apps-config' }),
providers: {
'DICO FOUNDATION': 'wss://rpc.kico.dico.io',
'DICO Foundation': 'wss://rpc.kico.dico.io',
OnFinality: 'wss://rpc.api.kico.dico.io'
}
},
@ -218,8 +218,8 @@ export function createKusama (t: TFunction): EndpointOption {
paraId: 2118,
text: t('rpc.kusama.listen', 'Listen Network', { ns: 'apps-config' }),
providers: {
'LISTEN FOUNDATION 1': 'wss://rpc.mainnet.listen.io',
'LISTEN FOUNDATION 2': 'wss://wss.mainnet.listen.io',
'Listen Foundation 1': 'wss://rpc.mainnet.listen.io',
'Listen Foundation 2': 'wss://wss.mainnet.listen.io',
OnFinality: 'wss://listen.api.onfinality.io/public-ws'
}
},