tests(entityRouteParams): initial test suite

Signed-off-by: Tim Klever <tim.v.klever@aexp.com>
This commit is contained in:
Tim Klever
2025-04-01 19:00:21 -07:00
parent 32cbef5b4c
commit def696c310
+64
View File
@@ -0,0 +1,64 @@
/*
* Copyright 2025 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 { DEFAULT_NAMESPACE, Entity } from '@backstage/catalog-model';
import { entityRouteParams } from './routes';
const entity: Entity = {
apiVersion: '1',
kind: 'Component',
metadata: {
name: 'Test-Component',
},
};
const expectedEntityRouteParams = {
kind: 'component',
name: 'Test-Component',
namespace: DEFAULT_NAMESPACE,
};
const namespacedEntity = {
apiVersion: '1',
kind: 'Component',
metadata: {
name: 'Test-Namespaced-Component',
namespace: 'Test-Namespace',
},
};
const expectedNamespacedEntityRouteParams = {
kind: 'component',
name: 'Test-Namespaced-Component',
namespace: 'test-namespace',
};
describe('entityRouteParams', () => {
it.each([
['Entity', entity, expectedEntityRouteParams],
[
'namespaced Entity',
namespacedEntity,
expectedNamespacedEntityRouteParams,
],
])(
'should return correct route params for %s',
(_type, entityOrRef, expectedRouteParams) => {
const actualRouteParams = entityRouteParams(entityOrRef);
expect(actualRouteParams).toEqual(expectedRouteParams);
},
);
});