add a test
This commit is contained in:
parent
9b9c15ecc4
commit
f6141b139e
@ -62,7 +62,7 @@ const handler = async (config) => {
|
|||||||
config.consola.info("running in dry mode, not saving\n", next);
|
config.consola.info("running in dry mode, not saving\n", next);
|
||||||
} else {
|
} else {
|
||||||
await config.save_changelog(changelog);
|
await config.save_changelog(changelog);
|
||||||
if (changelog.project.next_directory) {
|
if (changelog.project?.next_directory) {
|
||||||
config.consola.info(
|
config.consola.info(
|
||||||
`removing files in ${changelog.project.next_directory}`
|
`removing files in ${changelog.project.next_directory}`
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,7 @@ import yaml from "yaml";
|
|||||||
import { render_release } from "./print.js";
|
import { render_release } from "./print.js";
|
||||||
|
|
||||||
export async function next_release() {
|
export async function next_release() {
|
||||||
const source = await fs.readFile(this.source, "utf-8").then(yaml.parse);
|
const source = await this.changelog();
|
||||||
return (
|
return (
|
||||||
source.releases.find(u.matches({ version: "NEXT" })) ?? {
|
source.releases.find(u.matches({ version: "NEXT" })) ?? {
|
||||||
version: "NEXT",
|
version: "NEXT",
|
||||||
@ -14,14 +14,14 @@ export async function next_release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handler = async (config) => {
|
const handler = async (config) => {
|
||||||
const source = await fs.readFile(config.source, "utf-8").then(yaml.parse);
|
const source = await config.changelog();
|
||||||
|
|
||||||
const res = render_release(
|
const { body } = render_release(
|
||||||
{ ...config, next: true },
|
{ ...config, next: true },
|
||||||
source
|
source
|
||||||
)(source.releases.find(u.matches({ version: "NEXT" })));
|
)(await config.next_release());
|
||||||
|
|
||||||
config.consola.raw("\n" + res.body);
|
config.consola.raw("\n" + body);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
29
src/command/upcoming.test.js
Normal file
29
src/command/upcoming.test.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { test, expect, vi } from "vitest";
|
||||||
|
import upcoming from "./upcoming.js";
|
||||||
|
|
||||||
|
test("basic", async () => {
|
||||||
|
const changelog = {
|
||||||
|
releases: [{ version: "NEXT", changes: [] }, { version: "1.0.0" }],
|
||||||
|
change_types: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
const config = {
|
||||||
|
consola: {
|
||||||
|
start: noop,
|
||||||
|
raw: vi.fn(),
|
||||||
|
},
|
||||||
|
changelog: () => changelog,
|
||||||
|
next_release: () => ({
|
||||||
|
changes: [],
|
||||||
|
}),
|
||||||
|
latest_version: () => ({ version: "1.2.3" }),
|
||||||
|
git: () => ({
|
||||||
|
log: () => ({ all: [] }),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
await upcoming.handler(config);
|
||||||
|
|
||||||
|
expect(config.consola.raw).toHaveBeenCalled();
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user