From a032c80aaf8fed9a0288da6b2348501ca38c6d38 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Tue, 18 Aug 2015 08:05:35 -0500 Subject: [PATCH] Move chat controller to own spec file --- test/spec/controllers/chatCtrlSpec.js | 72 ++++++++++++++++++++++++++ test/spec/controllers/groupCtrlSpec.js | 70 ------------------------- 2 files changed, 72 insertions(+), 70 deletions(-) create mode 100644 test/spec/controllers/chatCtrlSpec.js diff --git a/test/spec/controllers/chatCtrlSpec.js b/test/spec/controllers/chatCtrlSpec.js new file mode 100644 index 0000000000..81a19f8efc --- /dev/null +++ b/test/spec/controllers/chatCtrlSpec.js @@ -0,0 +1,72 @@ +'use strict'; + +describe("Chat Controller", function() { + var scope, ctrl, user, $rootScope, $controller; + + beforeEach(function() { + module(function($provide) { + $provide.value('User', {}); + }); + + inject(function(_$rootScope_, _$controller_){ + user = specHelper.newUser(); + user._id = "unique-user-id"; + $rootScope = _$rootScope_; + + scope = _$rootScope_.$new(); + + $controller = _$controller_; + + // Load RootCtrl to ensure shared behaviors are loaded + $controller('RootCtrl', {$scope: scope, User: {user: user}}); + + ctrl = $controller('ChatCtrl', {$scope: scope}); + }); + }); + + describe('copyToDo', function() { + it('when copying a user message it opens modal with information from message', function() { + scope.group = { + name: "Princess Bride" + }; + + var modalSpy = sandbox.spy($rootScope, "openModal"); + var message = { + uuid: 'the-dread-pirate-roberts', + user: 'Wesley', + text: 'As you wish' + }; + + scope.copyToDo(message); + + modalSpy.should.have.been.calledOnce; + + modalSpy.should.have.been.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){ + return callArgToMatch.controller == 'CopyMessageModalCtrl' + && callArgToMatch.scope.text == message.text + })); + }); + + it('when copying a system message it opens modal with information from message', function() { + scope.group = { + name: "Princess Bride" + }; + + var modalSpy = sandbox.spy($rootScope, "openModal"); + var message = { + uuid: 'system', + text: 'Wesley attacked the ROUS in the Fire Swamp' + }; + + scope.copyToDo(message); + + modalSpy.should.have.been.calledOnce; + + modalSpy.should.have.been.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){ + return callArgToMatch.controller == 'CopyMessageModalCtrl' + && callArgToMatch.scope.text == message.text + })); + }); + }); +}); + diff --git a/test/spec/controllers/groupCtrlSpec.js b/test/spec/controllers/groupCtrlSpec.js index 8952ef5691..131f8805a9 100644 --- a/test/spec/controllers/groupCtrlSpec.js +++ b/test/spec/controllers/groupCtrlSpec.js @@ -72,76 +72,6 @@ describe('Groups Controller', function() { }); }); -describe("Chat Controller", function() { - var scope, ctrl, user, $rootScope, $controller; - - beforeEach(function() { - module(function($provide) { - $provide.value('User', {}); - }); - - inject(function(_$rootScope_, _$controller_){ - user = specHelper.newUser(); - user._id = "unique-user-id"; - $rootScope = _$rootScope_; - - scope = _$rootScope_.$new(); - - $controller = _$controller_; - - // Load RootCtrl to ensure shared behaviors are loaded - $controller('RootCtrl', {$scope: scope, User: {user: user}}); - - ctrl = $controller('ChatCtrl', {$scope: scope}); - }); - }); - - describe('copyToDo', function() { - it('when copying a user message it opens modal with information from message', function() { - scope.group = { - name: "Princess Bride" - }; - - var modalSpy = sandbox.spy($rootScope, "openModal"); - var message = { - uuid: 'the-dread-pirate-roberts', - user: 'Wesley', - text: 'As you wish' - }; - - scope.copyToDo(message); - - modalSpy.should.have.been.calledOnce; - - modalSpy.should.have.been.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){ - return callArgToMatch.controller == 'CopyMessageModalCtrl' - && callArgToMatch.scope.text == message.text - })); - }); - - it('when copying a system message it opens modal with information from message', function() { - scope.group = { - name: "Princess Bride" - }; - - var modalSpy = sandbox.spy($rootScope, "openModal"); - var message = { - uuid: 'system', - text: 'Wesley attacked the ROUS in the Fire Swamp' - }; - - scope.copyToDo(message); - - modalSpy.should.have.been.calledOnce; - - modalSpy.should.have.been.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){ - return callArgToMatch.controller == 'CopyMessageModalCtrl' - && callArgToMatch.scope.text == message.text - })); - }); - }); -}); - describe("Autocomplete controller", function() { var scope, ctrl, user, $rootScope, $controller;