@@ -0,0 +1,26 @@
|
||||
{
|
||||
"configMaps": [
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"metadata": {
|
||||
"name": "app-config",
|
||||
"namespace": "default",
|
||||
"uid": "1ea073bc-7a4b-4b99-8321-0305bce85568",
|
||||
"resourceVersion": "1362732552",
|
||||
"creationTimestamp": "2021-07-16T22:39:58Z",
|
||||
"labels": {
|
||||
"backstage.io/kubernetes-id": "dice-roller",
|
||||
"app": "dice-roller"
|
||||
},
|
||||
"annotations": {}
|
||||
},
|
||||
"data": {
|
||||
"database.host": "localhost",
|
||||
"database.port": "5432",
|
||||
"app.name": "dice-roller",
|
||||
"app.version": "1.0.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"configMaps": [
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"metadata": {
|
||||
"name": "app-config",
|
||||
"namespace": "default",
|
||||
"uid": "1ea073bc-7a4b-4b99-8321-0305bce85568",
|
||||
"resourceVersion": "1362732552",
|
||||
"creationTimestamp": "2021-07-16T22:39:58Z",
|
||||
"labels": {
|
||||
"backstage.io/kubernetes-id": "dice-roller",
|
||||
"app": "dice-roller"
|
||||
},
|
||||
"annotations": {}
|
||||
},
|
||||
"data": {
|
||||
"database.host": "localhost",
|
||||
"database.port": "5432",
|
||||
"app.name": "dice-roller",
|
||||
"app.version": "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"metadata": {
|
||||
"name": "redis-config",
|
||||
"namespace": "default",
|
||||
"uid": "2ea073bc-7a4b-4b99-8321-0305bce85568",
|
||||
"resourceVersion": "1362732553",
|
||||
"creationTimestamp": "2021-07-16T22:40:58Z",
|
||||
"labels": {
|
||||
"backstage.io/kubernetes-id": "dice-roller",
|
||||
"app": "redis"
|
||||
},
|
||||
"annotations": {}
|
||||
},
|
||||
"data": {
|
||||
"redis.conf": "# Redis configuration\nmaxmemory 256mb\nmaxmemory-policy allkeys-lru",
|
||||
"redis.host": "redis-service",
|
||||
"redis.port": "6379"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2021 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { screen } from '@testing-library/react';
|
||||
import { ConfigmapsAccordions } from './ConfigmapsAccordions';
|
||||
import * as oneConfigmapsFixture from '../../__fixtures__/1-configmaps.json';
|
||||
import * as twoConfigmapsFixture from '../../__fixtures__/2-configmaps.json';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { kubernetesProviders } from '../../hooks/test-utils';
|
||||
|
||||
describe('ConfigmapsAccordions', () => {
|
||||
it('should render 1 configmap', async () => {
|
||||
const wrapper = kubernetesProviders(
|
||||
oneConfigmapsFixture,
|
||||
new Set<string>(),
|
||||
);
|
||||
|
||||
await renderInTestApp(wrapper(<ConfigmapsAccordions />));
|
||||
|
||||
expect(screen.getByText('app-config')).toBeInTheDocument();
|
||||
expect(screen.getByText('ConfigMap')).toBeInTheDocument();
|
||||
expect(screen.getByText('namespace: default')).toBeInTheDocument();
|
||||
expect(screen.getByText('Data Count: 4')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render 2 configmaps', async () => {
|
||||
const wrapper = kubernetesProviders(
|
||||
twoConfigmapsFixture,
|
||||
new Set<string>(),
|
||||
);
|
||||
|
||||
await renderInTestApp(wrapper(<ConfigmapsAccordions />));
|
||||
|
||||
expect(screen.getByText('app-config')).toBeInTheDocument();
|
||||
expect(screen.getByText('redis-config')).toBeInTheDocument();
|
||||
expect(screen.getAllByText('ConfigMap')).toHaveLength(2);
|
||||
expect(screen.getAllByText('namespace: default')).toHaveLength(2);
|
||||
expect(screen.getByText('Data Count: 4')).toBeInTheDocument();
|
||||
expect(screen.getByText('Data Count: 3')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2021 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as oneConfigmapsFixture from '../../__fixtures__/1-configmaps.json';
|
||||
import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
|
||||
import { ConfigmapsDrawer } from './ConfigmapsDrawer';
|
||||
import { kubernetesClusterLinkFormatterApiRef } from '../../api';
|
||||
|
||||
describe('ConfigmapsDrawer', () => {
|
||||
it('should render configmap drawer', async () => {
|
||||
const { getByText, getAllByText } = await renderInTestApp(
|
||||
<TestApiProvider apis={[[kubernetesClusterLinkFormatterApiRef, {}]]}>
|
||||
<ConfigmapsDrawer
|
||||
configmap={(oneConfigmapsFixture as any).configMaps[0]}
|
||||
expanded
|
||||
/>
|
||||
</TestApiProvider>,
|
||||
);
|
||||
|
||||
expect(getAllByText('app-config')).toHaveLength(3);
|
||||
expect(getAllByText('ConfigMap')).toHaveLength(3);
|
||||
expect(getByText('YAML')).toBeInTheDocument();
|
||||
expect(getByText('namespace: default')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user