test: add config and config related tests
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SettingKey, getConfigSection, getSettingDefault } from "./config";
|
||||
|
||||
describe("config", () => {
|
||||
it("getConfigSection returns the section prefix from package.json", () => {
|
||||
const section = getConfigSection();
|
||||
expect(typeof section).toBe("string");
|
||||
expect(section).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("getSettingDefault returns a non-empty default for projectPath", () => {
|
||||
const value = getSettingDefault("projectPath");
|
||||
expect(typeof value).toBe("string");
|
||||
expect(value).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("getSettingDefault returns a string for globalPath (may be empty)", () => {
|
||||
const value = getSettingDefault("globalPath");
|
||||
expect(typeof value).toBe("string");
|
||||
});
|
||||
|
||||
it("throws for missing setting key", () => {
|
||||
expect(() => getSettingDefault("missing" as SettingKey)).toThrow(
|
||||
"Missing package.json setting",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
MAX_TASK_TITLE_LENGTH,
|
||||
TASK_FILE_EXTENSION,
|
||||
TASK_LANGUAGE_ID,
|
||||
isTaskFileName,
|
||||
} from "./taskFile";
|
||||
|
||||
describe("taskFile", () => {
|
||||
it("package.json defines a non-empty file extension", () => {
|
||||
expect(typeof TASK_FILE_EXTENSION).toBe("string");
|
||||
expect(TASK_FILE_EXTENSION).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("package.json defines a non-empty language id", () => {
|
||||
expect(typeof TASK_LANGUAGE_ID).toBe("string");
|
||||
expect(TASK_LANGUAGE_ID).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it("max title length is a positive number", () => {
|
||||
expect(typeof MAX_TASK_TITLE_LENGTH).toBe("number");
|
||||
expect(Number.isFinite(MAX_TASK_TITLE_LENGTH)).toBe(true);
|
||||
expect(MAX_TASK_TITLE_LENGTH).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("isTaskFileName uses the configured extension", () => {
|
||||
expect(isTaskFileName(`task${TASK_FILE_EXTENSION}`)).toBe(true);
|
||||
expect(isTaskFileName(TASK_FILE_EXTENSION)).toBe(true);
|
||||
});
|
||||
|
||||
it("isTaskFileName rejects non-matching extensions", () => {
|
||||
expect(isTaskFileName("task.md")).toBe(false);
|
||||
expect(isTaskFileName("task.xflow")).toBe(false);
|
||||
});
|
||||
|
||||
it("isTaskFileName rejects empty string", () => {
|
||||
expect(isTaskFileName("")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user