Skip to content

Commit

Permalink
chore: Rename KubeObject tests to better clarity
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <[email protected]>
  • Loading branch information
Nokel81 committed May 25, 2023
1 parent e7b030e commit 4e6b51e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/kube-object/src/kube-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ const getStubData = () => ({
});

describe("kube object tests", () => {
it("should allow an object to be created when missing uid", () => {
it("given '.metadata.uid' is missing, then KubeObject constructor does not throw", () => {
const data = getStubData();

delete data.metadata.uid;
expect(() => new KubeObject(data)).not.toThrow();
});

it("should allow an object to be created when missing resourceVersion", () => {
it("given '.metadata.resourceVersion' is missing, then KubeObject constructor does not throw", () => {
const data = getStubData();

delete data.metadata.resourceVersion;
expect(() => new KubeObject(data)).not.toThrow();
});

it("should allow an object to be created when missing resourceVersion and uid", () => {
it("given both '.metadata.resourceVersion' and '.metadata.uid' are missing, then KubeObject constructor does not throw", () => {
const data = getStubData();

delete data.metadata.uid;
delete data.metadata.resourceVersion;
expect(() => new KubeObject(data)).not.toThrow();
});

it("KubeObject.getId() should return the uid if present", () => {
it("given '.metadata.uid' exist, then KubeObject.getId() should return it", () => {
const data = getStubData();
const obj = new KubeObject(data);

expect(obj.getId()).toEqual("123");
});

it("KubeObject.getId() should return the selfLink if uid is missing", () => {
it("given '.metadata.uid' is missing, then KubeObject.getId() should return '.metadata.selfLink'", () => {
const data = getStubData();

delete data.metadata.uid;
Expand All @@ -54,14 +54,14 @@ describe("kube object tests", () => {
);
});

it("KubeObject.getResourceVersion() should return the resourceVersion if it is present", () => {
it("given '.metadata.resourceVersion' exist, then KubeObject.getResourceVersion() should return it", () => {
const data = getStubData();
const obj = new KubeObject(data);

expect(obj.getResourceVersion()).toEqual("foobar");
});

it("KubeObject.getResourceVersion() should return '' if the resourceVersion is missing", () => {
it("given '.metadata.resourceVersion' is missing, then KubeObject.getResourceVersion() should return an empty string", () => {
const data = getStubData();

delete data.metadata.resourceVersion;
Expand Down

0 comments on commit 4e6b51e

Please sign in to comment.