@@ -20,6 +20,7 @@ import {
|
||||
isKind,
|
||||
isNamespace,
|
||||
isResourceType,
|
||||
isApiType,
|
||||
isEntityWith,
|
||||
} from './conditions';
|
||||
|
||||
@@ -65,6 +66,27 @@ const notComponent: Entity = {
|
||||
spec: { type: 'service' },
|
||||
};
|
||||
|
||||
const graphqlApi: Entity = {
|
||||
apiVersion: '',
|
||||
kind: 'api',
|
||||
metadata: { name: 'aProtocol' },
|
||||
spec: { type: 'graphql' },
|
||||
};
|
||||
|
||||
const grpcApi: Entity = {
|
||||
apiVersion: '',
|
||||
kind: 'api',
|
||||
metadata: { name: 'aProtocol' },
|
||||
spec: { type: 'grpc' },
|
||||
};
|
||||
|
||||
const notApi: Entity = {
|
||||
apiVersion: '',
|
||||
kind: 'not-api',
|
||||
metadata: { name: 'aProtocol' },
|
||||
spec: { type: 'grpc' },
|
||||
};
|
||||
|
||||
const missingSpecType: Entity = {
|
||||
apiVersion: '',
|
||||
kind: 'another-type',
|
||||
@@ -133,6 +155,26 @@ describe('isComponentType', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isApiType', () => {
|
||||
it('should false on non API kinds', () => {
|
||||
const checkEntity = isApiType('openapi');
|
||||
|
||||
expect(checkEntity(notApi)).not.toBeTruthy();
|
||||
});
|
||||
it('should check for the intended type', () => {
|
||||
const checkEntity = isApiType('grpc');
|
||||
|
||||
expect(checkEntity(graphqlApi)).not.toBeTruthy();
|
||||
expect(checkEntity(grpcApi)).toBeTruthy();
|
||||
});
|
||||
it('should check for multiple types', () => {
|
||||
const checkEntity = isApiType(['grpc', 'graphql']);
|
||||
|
||||
expect(checkEntity(graphqlApi)).toBeTruthy();
|
||||
expect(checkEntity(grpcApi)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isEntityWith', () => {
|
||||
it('allows for a kind-only check (empty type array)', () => {
|
||||
const checkEntity = isEntityWith({ kind: 'api', type: [] });
|
||||
|
||||
Reference in New Issue
Block a user