@lerna/publish
Version:
Publish packages in the current project
69 lines (68 loc) • 2.86 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_node_fetch = __toESM(require("node-fetch"));
var import_gitlab_client = require("./gitlab-client");
jest.mock("node-fetch");
const fetch = jest.mocked(import_node_fetch.default);
describe("GitLabClient", () => {
describe("constructor", () => {
it("sets `baseUrl` and `token`", () => {
const client = new import_gitlab_client.GitLabClient("TOKEN", "http://some/host");
expect(client.baseUrl).toEqual("http://some/host");
expect(client.token).toEqual("TOKEN");
});
});
describe("releasesUrl", () => {
it("returns a GitLab releases API URL", () => {
const client = new import_gitlab_client.GitLabClient("TOKEN", "http://some/host");
const url = client.releasesUrl("the-namespace", "the-project");
expect(url).toEqual("http://some/host/projects/the-namespace%2Fthe-project/releases");
});
});
describe("createRelease", () => {
it("requests releases api with release", () => {
const client = new import_gitlab_client.GitLabClient("TOKEN", "http://some/host");
fetch.mockResolvedValue({ ok: true });
const release = {
owner: "the-owner",
repo: "the-repo",
name: "the-name",
tag_name: "the-tag_name",
body: "the-body"
};
client.createRelease(release);
expect(fetch).toHaveBeenCalledWith("http://some/host/projects/the-owner%2Fthe-repo/releases", {
method: "post",
body: JSON.stringify({
name: "the-name",
tag_name: "the-tag_name",
description: "the-body"
}),
headers: {
"PRIVATE-TOKEN": "TOKEN",
"Content-Type": "application/json"
}
});
});
});
});