-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from beezen/dev
fix: 优化环境异常时help日志不打印问题
- Loading branch information
Showing
25 changed files
with
859 additions
and
667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"presets": ["@babel/env"], | ||
"plugins": ["@babel/plugin-transform-runtime"] | ||
} | ||
"presets": [ | ||
"@babel/preset-env" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-transform-runtime" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,52 @@ | ||
import { addUser, getUserList, removeUser, changeUser } from "../../src/actions/base.js"; | ||
import { getConfig, getRegistryConfig, prepareEnv } from "../../src/common"; | ||
import { addUser, getUserList, removeUser, changeUser } from "../../src/actions/base"; | ||
import { getConfig, getRegistryConfig, prepareEnv, initLanguage } from "../../src/common"; | ||
import type { BaseConfig, RegistryConfig } from "../../src/common"; | ||
|
||
describe("action_base", () => { | ||
const name1 = "example1"; | ||
const name2 = "example2"; | ||
const token1 = "example_token1"; | ||
const token2 = "example_token2"; | ||
prepareEnv(() => { | ||
let config = getConfig(); | ||
let nucmrcConfig = config.nucm; | ||
let registryName = getRegistryConfig(config).registryName; | ||
let accountObject = nucmrcConfig[registryName]; | ||
let currentAccountName = ""; // 当前账号名 | ||
Object.keys(accountObject).forEach((name) => { | ||
if (accountObject[name]["is-current"]) { | ||
currentAccountName = name; | ||
} | ||
}); | ||
it("addUser", () => { | ||
addUser(name1, token1); | ||
addUser(name2, token2); | ||
config = getConfig(); | ||
expect(config.nucm[registryName][name1]).toBeDefined(); | ||
expect(config.nucm[registryName][name2]).toBeDefined(); | ||
}); | ||
initLanguage(); | ||
prepareEnv()(); | ||
let config = getConfig() as BaseConfig; | ||
let nucmrcConfig = config.nucm; | ||
let registryName = (getRegistryConfig(config) as RegistryConfig).registryName; | ||
let accountObject = nucmrcConfig?.[registryName]; | ||
let currentAccountName = ""; // 当前账号名 | ||
Object.keys(accountObject).forEach((name) => { | ||
if (accountObject[name]["is-current"]) { | ||
currentAccountName = name; | ||
} | ||
}); | ||
it("addUser", () => { | ||
addUser(name1, token1); | ||
addUser(name2, token2); | ||
config = getConfig(); | ||
expect(config.nucm?.[registryName][name1]).toBeDefined(); | ||
expect(config.nucm?.[registryName][name2]).toBeDefined(); | ||
}); | ||
|
||
it("changeUser", () => { | ||
expect(config.nucm[registryName][name1]["is-current"]).toBeUndefined(); | ||
changeUser(name2); | ||
config = getConfig(); | ||
expect(config.nucm[registryName][name2]["is-current"]).toBeDefined(); | ||
}); | ||
it("changeUser", () => { | ||
expect(config.nucm?.[registryName][name1]["is-current"]).toBeUndefined(); | ||
changeUser(name2); | ||
config = getConfig(); | ||
expect(config.nucm?.[registryName][name2]["is-current"]).toBeDefined(); | ||
}); | ||
|
||
it("removeUser", () => { | ||
removeUser(name1); | ||
config = getConfig(); | ||
expect(config.nucm[registryName][name1]).toBeUndefined(); | ||
}); | ||
it("removeUser", () => { | ||
removeUser(name1); | ||
config = getConfig(); | ||
expect(config.nucm?.[registryName][name1]).toBeUndefined(); | ||
}); | ||
|
||
it("getUserList", () => { | ||
expect(getUserList({}).indexOf(name2) > -1).toBeTruthy(); | ||
expect(getUserList({ all: true }).indexOf(name2) > -1).toBeTruthy(); | ||
}); | ||
// 还原单测前状态 | ||
it("backup", () => { | ||
removeUser(name2); | ||
changeUser(currentAccountName); | ||
}); | ||
it("getUserList", () => { | ||
expect(getUserList({}).indexOf(name2) > -1).toBeTruthy(); | ||
expect(getUserList({ all: true }).indexOf(name2) > -1).toBeTruthy(); | ||
}); | ||
// 还原单测前状态 | ||
it("backup", () => { | ||
removeUser(name2); | ||
changeUser(currentAccountName); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.