|
| 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 | +}); |