Skip to content

Commit

Permalink
ci: add optionsWithDefault testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Feb 8, 2025
1 parent 2dcd84b commit a10533d
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/options.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { describe, expect, it } from "vitest";

import type { Options } from "./options";

import { optionsWithDefault } from "./options";

describe("optionsWithDefault", () => {
it("should return default options when no user options are provided", () => {
const result = optionsWithDefault();
const expected: Options = {
cwd: process.cwd(),
todoFile: ".eslint-todo.js",
};
expect(result).toStrictEqual(expected);
});

it("should override default options with user options", () => {
const userOptions = {
todoFile: "custom-todo.js",
};
const result = optionsWithDefault(userOptions);
const expected: Options = {
cwd: process.cwd(),
todoFile: "custom-todo.js",
};
expect(result).toStrictEqual(expected);
});

it("should handle partial user options", () => {
const userOptions = {
cwd: "/custom/path",
};
const result = optionsWithDefault(userOptions);
const expected: Options = {
cwd: "/custom/path",
todoFile: ".eslint-todo.js",
};
expect(result).toStrictEqual(expected);
});

it("should respect all user options", () => {
const userOptions = {
cwd: "/custom/path",
todoFile: "custom-todo.js",
};
const result = optionsWithDefault(userOptions);
const expected: Options = {
cwd: "/custom/path",
todoFile: "custom-todo.js",
};
expect(result).toStrictEqual(expected);
});
});

0 comments on commit a10533d

Please sign in to comment.