Skip to content

Commit

Permalink
chore: add test for when capability is schedule (#693)
Browse files Browse the repository at this point in the history
## Description

Add unit test around if capability has schedule

## Related Issue

Fixes #
<!-- or -->
Relates to #

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/pepr/blob/main/CONTRIBUTING.md#submitting-a-pull-request)
followed

---------

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
Co-authored-by: Barrett <81570928+btlghrants@users.noreply.github.com>
  • Loading branch information
cmwylie19 and btlghrants committed Mar 29, 2024
1 parent 84b9726 commit 12add49
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/lib/module.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors

import { beforeEach, expect, jest, test } from "@jest/globals";
import { beforeEach, expect, jest, test, describe } from "@jest/globals";
import { clone } from "ramda";
import { Capability } from "./capability";

import { Schedule } from "./schedule";
import { Errors } from "./errors";
import { PackageJSON, PeprModule } from "./module";
import { CapabilityExport } from "./types";
Expand Down Expand Up @@ -98,3 +98,29 @@ test("should send the capabilities to the parent process if PEPR_MODE is set to
new PeprModule(packageJSON, [capability]);
expect(sendMock).toHaveBeenCalledWith([expected]);
});

describe("Capability", () => {
let capability: Capability;
let schedule: Schedule;

beforeEach(() => {
capability = new Capability({
name: "test",
description: "test",
});
schedule = {
name: "test-name",
every: 1,
unit: "seconds",
run: jest.fn(),
startTime: new Date(),
completions: 1,
};
});

test("should handle OnSchedule", () => {
const { OnSchedule } = capability;
OnSchedule(schedule);
expect(capability.hasSchedule).toBe(true);
});
});

0 comments on commit 12add49

Please sign in to comment.