Skip to content

Commit fe72c24

Browse files
committed
chore: test
1 parent 2235ee5 commit fe72c24

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/service-endpoints.test.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { getServiceClientEndpoint } from './service-endpoints';
22
import { GeneratedServiceClientCtor } from './types';
33
import SERVICE_ENDPOINTS_MAP from './service-endpoints-map.json';
4+
import { getServiceList } from '../scripts/check-endpoints';
45

56
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67
type MockServiceClientCtor = GeneratedServiceClientCtor<any>;
78

89
describe('service endpoints', () => {
9-
it('each service in generated service_clients module should have endpoint declared in service-endpoints-map', async () => {
10+
it('no empty endpoints', async () => {
1011
const missedEndpointsList: string[] = [];
1112

1213
Object.keys(SERVICE_ENDPOINTS_MAP).forEach((service) => {
@@ -15,10 +16,36 @@ describe('service endpoints', () => {
1516
});
1617

1718
if (missedEndpointsList.length !== 0) {
18-
throw `\nMissed endpoints:\n${missedEndpointsList.join('\n')}\n`;
19+
throw `\nMissed endpoints in service-endpoints-map.json:\n${missedEndpointsList.join(
20+
'\n',
21+
)}\n`;
1922
}
2023
});
2124

25+
it('each service should have endpoint', async () => {
26+
const serviceList = await getServiceList();
27+
const missedEndpointsList: string[] = [];
28+
29+
serviceList.forEach((s) => {
30+
// full name without leading dot
31+
const serviceName = s.fullName.slice(1);
32+
let endpoint = '';
33+
34+
try {
35+
endpoint = getServiceClientEndpoint({
36+
serviceName,
37+
} as unknown as MockServiceClientCtor);
38+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-empty
39+
} catch (_err) {}
40+
41+
if (!endpoint) missedEndpointsList.push(serviceName);
42+
});
43+
44+
if (missedEndpointsList.length !== 0) {
45+
throw `\nMissed endpoints:\n${missedEndpointsList.join('\n')}\n`;
46+
}
47+
}, 200_000);
48+
2249
it('should throw exception if endpoint was not found', () => {
2350
const serviceName = 'myCustomService';
2451

0 commit comments

Comments
 (0)