2023-01-26 03:03:44 +00:00
|
|
|
import { EnvironmentType } from '@/react/portainer/environments/types';
|
|
|
|
|
|
|
|
import { EditorType } from './types';
|
|
|
|
import { getValidEditorTypes } from './utils';
|
|
|
|
|
|
|
|
interface GetValidEditorTypesTest {
|
|
|
|
endpointTypes: EnvironmentType[];
|
|
|
|
expected: EditorType[];
|
|
|
|
title: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('getValidEditorTypes', () => {
|
|
|
|
const tests: GetValidEditorTypesTest[] = [
|
|
|
|
{
|
|
|
|
endpointTypes: [EnvironmentType.EdgeAgentOnDocker],
|
|
|
|
expected: [EditorType.Compose],
|
|
|
|
title: 'should return compose for docker envs',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
endpointTypes: [EnvironmentType.EdgeAgentOnKubernetes],
|
|
|
|
expected: [EditorType.Kubernetes],
|
|
|
|
title: 'should return kubernetes for kubernetes envs',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
endpointTypes: [
|
|
|
|
EnvironmentType.EdgeAgentOnDocker,
|
|
|
|
EnvironmentType.EdgeAgentOnKubernetes,
|
|
|
|
],
|
|
|
|
expected: [],
|
|
|
|
title: 'should return empty for docker and kubernetes envs',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
tests.forEach((test) => {
|
2024-01-23 06:42:52 +00:00
|
|
|
// eslint-disable-next-line vitest/valid-title
|
2023-01-26 03:03:44 +00:00
|
|
|
it(test.title, () => {
|
|
|
|
expect(getValidEditorTypes(test.endpointTypes)).toEqual(test.expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|