| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,10 +29,13 @@ test.serial( | |||
| 29 | 29 | process.env["GITHUB_SHA"] = currentSha; | |
| 30 | 30 | ||
| 31 | 31 | const callback = sinon.stub(gitUtils, "getCommitOid"); | |
| 32 | - callback.withArgs("HEAD").resolves(currentSha); | ||
| 32 | + callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha); | ||
| 33 | 33 | ||
| 34 | 34 | const actualRef = await gitUtils.getRef(); | |
| 35 | 35 | t.deepEqual(actualRef, expectedRef); | |
| 36 | + | ||
| 37 | + t.is(callback.callCount, 1); | ||
| 38 | + t.true(callback.calledOnceWith(tmpDir, "HEAD")); | ||
| 36 | 39 | }); | |
| 37 | 40 | }, | |
| 38 | 41 | ); | |
@@ -48,11 +51,17 @@ test.serial( | |||
| 48 | 51 | const sha = "a".repeat(40); | |
| 49 | 52 | ||
| 50 | 53 | const callback = sinon.stub(gitUtils, "getCommitOid"); | |
| 51 | - callback.withArgs("refs/remotes/pull/1/merge").resolves(sha); | ||
| 52 | - callback.withArgs("HEAD").resolves(sha); | ||
| 54 | + callback | ||
| 55 | + .withArgs(sinon.match.string, "refs/remotes/pull/1/merge") | ||
| 56 | + .resolves(sha); | ||
| 57 | + callback.withArgs(sinon.match.any, "HEAD").resolves(sha); | ||
| 53 | 58 | ||
| 54 | 59 | const actualRef = await gitUtils.getRef(); | |
| 55 | 60 | t.deepEqual(actualRef, expectedRef); | |
| 61 | + | ||
| 62 | + t.is(callback.callCount, 2); | ||
| 63 | + t.true(callback.calledWith(tmpDir, "HEAD")); | ||
| 64 | + t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); | ||
| 56 | 65 | }); | |
| 57 | 66 | }, | |
| 58 | 67 | ); | |
@@ -66,11 +75,18 @@ test.serial( | |||
| 66 | 75 | process.env["GITHUB_SHA"] = "a".repeat(40); | |
| 67 | 76 | ||
| 68 | 77 | const callback = sinon.stub(gitUtils, "getCommitOid"); | |
| 69 | - callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("a".repeat(40)); | ||
| 78 | + callback | ||
| 79 | + .withArgs(tmpDir, "refs/remotes/pull/1/merge") | ||
| 80 | + .resolves("a".repeat(40)); | ||
| 70 | 81 | callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40)); | |
| 82 | + callback.throws(new Error("Unexpected getCommitOid call in test.")); | ||
| 71 | 83 | ||
| 72 | 84 | const actualRef = await gitUtils.getRef(); | |
| 73 | 85 | t.deepEqual(actualRef, "refs/pull/1/head"); | |
| 86 | + | ||
| 87 | + t.is(callback.callCount, 2); | ||
| 88 | + t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); | ||
| 89 | + t.true(callback.calledWith(tmpDir, "HEAD")); | ||
| 74 | 90 | }); | |
| 75 | 91 | }, | |
| 76 | 92 | ); | |
@@ -92,11 +108,14 @@ test.serial( | |||
| 92 | 108 | process.env["GITHUB_SHA"] = "a".repeat(40); | |
| 93 | 109 | ||
| 94 | 110 | const callback = sinon.stub(gitUtils, "getCommitOid"); | |
| 95 | - callback.withArgs("refs/pull/1/merge").resolves("b".repeat(40)); | ||
| 96 | - callback.withArgs("HEAD").resolves("b".repeat(40)); | ||
| 111 | + callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40)); | ||
| 112 | + callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40)); | ||
| 97 | 113 | ||
| 98 | 114 | const actualRef = await gitUtils.getRef(); | |
| 99 | 115 | t.deepEqual(actualRef, "refs/pull/2/merge"); | |
| 116 | + | ||
| 117 | + // getCommitOid shouldn't be called, because the ref should be taken from the input | ||
| 118 | + t.is(callback.callCount, 0); | ||
| 100 | 119 | }); | |
| 101 | 120 | }, | |
| 102 | 121 | ); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments