Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8af064c

Browse files
committed
setup arg tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent36fd3f1 commit8af064c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎tests/args.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import{getArg}from"../src/utils/args";
2+
3+
describe("args",()=>{
4+
it("should capture an arg name from text",()=>{
5+
constargs=["--name","value"];
6+
constresult=getArg(args,{name:"name"});
7+
expect(result).toBe("value");
8+
});
9+
it("should capture an arg alias from text",()=>{
10+
constargs=["-n","value"];
11+
constresult=getArg(args,{name:"name",alias:"n"});
12+
expect(result).toBe("value");
13+
});
14+
it("should capture an arg name from text when starting values",()=>{
15+
constargs=["dir","--name","value"];
16+
constresult=getArg(args,{name:"name"});
17+
expect(result).toBe("value");
18+
});
19+
it("should capture an arg alias from text",()=>{
20+
constargs=["dir","-n","value"];
21+
constresult=getArg(args,{name:"name",alias:"n"});
22+
expect(result).toBe("value");
23+
});
24+
it("should default value to true if no next value",()=>{
25+
constargs=["--someBool"];
26+
constresult=getArg(args,{
27+
name:"someBool",
28+
alias:"sb",
29+
type:"bool",
30+
});
31+
expect(result).toBe(true);
32+
});
33+
it("should default value to true if next value is param",()=>{
34+
constargs=["--someBool","--someOtherBool"];
35+
constresult=getArg(args,{
36+
name:"someBool",
37+
alias:"sb",
38+
type:"bool",
39+
});
40+
expect(result).toBe(true);
41+
});
42+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp