Skip to content

Commit

Permalink
address code style
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrifwald committed Jun 29, 2016
1 parent ddbb55b commit 1335fef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 51 deletions.
68 changes: 36 additions & 32 deletions test/spec/file-handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import sinon from "sinon";


describe("fileHandler", () => {
const sandbox = sinon.sandbox.create();
let sandbox;

beforeEach(() => {
sandbox = sinon.sandbox.create();
});

afterEach(() => {
sandbox.restore();
Expand All @@ -25,8 +29,8 @@ describe("fileHandler", () => {
});
expect(fileUtils.removeFile).to.have.callCount(0);
expect(fileUtils.checkoutFile)
.to.have.callCount(1).and
.to.have.been.calledWith("checkout.js");
.to.have.callCount(1).and
.to.have.been.calledWith("checkout.js");
});

it("should remove files", () => {
Expand All @@ -41,8 +45,8 @@ describe("fileHandler", () => {
});
expect(fileUtils.checkoutFile).to.have.callCount(0);
expect(fileUtils.removeFile)
.to.have.callCount(1).and
.to.have.been.calledWith("remove.js");
.to.have.callCount(1).and
.to.have.been.calledWith("remove.js");
});

it("should handle multiple files", () => {
Expand All @@ -65,13 +69,13 @@ describe("fileHandler", () => {
}]
});
expect(fileUtils.checkoutFile)
.to.have.callCount(2).and
.to.have.been.calledWith("checkout1.js").and
.to.have.been.calledWith("checkout2.js");
.to.have.callCount(2).and
.to.have.been.calledWith("checkout1.js").and
.to.have.been.calledWith("checkout2.js");
expect(fileUtils.removeFile)
.to.have.callCount(2).and
.to.have.been.calledWith("remove1.js").and
.to.have.been.calledWith("remove2.js");
.to.have.callCount(2).and
.to.have.been.calledWith("remove1.js").and
.to.have.been.calledWith("remove2.js");
});
});

Expand All @@ -93,14 +97,14 @@ describe("fileHandler", () => {
}
}).then((json) => {
expect(fileUtils.statFiles)
.to.have.callCount(1).and
.to.have.been.calledWith([{
newPath: "first.js",
oldPath: "first.js.publishr"
}, {
newPath: "second.js",
oldPath: "second.js.publishr"
}]);
.to.have.callCount(1).and
.to.have.been.calledWith([{
newPath: "first.js",
oldPath: "first.js.publishr"
}, {
newPath: "second.js",
oldPath: "second.js.publishr"
}]);
expect(fileUtils.readFiles).to.have.callCount(1);
expect(fileUtils.writeFiles).to.have.callCount(1);
expect(fileHandler.overwritePackage).to.have.callCount(1);
Expand Down Expand Up @@ -153,21 +157,21 @@ describe("fileHandler", () => {

return fileHandler.overwritePackage(packageJSON, files).then(() => {
expect(packageUtils.updateDependencies)
.to.have.callCount(1).and
.to.have.been.calledWith(packageJSON);
.to.have.callCount(1).and
.to.have.been.calledWith(packageJSON);
expect(packageUtils.updateMeta)
.to.have.callCount(1).and
.to.have.been.calledWith(packageJSON, files);
.to.have.callCount(1).and
.to.have.been.calledWith(packageJSON, files);
expect(fileUtils.writePackage)
.to.have.callCount(1).and
.to.have.been.calledWith({
dependencies: {
babel: "1.0.0"
},
devDependencies: {
eslint: "1.0.0"
}
});
.to.have.callCount(1).and
.to.have.been.calledWith({
dependencies: {
babel: "1.0.0"
},
devDependencies: {
eslint: "1.0.0"
}
});
});
});
});
Expand Down
10 changes: 8 additions & 2 deletions test/spec/file-utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import testHelpers from "../test-helpers";


describe("fileUtils", () => {
const sandbox = sinon.sandbox.create();
let sandbox;

beforeEach(() => {
sandbox = sinon.sandbox.create();
});

afterEach(() => {
mockfs.restore();
Expand Down Expand Up @@ -118,7 +122,9 @@ describe("fileUtils", () => {
return fileUtils
.removeFile("remove.js")
.then(() => testHelpers.fileExists("remove.js"))
.then((fileExists) => expect(fileExists).to.be.false);
.then((fileExists) => {
expect(fileExists).to.equal(false);
});
});

it("should reject on an error", () => {
Expand Down
20 changes: 12 additions & 8 deletions test/spec/postpublish.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import sinon from "sinon";


describe("postpublish", () => {
const sandbox = sinon.sandbox.create();
let sandbox;

beforeEach(() => {
sandbox = sinon.sandbox.create();
});

afterEach(() => {
sandbox.restore();
Expand All @@ -26,13 +30,13 @@ describe("postpublish", () => {
return postpublish().then(() => {
expect(fileUtils.readPackage).to.have.callCount(1);
expect(fileHandler.fixFiles)
.to.have.callCount(1).and
.to.have.been.calledWith({
_publishr: [{
created: true,
path: "file.js"
}]
});
.to.have.callCount(1).and
.to.have.been.calledWith({
_publishr: [{
created: true,
path: "file.js"
}]
});
});
});
});
18 changes: 9 additions & 9 deletions test/spec/postversion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import sinon from "sinon";


describe("postversion", () => {
const sandbox = sinon.sandbox.create();
let sandbox;

afterEach(() => {
sandbox.restore();
beforeEach(() => {
sandbox = sinon.sandbox.create();
});

it("should overwrite files", () => {
Expand All @@ -26,12 +26,12 @@ describe("postversion", () => {
return postversion().then(() => {
expect(fileUtils.readPackage).to.have.callCount(1);
expect(fileHandler.overwriteFiles)
.to.have.callCount(1).and
.to.have.been.calledWith({
publishr: {
dependencies: ["^babel"]
}
});
.to.have.callCount(1).and
.to.have.been.calledWith({
publishr: {
dependencies: ["^babel"]
}
});
});
});
});

0 comments on commit 1335fef

Please sign in to comment.