Skip to content

Commit

Permalink
test: revert the public API tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EshaanAgg committed Jan 2, 2024
1 parent 6b4ceca commit 8d7ac3b
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion packages/jaeger-ui/src/actions/jaeger-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jest.mock(
})
);

import sinon from 'sinon';
function isPromise(p) {
return p !== null && typeof p === 'object' && typeof p.then === 'function' && typeof p.catch === 'function';
}

import sinon from 'sinon';
import * as jaegerApiActions from './jaeger-api';
import JaegerAPI from '../api/jaeger';

Expand All @@ -48,6 +51,11 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/FETCH_TRACE should return the promise', () => {
const { payload } = jaegerApiActions.fetchTrace(id);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_TRACE should attach the id as meta', () => {
const { meta } = jaegerApiActions.fetchTrace(id);
expect(meta.id).toBe(id);
Expand All @@ -59,6 +67,11 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/FETCH_MULTIPLE_TRACES should return the promise', () => {
const { payload } = jaegerApiActions.fetchMultipleTraces(ids);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_MULTIPLE_TRACES should attach the ids as meta', () => {
const { meta } = jaegerApiActions.fetchMultipleTraces(ids);
expect(meta.ids).toBe(ids);
Expand All @@ -70,6 +83,11 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/ARCHIVE_TRACE should return the promise', () => {
const { payload } = jaegerApiActions.archiveTrace(id);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/ARCHIVE_TRACE should attach the id as meta', () => {
const { meta } = jaegerApiActions.archiveTrace(id);
expect(meta.id).toBe(id);
Expand All @@ -81,11 +99,21 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/SEARCH_TRACES should return the promise', () => {
const { payload } = jaegerApiActions.searchTraces(query);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/SEARCH_TRACES should attach the query as meta', () => {
const { meta } = jaegerApiActions.searchTraces(query);
expect(meta.query).toEqual(query);
});

it('@JAEGER_API/FETCH_SERVICES should return a promise', () => {
const { payload } = jaegerApiActions.fetchServices();
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_SERVICE_OPERATIONS should call the JaegerAPI', () => {
const called = mock.expects('fetchServiceOperations').once().withExactArgs('service');
jaegerApiActions.fetchServiceOperations('service');
Expand All @@ -104,6 +132,11 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/FETCH_DEEP_DEPENDENCY_GRAPH should return the promise', () => {
const { payload } = jaegerApiActions.fetchDeepDependencyGraph(query);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_DEEP_DEPENDENCY_GRAPH should attach the query as meta', () => {
const { meta } = jaegerApiActions.fetchDeepDependencyGraph(query);
expect(meta.query).toEqual(query);
Expand All @@ -115,6 +148,11 @@ describe('actions/jaeger-api', () => {
expect(called.verify()).toBeTruthy();
});

it('@JAEGER_API/FETCH_ALL_SERVICE_METRICS should return the promise', () => {
const { payload } = jaegerApiActions.fetchAllServiceMetrics('serviceName', query);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_ALL_SERVICE_METRICS should fetch service metrics by name', () => {
mock.expects('fetchMetrics');
mock.expects('fetchMetrics');
Expand All @@ -125,6 +163,11 @@ describe('actions/jaeger-api', () => {
expect(() => mock.verify()).not.toThrow();
});

it('@JAEGER_API/FETCH_AGGREGATED_SERVICE_METRICS should return the promise', () => {
const { payload } = jaegerApiActions.fetchAggregatedServiceMetrics('serviceName', query);
expect(isPromise(payload)).toBeTruthy();
});

it('@JAEGER_API/FETCH_AGGREGATED_SERVICE_METRICS should fetch service metrics by name', () => {
mock.expects('fetchMetrics');
mock.expects('fetchMetrics');
Expand Down

0 comments on commit 8d7ac3b

Please sign in to comment.