From 794ca91a7b71702e54118d3b1496e45e53b282bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Juli=C3=A1n?= Date: Mon, 22 Aug 2016 12:54:06 +0200 Subject: [PATCH] Create epics unit test --- .../create-epic.controller.spec.coffee | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/modules/epics/create-epic/create-epic.controller.spec.coffee diff --git a/app/modules/epics/create-epic/create-epic.controller.spec.coffee b/app/modules/epics/create-epic/create-epic.controller.spec.coffee new file mode 100644 index 00000000..3453206d --- /dev/null +++ b/app/modules/epics/create-epic/create-epic.controller.spec.coffee @@ -0,0 +1,63 @@ +### +# Copyright (C) 2014-2015 Taiga Agile LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: epic-row.controller.spec.coffee +### + +describe "EpicRow", -> + createEpicCtrl = null + provide = null + controller = null + mocks = {} + + _mockTgResources = () -> + mocks.tgResources = { + epics: { + post: sinon.stub() + } + } + + provide.value "tgResources", mocks.tgResources + + _mocks = () -> + module ($provide) -> + provide = $provide + _mockTgResources() + + return null + + beforeEach -> + module "taigaEpics" + + _mocks() + + inject ($controller) -> + controller = $controller + + it "create Epic", (done) -> + createEpicCtrl = controller "CreateEpicCtrl" + createEpicCtrl.project = { + id: 7 + } + createEpicCtrl.newEpic = { + project: createEpicCtrl.project.id + } + createEpicCtrl.onReloadEpics = sinon.stub() + promise = mocks.tgResources.epics.post.withArgs(createEpicCtrl.newEpic).promise().resolve() + + createEpicCtrl.createEpic().then () -> + expect(createEpicCtrl.onReloadEpics).have.been.called + done()