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

Commit1613c44

Browse files
committed
Setup some tests
1 parentc5679b7 commit1613c44

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

‎tests/index.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import{exec}from"child_process";
2+
import{promisify}from"util";
3+
import{expect,use}from"chai";
4+
importchaiAsPromised= require("chai-as-promised");
5+
6+
use(chaiAsPromised);
7+
8+
/**
9+
* Returns a boolean indicating whether the given command ran successfully or not.
10+
*@param args
11+
*/
12+
asyncfunctionrunCommandWithArgs(args:string[]):Promise<boolean>{
13+
constchildProcPromise=promisify(exec)(
14+
["node","dist/index.js", ...args].join(" ")
15+
);
16+
try{
17+
awaitchildProcPromise;
18+
}catch(e:unknown){
19+
returnfalse;
20+
}
21+
22+
returntrue;
23+
}
24+
25+
asyncfunctionrunCommandWithArgsForOutput(
26+
args:string[]
27+
):Promise<{stdout:string;stderr:string}>{
28+
constchildProcPromise=promisify(exec)(
29+
["node","dist/index.js", ...args].join(" ")
30+
);
31+
try{
32+
returnawaitchildProcPromise;
33+
}catch(e:any){
34+
// Error object has stdout/stderr
35+
returne;
36+
}
37+
}
38+
39+
describe("github-run-script base tests",()=>{
40+
it("should not run with no arguments",()=>
41+
expect(runCommandWithArgs([])).to.eventually.equal(false));
42+
it("should do nothing",()=>
43+
expect(runCommandWithArgs(["env"])).to.eventually.equal(true));
44+
it("should have the repo name",()=>
45+
expect(
46+
runCommandWithArgsForOutput(["env","PythonCoderAS/github-run-script"])
47+
)
48+
.to.eventually.have.property("stdout")
49+
.which.contain("PythonCoderAS/github-run-script"));
50+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp