Skip to content

Commit

Permalink
Update: config
Browse files Browse the repository at this point in the history
  • Loading branch information
ikepu-tp committed Sep 2, 2023
1 parent 56451df commit 79283e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/config.test.ts
Expand Up @@ -55,7 +55,7 @@ jest.mock("node:fs/promises", () => {
writeFile: jest.fn((filePath: string, text: string) => {
setFile(filePath, text);
}),
mkdir: jest.fn(() => {}),
mkdir: jest.fn(() => { }),
};
});
jest.mock("node:fs", () => {
Expand Down Expand Up @@ -224,6 +224,8 @@ describe("config", () => {
beforeEach(() => {
const userConfigData = {
includePrivate: true,
address: "localhost",
family: "IPv4",
port: 9999,
};
resetFiles();
Expand All @@ -234,6 +236,8 @@ describe("config", () => {
const userConfig = await config.getUserConfig();
expect(userConfig).toStrictEqual({
includePrivate: true,
address: "localhost",
family: "IPv4",
port: 9999,
});
});
Expand All @@ -248,6 +252,8 @@ describe("config", () => {
const userConfig = await config.getUserConfig();
expect(userConfig).toStrictEqual({
includePrivate: false,
address: "localhost",
family: "IPv4",
port: 8888,
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config.ts
Expand Up @@ -14,6 +14,8 @@ interface Options {

type UserConfig = {
includePrivate: boolean;
address: string;
family: string;
port: number;
};

Expand Down Expand Up @@ -107,6 +109,8 @@ class Config {
async getUserConfig() {
const defaultConfig = {
includePrivate: false,
address: "localhost",
family: "IPv4",
port: 8888,
} as UserConfig;

Expand Down

0 comments on commit 79283e6

Please sign in to comment.