Files
archived-tauri-github-bot/__tests__/command.spec.ts
2022-08-26 14:51:34 +02:00

29 lines
967 B
TypeScript

// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { it, expect, describe } from "vitest";
import { COMMAND_REGEX } from "../src/constants";
describe("Parses command info from a GitHub comment", () => {
it("Parses upstream command", async () => {
const comment = "/upstream tauri-apps/tao";
const [, command, owner, repo] = COMMAND_REGEX.exec(comment)!;
expect(command).toBe("upstream");
expect(owner).toBe("tauri-apps");
expect(repo).toBe("tao");
});
it("Parses nothing from a slash predicated comment ", async () => {
const comment = "/downstream rust-lang/rust";
const matches = COMMAND_REGEX.exec(comment);
expect(matches).toBeNull();
});
it("Parses nothing", async () => {
const comment = "fasdk asfjadf asd;klajsdf qwrpo";
const matches = COMMAND_REGEX.exec(comment);
expect(matches).toBeNull();
});
});