More test cases:
This commit is contained in:
parent
09b0ac8cd3
commit
8c5e8043f8
4 changed files with 63 additions and 12 deletions
|
@ -1,31 +1,58 @@
|
|||
import { renderCommitMessage } from "./template.js";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { renderCommitMessage, renderPullRequestBody } from "./template.js";
|
||||
import { template } from "handlebars";
|
||||
import { Test, describe, expect, test } from "vitest";
|
||||
|
||||
describe("templating", () => {
|
||||
test("commit message", () => {
|
||||
type TestCase = {
|
||||
template: string;
|
||||
flakeDotLockDir: string;
|
||||
flakeDotLock: string;
|
||||
expected: string;
|
||||
};
|
||||
|
||||
const testCases: TestCase[] = [
|
||||
{
|
||||
template: "Updating lockfile at {{ flake_dot_lock }}",
|
||||
template: "Updating flake.lock in dir {{ flake_dot_lock_dir }}",
|
||||
flakeDotLockDir: ".",
|
||||
flakeDotLock: "./flake.lock",
|
||||
expected: "Updating lockfile at ./flake.lock",
|
||||
expected: "Updating flake.lock in dir .",
|
||||
},
|
||||
{
|
||||
template:
|
||||
"Here I go doing some updating of my pristine flake.lock at {{ flake_dot_lock }}",
|
||||
flakeDotLockDir: "subflake",
|
||||
flakeDotLock: "subflake/flake.lock",
|
||||
expected:
|
||||
"Here I go doing some updating of my pristine flake.lock at subflake/flake.lock",
|
||||
},
|
||||
{
|
||||
template: "This variable doesn't exist: {{ foo }}",
|
||||
flakeDotLockDir: ".",
|
||||
flakeDotLock: "./flake.lock",
|
||||
expected: "This variable doesn't exist: ",
|
||||
},
|
||||
];
|
||||
|
||||
testCases.forEach(({ template, flakeDotLock, expected }) => {
|
||||
expect(renderCommitMessage(template, flakeDotLock)).toEqual(expected);
|
||||
testCases.forEach(
|
||||
({ template, flakeDotLockDir, flakeDotLock, expected }) => {
|
||||
expect(
|
||||
renderCommitMessage(template, flakeDotLockDir, flakeDotLock),
|
||||
).toEqual(expected);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("pull request body", () => {
|
||||
type TestCase = {
|
||||
template: string;
|
||||
expected: string;
|
||||
};
|
||||
|
||||
const testCases: TestCase[] = [];
|
||||
|
||||
testCases.forEach(({ template, expected }) => {
|
||||
expect(renderPullRequestBody(template)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue