kibana/x-pack/plugins/apm/server/lib/service_nodes/queries.test.ts
Cauê Marcondes 712c4bdde7
[APM] Prevent imports of public in server code (#75979)
* renaming test file

* removing eslint rule

* restructuring observability types

* refactoring fetchOptions type
2020-08-28 12:43:49 +02:00

58 lines
1.6 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getServiceNodes } from './';
import {
SearchParamsMock,
inspectSearchParams,
} from '../../utils/test_helpers';
import { getServiceNodeMetadata } from '../services/get_service_node_metadata';
import { SERVICE_NODE_NAME_MISSING } from '../../../common/service_nodes';
describe('service node queries', () => {
let mock: SearchParamsMock;
afterEach(() => {
mock.teardown();
});
it('fetches services nodes', async () => {
mock = await inspectSearchParams((setup) =>
getServiceNodes({ setup, serviceName: 'foo' })
);
expect(mock.params).toMatchSnapshot();
});
it('fetches metadata for a service node', async () => {
mock = await inspectSearchParams((setup) =>
getServiceNodeMetadata({
setup,
serviceName: 'foo',
serviceNodeName: 'bar',
})
);
expect(mock.params).toMatchSnapshot();
});
it('fetches metadata for unidentified service nodes', async () => {
mock = await inspectSearchParams((setup) =>
getServiceNodeMetadata({
setup,
serviceName: 'foo',
serviceNodeName: SERVICE_NODE_NAME_MISSING,
})
);
expect(mock.params).toMatchSnapshot();
});
});