Skip to content

Commit

Permalink
fix(portcheck): feedback from PR 266#discussion_r255314895
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Feb 9, 2019
1 parent cc7f429 commit c583224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/common/net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ describe("Net", () => {
describe("#isPortAvailable", () => {
context("when the port is not allowed to be bound", () => {
it("should return a rejected promise", () => {
expect(isPortAvailable(specialPort, host)).to.eventually.be.rejected;
return expect(isPortAvailable(specialPort, host)).to.eventually.be.rejected;
});
});

context("when the port is available", () => {
it("should return a fulfilled promise", () => {
expect(isPortAvailable(port + 1, host)).to.eventually.be.fulfilled;
it("should return a fulfilled promise", () => {
return expect(isPortAvailable(port, host)).to.eventually.be.fulfilled;
});
});

context("when the port is unavailable", () => {
it("should return a rejected promise", () => {
createServer(port).then((_: { close(): any }) => {
expect(isPortAvailable(port, host)).to.eventually.be.rejected;
return expect(isPortAvailable(port, host)).to.eventually.be.rejected;
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/common/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const portCheck = (port: number, host: string): Promise<void> => {
.listen({ port, host, exclusive: true })
.on("error", (e: any) => {
if (e.code === "EADDRINUSE") {
reject(new Error(`Port ${port} is unavailable`))
reject(new Error(`Port ${port} is unavailable on address ${host}`))
} else {
reject(e);
}
Expand Down

0 comments on commit c583224

Please sign in to comment.