k8s-deploy/src/inputUtils.test.ts
David Gamero 99510dff95
case-insensitive resource type (#398)
* case-insensitive resource type

* inline error and throw outside switch

* consistent input naming

* catch failed clustertype parse

* protect raw input

* naming

* format
2025-04-16 11:47:29 -04:00

35 lines
1.1 KiB
TypeScript

import {parseResourceTypeInput} from './inputUtils'
import {
ClusterType,
ResourceTypeFleet,
ResourceTypeManagedCluster
} from './actions/deploy'
describe('InputUtils', () => {
describe('parseResourceTypeInput', () => {
it('should extract fleet exact match resource type', () => {
expect(
parseResourceTypeInput('Microsoft.ContainerService/fleets')
).toEqual(ResourceTypeFleet)
})
it('should match fleet case-insensitively', () => {
expect(
parseResourceTypeInput('Microsoft.containerservice/fleets')
).toEqual(ResourceTypeFleet)
})
it('should match managed cluster case-insensitively', () => {
expect(
parseResourceTypeInput('Microsoft.containerservice/MAnaGedClusterS')
).toEqual(ResourceTypeManagedCluster)
})
it('should error on unexpected values', () => {
expect(() => {
parseResourceTypeInput('icrosoft.ContainerService/ManagedCluster')
}).toThrow()
expect(() => {
parseResourceTypeInput('wrong-value')
}).toThrow()
})
})
})