|
@@ -17,6 +17,7 @@ const modulePath =
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
|
|
|
|
|
const promiseStub = val => new Promise(resolve => resolve(val))
|
|
const promiseStub = val => new Promise(resolve => resolve(val))
|
|
|
|
|
+const failedPromiseStub = err => new Promise((resolve, reject) => reject(err))
|
|
|
|
|
|
|
|
describe('ProjectUploadManager', function() {
|
|
describe('ProjectUploadManager', function() {
|
|
|
beforeEach(function() {
|
|
beforeEach(function() {
|
|
@@ -47,6 +48,9 @@ describe('ProjectUploadManager', function() {
|
|
|
'../Project/ProjectDetailsHandler': (this.ProjectDetailsHandler = {
|
|
'../Project/ProjectDetailsHandler': (this.ProjectDetailsHandler = {
|
|
|
promises: {}
|
|
promises: {}
|
|
|
}),
|
|
}),
|
|
|
|
|
+ '../Project/ProjectDeleter': (this.ProjectDeleter = {
|
|
|
|
|
+ promises: {}
|
|
|
|
|
+ }),
|
|
|
'../Documents/DocumentHelper': (this.DocumentHelper = {}),
|
|
'../Documents/DocumentHelper': (this.DocumentHelper = {}),
|
|
|
rimraf: (this.rimraf = sinon.stub().callsArg(1))
|
|
rimraf: (this.rimraf = sinon.stub().callsArg(1))
|
|
|
}
|
|
}
|
|
@@ -211,7 +215,7 @@ describe('ProjectUploadManager', function() {
|
|
|
this.ProjectUploadManager.promises.insertZipArchiveIntoFolder = sinon
|
|
this.ProjectUploadManager.promises.insertZipArchiveIntoFolder = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.returns(promiseStub())
|
|
.returns(promiseStub())
|
|
|
- return this.ProjectUploadManager.createProjectFromZipArchiveWithName(
|
|
|
|
|
|
|
+ this.ProjectUploadManager.createProjectFromZipArchiveWithName(
|
|
|
this.owner_id,
|
|
this.owner_id,
|
|
|
this.name,
|
|
this.name,
|
|
|
this.source,
|
|
this.source,
|
|
@@ -256,6 +260,71 @@ describe('ProjectUploadManager', function() {
|
|
|
.calledWith(sinon.match.falsy, this.project)
|
|
.calledWith(sinon.match.falsy, this.project)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
+ describe('when inserting the zip file contents into the root folder fails', function() {
|
|
|
|
|
+ beforeEach(function(done) {
|
|
|
|
|
+ this.callback = sinon.stub()
|
|
|
|
|
+ this.ProjectUploadManager.promises.insertZipArchiveIntoFolder = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .returns(failedPromiseStub('insert-zip-error'))
|
|
|
|
|
+ this.ProjectDeleter.promises.deleteProject = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .returns(promiseStub())
|
|
|
|
|
+ this.ProjectUploadManager.createProjectFromZipArchiveWithName(
|
|
|
|
|
+ this.owner_id,
|
|
|
|
|
+ this.name,
|
|
|
|
|
+ this.source,
|
|
|
|
|
+ (err, project) => {
|
|
|
|
|
+ this.callback(err, project)
|
|
|
|
|
+ return done()
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('should pass an error to the callback', function() {
|
|
|
|
|
+ return this.callback
|
|
|
|
|
+ .calledWith('insert-zip-error', sinon.match.falsy)
|
|
|
|
|
+ .should.equal(true)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('should cleanup the blank project created', function() {
|
|
|
|
|
+ return this.ProjectDeleter.promises.deleteProject
|
|
|
|
|
+ .calledWith(this.project_id)
|
|
|
|
|
+ .should.equal(true)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('when setting automatically the root doc fails', function() {
|
|
|
|
|
+ beforeEach(function(done) {
|
|
|
|
|
+ this.callback = sinon.stub()
|
|
|
|
|
+ this.ProjectRootDocManager.promises.setRootDocAutomatically = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .returns(failedPromiseStub('set-root-auto-error'))
|
|
|
|
|
+ this.ProjectDeleter.promises.deleteProject = sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .returns(promiseStub())
|
|
|
|
|
+ this.ProjectUploadManager.createProjectFromZipArchiveWithName(
|
|
|
|
|
+ this.owner_id,
|
|
|
|
|
+ this.name,
|
|
|
|
|
+ this.source,
|
|
|
|
|
+ (err, project) => {
|
|
|
|
|
+ this.callback(err, project)
|
|
|
|
|
+ return done()
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('should pass an error to the callback', function() {
|
|
|
|
|
+ return this.callback
|
|
|
|
|
+ .calledWith('set-root-auto-error', sinon.match.falsy)
|
|
|
|
|
+ .should.equal(true)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('should cleanup the blank project created', function() {
|
|
|
|
|
+ return this.ProjectDeleter.promises.deleteProject
|
|
|
|
|
+ .calledWith(this.project_id)
|
|
|
|
|
+ .should.equal(true)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('insertZipArchiveIntoFolder', function() {
|
|
describe('insertZipArchiveIntoFolder', function() {
|