@auto-it/package-json-utils
Version:
Shared utilities for parsing information from a package.json
42 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const packageJsonSpy = _1.loadPackageJson;
jest.mock("../src/utils");
test("should return nothing without a repo", async () => {
packageJsonSpy.mockReturnValueOnce({});
expect(await _1.getRepo()).toBeUndefined();
});
test("should return nothing without an owner", async () => {
packageJsonSpy.mockReturnValueOnce({
repository: { url: "fake.com" },
});
expect(await _1.getRepo()).toBeUndefined();
});
test("should return nothing without an package name", async () => {
packageJsonSpy.mockReturnValueOnce({
repository: { url: "fake.com" },
});
expect(await _1.getRepo()).toBeUndefined();
});
test("should correctly parse package info", async () => {
packageJsonSpy.mockReturnValueOnce({
version: "1.0.0",
repository: { url: "https://github.com/black-panther/operation-foo" },
});
expect(await _1.getRepo()).toStrictEqual({
repo: "operation-foo",
owner: "black-panther",
});
});
test("should correctly parse package info - string", async () => {
packageJsonSpy.mockReturnValueOnce({
version: "1.0.0",
repository: "black-panther/operation-foo",
});
expect(await _1.getRepo()).toStrictEqual({
repo: "operation-foo",
owner: "black-panther",
});
});
//# sourceMappingURL=index.test.js.map