Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): upgrade compiler dependencies #2858

Merged
merged 3 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export class ApiObjectMetadataDefinition {

constructor(options: ApiObjectMetadataDefinitionOptions) {
this.name = options.name;
this.labels = { ...options.labels } ?? { };
this.annotations = { ...options.annotations } ?? { };
this.labels = { ...(options.labels ?? {}) };
this.annotations = { ...(options.annotations ?? {}) };
this.namespace = options.namespace;
this.finalizers = options.finalizers ? [...options.finalizers] : [];
this.ownerReferences = options.ownerReferences ? [...options.ownerReferences] : [];
Expand Down
58 changes: 33 additions & 25 deletions test/metadata.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { ApiObject, ApiObjectMetadataDefinition, Lazy, OwnerReference, Testing } from '../src';
import {
ApiObject,
ApiObjectMetadataDefinition,
Lazy,
OwnerReference,
Testing,
} from '../src';

test('Can add a label', () => {

const meta = new ApiObjectMetadataDefinition({ apiObject: createApiObject() });
const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
});

meta.addLabel('key', 'value');

Expand All @@ -11,12 +18,12 @@ test('Can add a label', () => {
expect(actual.labels).toEqual({
key: 'value',
});

});

test('Can add an annotation', () => {

const meta = new ApiObjectMetadataDefinition({ apiObject: createApiObject() });
const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
});

meta.addAnnotation('key', 'value');

Expand All @@ -25,24 +32,24 @@ test('Can add an annotation', () => {
expect(actual.annotations).toEqual({
key: 'value',
});

});

test('Can add a finalizer', () => {

const meta = new ApiObjectMetadataDefinition({ apiObject: createApiObject() });
const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
});

meta.addFinalizers('my-finalizer');

const actual = meta.toJson();

expect(actual.finalizers).toEqual(['my-finalizer']);

});

test('Can add an owner reference', () => {

const meta = new ApiObjectMetadataDefinition({ apiObject: createApiObject() });
const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
});

meta.addOwnerReference({
apiVersion: 'v1',
Expand All @@ -53,17 +60,17 @@ test('Can add an owner reference', () => {

const actual = meta.toJson();

expect(actual.ownerReferences).toEqual([{
apiVersion: 'v1',
kind: 'Pod',
name: 'mypod',
uid: 'abcdef12-3456-7890-abcd-ef1234567890',
}]);

expect(actual.ownerReferences).toEqual([
{
apiVersion: 'v1',
kind: 'Pod',
name: 'mypod',
uid: 'abcdef12-3456-7890-abcd-ef1234567890',
},
]);
});

test('Instantiation properties are all respected', () => {

const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
labels: { key: 'value' },
Expand All @@ -86,17 +93,19 @@ test('Instantiation properties are all respected', () => {
};

expect(actual).toStrictEqual(expected);

});

test('ensure Lazy properties are resolved', () => {

const meta = new ApiObjectMetadataDefinition({
apiObject: createApiObject(),
labels: { key: 'value' },
annotations: {
key: 'value',
lazy: Lazy.any({ produce: () => { return { uiMeta: 'is good' }; } }),
lazy: Lazy.any({
produce: () => {
return { uiMeta: 'is good' };
},
}),
},
name: 'name',
namespace: 'namespace',
Expand All @@ -119,7 +128,6 @@ test('ensure Lazy properties are resolved', () => {
};

expect(actual).toStrictEqual(expected);

});

test('Can include arbirary key/value options', () => {
Expand Down Expand Up @@ -249,4 +257,4 @@ function createApiObject(): ApiObject {
apiVersion: 'v1',
kind: 'Service',
});
}
}
13 changes: 9 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading