prettier: convert test/unit decaffeinated files to Prettier format

This commit is contained in:
mserranom
2020-02-19 12:15:37 +01:00
parent b515397b5a
commit 7e2542319f
18 changed files with 4233 additions and 3427 deletions

View File

@@ -9,75 +9,85 @@
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const SandboxedModule = require('sandboxed-module');
const sinon = require('sinon');
require('chai').should();
const modulePath = require('path').join(__dirname, '../../../app/js/LockManager');
const Path = require("path");
const Errors = require("../../../app/js/Errors");
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join(
__dirname,
'../../../app/js/LockManager'
)
const Path = require('path')
const Errors = require('../../../app/js/Errors')
describe("DockerLockManager", function() {
beforeEach(function() {
this.LockManager = SandboxedModule.require(modulePath, { requires: {
"settings-sharelatex": {},
"logger-sharelatex": (this.logger = { log: sinon.stub(), error: sinon.stub(), err() {} }),
"fs": {
lstat:sinon.stub().callsArgWith(1),
readdir: sinon.stub().callsArgWith(1)
},
"lockfile": (this.Lockfile = {})
}
});
return this.lockFile = "/local/compile/directory/.project-lock";
});
describe('DockerLockManager', function() {
beforeEach(function() {
this.LockManager = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': {},
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
err() {}
}),
fs: {
lstat: sinon.stub().callsArgWith(1),
readdir: sinon.stub().callsArgWith(1)
},
lockfile: (this.Lockfile = {})
}
})
return (this.lockFile = '/local/compile/directory/.project-lock')
})
return describe("runWithLock", function() {
beforeEach(function() {
this.runner = sinon.stub().callsArgWith(0, null, "foo", "bar");
return this.callback = sinon.stub();
});
return describe('runWithLock', function() {
beforeEach(function() {
this.runner = sinon.stub().callsArgWith(0, null, 'foo', 'bar')
return (this.callback = sinon.stub())
})
describe("normally", function() {
beforeEach(function() {
this.Lockfile.lock = sinon.stub().callsArgWith(2, null);
this.Lockfile.unlock = sinon.stub().callsArgWith(1, null);
return this.LockManager.runWithLock(this.lockFile, this.runner, this.callback);
});
describe('normally', function() {
beforeEach(function() {
this.Lockfile.lock = sinon.stub().callsArgWith(2, null)
this.Lockfile.unlock = sinon.stub().callsArgWith(1, null)
return this.LockManager.runWithLock(
this.lockFile,
this.runner,
this.callback
)
})
it("should run the compile", function() {
return this.runner
.calledWith()
.should.equal(true);
});
it('should run the compile', function() {
return this.runner.calledWith().should.equal(true)
})
return it("should call the callback with the response from the compile", function() {
return this.callback
.calledWithExactly(null, "foo", "bar")
.should.equal(true);
});
});
return it('should call the callback with the response from the compile', function() {
return this.callback
.calledWithExactly(null, 'foo', 'bar')
.should.equal(true)
})
})
return describe("when the project is locked", function() {
beforeEach(function() {
this.error = new Error();
this.error.code = "EEXIST";
this.Lockfile.lock = sinon.stub().callsArgWith(2,this.error);
this.Lockfile.unlock = sinon.stub().callsArgWith(1, null);
return this.LockManager.runWithLock(this.lockFile, this.runner, this.callback);
});
return describe('when the project is locked', function() {
beforeEach(function() {
this.error = new Error()
this.error.code = 'EEXIST'
this.Lockfile.lock = sinon.stub().callsArgWith(2, this.error)
this.Lockfile.unlock = sinon.stub().callsArgWith(1, null)
return this.LockManager.runWithLock(
this.lockFile,
this.runner,
this.callback
)
})
it("should not run the compile", function() {
return this.runner
.called
.should.equal(false);
});
it('should not run the compile', function() {
return this.runner.called.should.equal(false)
})
return it("should return an error", function() {
const error = new Errors.AlreadyCompilingError();
return this.callback
.calledWithExactly(error)
.should.equal(true);
});
});
});
});
return it('should return an error', function() {
const error = new Errors.AlreadyCompilingError()
return this.callback.calledWithExactly(error).should.equal(true)
})
})
})
})