|
1 | 1 | import { describe, it } from 'node:test';
|
2 | 2 | import { deepEqual, deepStrictEqual, strictEqual } from 'node:assert';
|
3 |
| -import { V1CustomResourceDefinition, V1Namespace, V1Pod } from './api.js'; |
| 3 | +import { V1CustomResourceDefinition, V1Namespace } from './api.js'; |
4 | 4 | import { dumpYaml, loadAllYaml, loadYaml } from './yaml.js';
|
5 | 5 |
|
6 | 6 | describe('yaml', () => {
|
@@ -84,27 +84,22 @@ spec:
|
84 | 84 | const objects = loadAllYaml(yaml);
|
85 | 85 |
|
86 | 86 | strictEqual(objects.length, 3);
|
87 |
| - // Assert specific types for each object |
88 |
| - const ns = objects[0] as V1Namespace; |
89 |
| - const pod = objects[1] as V1Pod; |
90 |
| - const crd = objects[2] as V1CustomResourceDefinition; |
91 |
| - |
92 |
| - strictEqual(ns.kind, 'Namespace'); |
93 |
| - strictEqual(pod.kind, 'Pod'); |
94 |
| - strictEqual(ns.metadata!.name, 'some-namespace'); |
95 |
| - strictEqual(pod.metadata!.name, 'some-pod'); |
96 |
| - strictEqual(pod.metadata!.namespace, 'some-ns'); |
97 |
| - |
98 |
| - strictEqual(crd.apiVersion, 'apiextensions.k8s.io/v1'); |
99 |
| - strictEqual(crd.kind, 'CustomResourceDefinition'); |
100 |
| - strictEqual(crd.metadata!.name, 'my-crd.example.com'); |
| 87 | + strictEqual(objects[0].kind, 'Namespace'); |
| 88 | + strictEqual(objects[1].kind, 'Pod'); |
| 89 | + strictEqual(objects[0].metadata.name, 'some-namespace'); |
| 90 | + strictEqual(objects[1].metadata.name, 'some-pod'); |
| 91 | + strictEqual(objects[1].metadata.namespace, 'some-ns'); |
| 92 | + strictEqual(objects[2].apiVersion, 'apiextensions.k8s.io/v1'); |
| 93 | + strictEqual(objects[2].kind, 'CustomResourceDefinition'); |
| 94 | + strictEqual(objects[2].metadata!.name, 'my-crd.example.com'); |
101 | 95 | strictEqual(
|
102 |
| - crd.spec.versions[0]!.schema!.openAPIV3Schema!.properties!['foobar'].x_kubernetes_int_or_string, |
| 96 | + objects[2].spec.versions[0]!.schema!.openAPIV3Schema!.properties!['foobar'] |
| 97 | + .x_kubernetes_int_or_string, |
103 | 98 | true,
|
104 | 99 | );
|
105 | 100 | strictEqual(
|
106 |
| - crd.spec.versions[0]!.schema!.openAPIV3Schema!.properties!['foobar'][ |
107 |
| - 'x-kubernetes-int-or-string' // This access is still on the parsed object before type mapping, hence `undefined` is correct |
| 101 | + objects[2].spec.versions[0]!.schema!.openAPIV3Schema!.properties!['foobar'][ |
| 102 | + 'x-kubernetes-int-or-string' |
108 | 103 | ],
|
109 | 104 | undefined,
|
110 | 105 | );
|
|
0 commit comments