fix unit tests warning

stable
Juanfran 2016-05-24 09:22:06 +02:00
parent 28827419d5
commit 8457f94323
8 changed files with 17 additions and 21 deletions

View File

@ -158,7 +158,7 @@ describe "AttachmentsController", ->
deleteFile = Immutable.Map() deleteFile = Immutable.Map()
mocks.attachmentsFullService.deleteAttachment = sinon.stub() mocks.attachmentsFullService.deleteAttachment = sinon.stub()
mocks.attachmentsFullService.deleteAttachment.withArgs(deleteFile, 'us').promise().reject() mocks.attachmentsFullService.deleteAttachment.withArgs(deleteFile, 'us').promise().reject(new Error('error'))
askResponse = { askResponse = {
finish: sinon.spy() finish: sinon.spy()

View File

@ -73,7 +73,7 @@ class AttachmentsFullService extends taiga.Service
resolve(attachment) resolve(attachment)
else else
reject(file) reject(new Error(file))
loadAttachments: (type, objId, projectId)-> loadAttachments: (type, objId, projectId)->
@attachmentsService.list(type, objId, projectId).then (files) => @attachmentsService.list(type, objId, projectId).then (files) =>

View File

@ -104,17 +104,15 @@ describe "ExternalAppController", ->
mocks.routeParams.application = 6 mocks.routeParams.application = 6
mocks.routeParams.state = "testing-state" mocks.routeParams.state = "testing-state"
xhr = { error = new Error('404')
status: 404
}
mocks.tgExternalAppsService.getApplicationToken.withArgs(mocks.routeParams.application, mocks.routeParams.state).promise().reject(xhr) mocks.tgExternalAppsService.getApplicationToken.withArgs(mocks.routeParams.application, mocks.routeParams.state).promise().reject(error)
ctrl = $controller("ExternalApp") ctrl = $controller("ExternalApp")
setTimeout ( -> setTimeout ( ->
expect(mocks.tgLoader.start.withArgs(false)).to.be.calledOnce expect(mocks.tgLoader.start.withArgs(false)).to.be.calledOnce
expect(mocks.tgXhrErrorService.response.withArgs(xhr)).to.be.calledOnce expect(mocks.tgXhrErrorService.response.withArgs(error)).to.be.calledOnce
done() done()
) )

View File

@ -126,16 +126,14 @@ describe "ProfileController", ->
mocks.routeParams.slug = "user-slug" mocks.routeParams.slug = "user-slug"
xhr = { error = new Error('404')
status: 404
}
mocks.userService.getUserByUserName.withArgs(mocks.routeParams.slug).promise().reject(xhr) mocks.userService.getUserByUserName.withArgs(mocks.routeParams.slug).promise().reject(error)
ctrl = $controller("Profile") ctrl = $controller("Profile")
setTimeout ( -> setTimeout ( ->
expect(mocks.xhrErrorService.response.withArgs(xhr)).to.be.calledOnce expect(mocks.xhrErrorService.response.withArgs(error)).to.be.calledOnce
done() done()
) )

View File

@ -91,7 +91,7 @@ describe "LikeProjectButton", ->
ctrl = $controller("LikeProjectButton") ctrl = $controller("LikeProjectButton")
ctrl.project = project ctrl.project = project
mocks.tgLikeProjectButton.like.withArgs(project.get('id')).promise().reject() mocks.tgLikeProjectButton.like.withArgs(project.get('id')).promise().reject(new Error('error'))
ctrl.toggleLike().finally () -> ctrl.toggleLike().finally () ->
expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce
@ -127,7 +127,7 @@ describe "LikeProjectButton", ->
ctrl = $controller("LikeProjectButton") ctrl = $controller("LikeProjectButton")
ctrl.project = project ctrl.project = project
mocks.tgLikeProjectButton.unlike.withArgs(project.get('id')).promise().reject() mocks.tgLikeProjectButton.unlike.withArgs(project.get('id')).promise().reject(new Error('error'))
ctrl.toggleLike().finally () -> ctrl.toggleLike().finally () ->
expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce

View File

@ -118,7 +118,7 @@ describe "WatchProjectButton", ->
ctrl.project = project ctrl.project = project
ctrl.showWatchOptions = true ctrl.showWatchOptions = true
mocks.tgWatchProjectButton.watch.withArgs(project.get('id'), notifyLevel).promise().reject() mocks.tgWatchProjectButton.watch.withArgs(project.get('id'), notifyLevel).promise().reject(new Error('error'))
ctrl.watch(notifyLevel).finally () -> ctrl.watch(notifyLevel).finally () ->
expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce
@ -159,7 +159,7 @@ describe "WatchProjectButton", ->
ctrl.project = project ctrl.project = project
ctrl.showWatchOptions = true ctrl.showWatchOptions = true
mocks.tgWatchProjectButton.unwatch.withArgs(project.get('id')).promise().reject() mocks.tgWatchProjectButton.unwatch.withArgs(project.get('id')).promise().reject(new Error('error'))
ctrl.unwatch().finally () -> ctrl.unwatch().finally () ->
expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce expect(mocks.tgConfirm.notify.withArgs("error")).to.be.calledOnce

View File

@ -113,7 +113,7 @@ describe "TransferProject", ->
mocks.auth.refresh.promise().resolve() mocks.auth.refresh.promise().resolve()
mocks.routeParams.token = "BAD_TOKEN" mocks.routeParams.token = "BAD_TOKEN"
mocks.currentUserService.getUser.returns(user) mocks.currentUserService.getUser.returns(user)
mocks.projectsService.transferValidateToken.withArgs(1, "BAD_TOKEN").promise().reject() mocks.projectsService.transferValidateToken.withArgs(1, "BAD_TOKEN").promise().reject(new Error('error'))
mocks.tgNavUrls.resolve.withArgs("not-found").returns("/not-found") mocks.tgNavUrls.resolve.withArgs("not-found").returns("/not-found")
ctrl = $controller("TransferProjectController") ctrl = $controller("TransferProjectController")
@ -247,7 +247,7 @@ describe "TransferProject", ->
expect(mocks.location.path).to.be.calledWith("/project/slug/") expect(mocks.location.path).to.be.calledWith("/project/slug/")
expect(mocks.tgConfirm.notify).to.be.calledWith("success", "ACCEPTED_PROJECT_OWNERNSHIP", '', 5000) expect(mocks.tgConfirm.notify).to.be.calledWith("success", "ACCEPTED_PROJECT_OWNERNSHIP", '', 5000)
done() done()
it "transfer reject", (done) -> it "transfer reject", (done) ->
project = Immutable.fromJS({ project = Immutable.fromJS({
@ -262,7 +262,7 @@ describe "TransferProject", ->
mocks.currentUserService.getUser.returns(user) mocks.currentUserService.getUser.returns(user)
mocks.projectsService.transferValidateToken.withArgs(1, "TOKEN").promise().resolve() mocks.projectsService.transferValidateToken.withArgs(1, "TOKEN").promise().resolve()
mocks.projectsService.transferReject.withArgs(1, "TOKEN", "this is my reason").promise().resolve() mocks.projectsService.transferReject.withArgs(1, "TOKEN", "this is my reason").promise().resolve()
mocks.tgNavUrls.resolve.withArgs("project-admin-project-profile-details", {project: "slug"}).returns("/project/slug/") mocks.tgNavUrls.resolve.withArgs("home", {project: "slug"}).returns("/project/slug/")
mocks.translate.instant.withArgs("ADMIN.PROJECT_TRANSFER.REJECTED_PROJECT_OWNERNSHIP").returns("REJECTED_PROJECT_OWNERNSHIP") mocks.translate.instant.withArgs("ADMIN.PROJECT_TRANSFER.REJECTED_PROJECT_OWNERNSHIP").returns("REJECTED_PROJECT_OWNERNSHIP")
ctrl = $controller("TransferProjectController") ctrl = $controller("TransferProjectController")
@ -272,4 +272,4 @@ describe "TransferProject", ->
expect(mocks.location.path).to.be.calledWith("/project/slug/") expect(mocks.location.path).to.be.calledWith("/project/slug/")
expect(mocks.tgConfirm.notify).to.be.calledWith("success", "REJECTED_PROJECT_OWNERNSHIP", '', 5000) expect(mocks.tgConfirm.notify).to.be.calledWith("success", "REJECTED_PROJECT_OWNERNSHIP", '', 5000)
done() done()

View File

@ -190,7 +190,7 @@ describe "tgCurrentUserService", ->
done() done()
it "create default joyride config", (done) -> it "create default joyride config", (done) ->
mocks.resources.user.getUserStorage.withArgs('joyride').promise().reject() mocks.resources.user.getUserStorage.withArgs('joyride').promise().reject(new Error('error'))
currentUserService.loadJoyRideConfig().then (config) -> currentUserService.loadJoyRideConfig().then (config) ->
joyride = { joyride = {