Browse Source

Cleanup of tests, improved readability of the test code (#1434)

* Cleanup of tests, improved readability

* Improved readability concerning timeout/loading tests, removed unnecessary 'this.'
master
Bart 8 years ago committed by Igor Zhukov
parent
commit
cd3979aeab
  1. 4
      app/js/controllers.js
  2. 24
      test/unit/controllers/AppFooterControllerSpec.js
  3. 10
      test/unit/controllers/AppImPanelControllerSpec.js
  4. 23
      test/unit/controllers/AppLangSelectControllerSpec.js
  5. 37
      test/unit/controllers/AppWelcomeControllerSpec.js
  6. 55
      test/unit/controllers/ChangelogModalControlelerSpec.js
  7. 141
      test/unit/controllers/DocumentModalControllerSpec.js
  8. 74
      test/unit/controllers/EmbedModalController.js
  9. 235
      test/unit/controllers/PeerSelectControllerSpec.js
  10. 152
      test/unit/controllers/VideoModalControllerSpec.js
  11. 14
      test/unit/directives/myHeadDirective.js
  12. 14
      test/unit/directives/myLangFooterDirective.js
  13. 20
      test/unit/services/PhonebookContactsServiceSpec.js

4
app/js/controllers.js

@ -3537,7 +3537,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
$scope.$on('history_delete', function (e, historyUpdate) { $scope.$on('history_delete', function (e, historyUpdate) {
if (historyUpdate.msgs[$scope.messageID]) { if (historyUpdate && historyUpdate.msgs && historyUpdate.msgs[$scope.messageID]) {
$modalInstance.dismiss() $modalInstance.dismiss()
} }
}) })
@ -3571,7 +3571,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
$scope.$on('history_delete', function (e, historyUpdate) { $scope.$on('history_delete', function (e, historyUpdate) {
if (historyUpdate.msgs[$scope.messageID]) { if (historyUpdate && historyUpdate.msgs && historyUpdate.msgs[$scope.messageID]) {
$modalInstance.dismiss() $modalInstance.dismiss()
} }
}) })

24
test/unit/controllers/AppFooterControllerSpec.js

@ -2,34 +2,32 @@
/* global describe, it, inject, expect, beforeEach */ /* global describe, it, inject, expect, beforeEach */
describe('AppFooterController', function () { describe('AppFooterController', function () {
var $controller, $scope, service, serviceFlag
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
serviceFlag = false this.LayoutSwitchService = {
service = { serviceFlag: false,
switchLayout: function (parameter) { switchLayout: function (parameter) {
serviceFlag = true this.serviceFlag = true
} }
} }
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$controller = _$controller_ this.$controller = _$controller_
$scope = _$rootScope_.$new() this.$scope = _$rootScope_.$new()
$controller('AppFooterController', { this.$controller('AppFooterController', {
$scope: $scope, $scope: this.$scope,
LayoutSwitchService: service LayoutSwitchService: this.LayoutSwitchService
}) })
}) })
}) })
// define tests // define tests
it('calls the right function', function (done) { it('calls the right function', function (done) {
expect(serviceFlag).toBe(false) expect(this.LayoutSwitchService.serviceFlag).toBe(false)
$scope.switchLayout(null) this.$scope.switchLayout(true)
expect(serviceFlag).toBe(true) expect(this.LayoutSwitchService.serviceFlag).toBe(true)
done() done()
}) })
}) })

10
test/unit/controllers/AppImPanelControllerSpec.js

@ -2,21 +2,19 @@
/* global describe, it, inject, expect, beforeEach, jasmine */ /* global describe, it, inject, expect, beforeEach, jasmine */
describe('AppImPanelController', function () { describe('AppImPanelController', function () {
var $scope
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$scope = _$rootScope_.$new() this.$scope = _$rootScope_.$new()
$scope.$on = jasmine.createSpy('$on') this.$scope.$on = jasmine.createSpy('$on')
_$controller_('AppImPanelController', { $scope: $scope }) _$controller_('AppImPanelController', { $scope: this.$scope })
}) })
}) })
// define tests // define tests
it('sets $on(user_update) to no-operation function', function (done) { it('sets $on(user_update) to no-operation function', function (done) {
expect($scope.$on).toHaveBeenCalledWith('user_update', angular.noop) expect(this.$scope.$on).toHaveBeenCalledWith('user_update', angular.noop)
done() done()
}) })
}) })

23
test/unit/controllers/AppLangSelectControllerSpec.js

@ -2,18 +2,17 @@
/* global describe, it, inject, expect, beforeEach, xit */ /* global describe, it, inject, expect, beforeEach, xit */
describe('AppLangSelectController', function () { describe('AppLangSelectController', function () {
var $controller, $scope
beforeEach(module('ui.bootstrap')) beforeEach(module('ui.bootstrap'))
beforeEach(module('myApp.services')) beforeEach(module('myApp.services'))
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
inject(function (_$controller_, _$rootScope_, _, Storage, ErrorService, AppRuntimeManager) { inject(function (_$controller_, _$rootScope_, _, Storage, ErrorService, AppRuntimeManager) {
$controller = _$controller_ this.$controller = _$controller_
$scope = _$rootScope_.$new() this.$scope = _$rootScope_.$new()
$controller('AppLangSelectController', {
$scope: $scope, this.$controller('AppLangSelectController', {
$scope: this.$scope,
_: _, _: _,
Storage: Storage, Storage: Storage,
ErrorService: ErrorService, ErrorService: ErrorService,
@ -23,24 +22,24 @@ describe('AppLangSelectController', function () {
}) })
it('holds the supportedLocales', function () { it('holds the supportedLocales', function () {
expect($scope.supportedLocales).toBeDefined() expect(this.$scope.supportedLocales).toBeDefined()
}) })
it('holds langNames', function () { it('holds langNames', function () {
expect($scope.langNames).toBeDefined() expect(this.$scope.langNames).toBeDefined()
}) })
it('holds the current locale', function () { it('holds the current locale', function () {
expect($scope.curLocale).toBeDefined() expect(this.$scope.curLocale).toBeDefined()
}) })
it('has a locale form', function () { it('has a locale form', function () {
expect($scope.form).toBeDefined() expect(this.$scope.form).toBeDefined()
expect($scope.form.locale).toBeDefined() expect(this.$scope.form.locale).toBeDefined()
}) })
it('allows to select a locale', function () { it('allows to select a locale', function () {
expect($scope.localeSelect).toBeDefined() expect(this.$scope.localeSelect).toBeDefined()
}) })
describe('when the user switches the locale', function () { describe('when the user switches the locale', function () {

37
test/unit/controllers/AppWelcomeControllerSpec.js

@ -2,21 +2,18 @@
/* global describe, it, inject, expect, beforeEach */ /* global describe, it, inject, expect, beforeEach */
describe('AppWelcomeController', function () { describe('AppWelcomeController', function () {
var $controller, $rootScope, $scope, $location, MtpApiManager, ErrorService,
ChangelogNotifyService, LayoutSwitchService
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
ChangelogNotifyService = { this.ChangelogNotifyService = {
checkUpdate: function () {} checkUpdate: function () {}
} }
LayoutSwitchService = { this.LayoutSwitchService = {
start: function () {} start: function () {}
} }
MtpApiManager = { this.MtpApiManager = {
getUserID: function () { getUserID: function () {
return { return {
then: function () {} then: function () {}
@ -24,23 +21,19 @@ describe('AppWelcomeController', function () {
} }
} }
module(function ($provide) {
$provide.value('MtpApiManager', MtpApiManager)
})
inject(function (_$controller_, _$rootScope_, _$location_) { inject(function (_$controller_, _$rootScope_, _$location_) {
$controller = _$controller_ this.$controller = _$controller_
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
$location = _$location_ this.$location = _$location_
this.$scope = _$rootScope_.$new()
$scope = $rootScope.$new()
$controller('AppWelcomeController', { this.$controller('AppWelcomeController', {
$scope: $scope, $scope: this.$scope,
$location: $location, $location: this.$location,
MtpApiManager: MtpApiManager, MtpApiManager: this.MtpApiManager,
ErrorService: ErrorService, ErrorService: this.ErrorService,
ChangelogNotifyService: ChangelogNotifyService, ChangelogNotifyService: this.ChangelogNotifyService,
LayoutSwitchService: LayoutSwitchService LayoutSwitchService: this.LayoutSwitchService
}) })
}) })
}) })

55
test/unit/controllers/ChangelogModalControlelerSpec.js

@ -2,69 +2,68 @@
/* global describe, it, inject, expect, beforeEach, Config */ /* global describe, it, inject, expect, beforeEach, Config */
describe('ChangeLogModalController', function () { describe('ChangeLogModalController', function () {
var $controller, $scope, modal, modalFlag
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
modalFlag = false this.modal = {
modal = { modalFlag: false,
open: function (data) { open: function (data) {
modalFlag = true this.modalFlag = true
} }
} }
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$controller = _$controller_ this.$controller = _$controller_
this.$scope = _$rootScope_.$new()
$scope = _$rootScope_.$new() this.$controller('ChangelogModalController', {
$controller('ChangelogModalController', { $scope: this.$scope,
$scope: $scope, $modal: this.modal
$modal: modal
}) })
}) })
}) })
// define tests // define tests
it('will have standard data when no function is called', function (done) { it('will have standard data when no function is called', function (done) {
expect($scope.changelogHidden).toBe(false) expect(this.$scope.changelogHidden).toBe(false)
expect($scope.changelogShown).toBe(false) expect(this.$scope.changelogShown).toBe(false)
expect($scope.currentVersion).toBe(Config.App.version) expect(this.$scope.currentVersion).toBe(Config.App.version)
done() done()
}) })
it('will show the changelog', function (done) { it('will show the changelog', function (done) {
$scope.showAllVersions() this.$scope.showAllVersions()
expect($scope.changelogHidden).toBe(false) expect(this.$scope.changelogHidden).toBe(false)
expect($scope.changelogShown).toBe(true) expect(this.$scope.changelogShown).toBe(true)
done() done()
}) })
it('will allow to show any version when "changelogShown" is true', function (done) { it('will allow to show any version when "changelogShown" is true', function (done) {
$scope.changelogShown = true this.$scope.changelogShown = true
expect($scope.canShowVersion(null)).toBe(true) expect(this.$scope.canShowVersion(null)).toBe(true)
expect($scope.canShowVersion('0.0.1')).toBe(true) expect(this.$scope.canShowVersion('0.0.1')).toBe(true)
expect($scope.canShowVersion('0.1.0')).toBe(true) expect(this.$scope.canShowVersion('0.1.0')).toBe(true)
expect($scope.canShowVersion('1.0.0')).toBe(true) expect(this.$scope.canShowVersion('1.0.0')).toBe(true)
done() done()
}) })
it('will allow the version to be shown when the current verion is bigger than the last function', function (done) { it('will allow the version to be shown when the current verion is bigger than the last function', function (done) {
expect($scope.canShowVersion('100.100.100')).toBe(true) expect(this.$scope.canShowVersion('100.100.100')).toBe(true)
done() done()
}) })
it('won\'t allow the version to be shown when it is smaller than the current version', function (done) { it('won\'t allow the version to be shown when it is smaller than the current version', function (done) {
expect($scope.changelogHidden).toBe(false) expect(this.$scope.changelogHidden).toBe(false)
expect($scope.canShowVersion('0.0.0')).toBe(false) expect(this.$scope.canShowVersion('0.0.0')).toBe(false)
expect($scope.changelogHidden).toBe(true) expect(this.$scope.changelogHidden).toBe(true)
done() done()
}) })
it('will call modal when the changeUsername function is called', function (done) { it('will call modal when the changeUsername function is called', function (done) {
expect(modalFlag).toBe(false) expect(this.modal.modalFlag).toBe(false)
$scope.changeUsername() this.$scope.changeUsername()
expect(modalFlag).toBe(true) expect(this.modal.modalFlag).toBe(true)
done() done()
}) })
}) })

141
test/unit/controllers/DocumentModalControllerSpec.js

@ -1,20 +1,19 @@
'use strict' 'use strict'
/* global describe, it, inject, expect, beforeEach, jasmine */ /* global describe, it, inject, expect, beforeEach, jasmine, spyOn */
describe('DocumentModalController', function () { describe('DocumentModalController', function () {
var $controller, $scope, $rootScope, $docManager, $errService, $input, $messManager, $pSelectService, $modalI, createController
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
$docManager = {} this.AppDocsManager = {
$docManager.wrapForHistory = jasmine.createSpy('wrapForHistory') wrapForHistory: jasmine.createSpy('wrapForHistory'),
$docManager.saveDocFile = jasmine.createSpy('saveDocFile') saveDocFile: jasmine.createSpy('saveDocFile')
}
$input = {} this.ErrorService = {
$errService = { $input: {},
confirm: function (message) { confirm: function (message) {
$input = message this.$input = message
return { return {
then: function (f) { then: function (f) {
f() f()
@ -23,9 +22,10 @@ describe('DocumentModalController', function () {
} }
} }
$pSelectService = { this.PeersSelectService = {
$input: {},
selectPeer: function (options) { selectPeer: function (options) {
$input = options this.$input = options
return { return {
then: function (f) { then: function (f) {
f('Peerselected') f('Peerselected')
@ -34,100 +34,103 @@ describe('DocumentModalController', function () {
} }
} }
createController = function (spyBroadcast, spyOn) { this.AppMessagesManager = {
if (spyBroadcast) { deleteMessages: jasmine.createSpy('deleteMessages')
$rootScope.$broadcast = jasmine.createSpy('$broadcast')
}
if (spyOn) {
$scope.$on = jasmine.createSpy('$on')
} }
$controller('DocumentModalController', {
$scope: $scope,
$rootScope: $rootScope,
$modalInstance: $modalI,
PeersSelectService: $pSelectService,
AppMessagesManager: $messManager,
AppDocsManager: $docManager,
AppPeersManager: {},
ErrorService: $errService
})
}
$messManager = {}
$messManager.deleteMessages = jasmine.createSpy('deleteMessages')
$modalI = {} this.$modalInstance = {
$modalI.dismiss = jasmine.createSpy('dismissModal') dismiss: jasmine.createSpy('dismissModal')
}
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
$scope = $rootScope.$new() this.$scope = this.$rootScope.$new()
$scope.docID = 'randomdoc' this.$scope.docID = 'randomdoc'
$controller = _$controller_ this.$controller = _$controller_
spyOn(this.$rootScope, '$broadcast').and.callThrough()
spyOn(this.$scope, '$on').and.callThrough()
this.$controller('DocumentModalController', {
$scope: this.$scope,
$rootScope: this.$rootScope,
$modalInstance: this.$modalInstance,
PeersSelectService: this.PeersSelectService,
AppMessagesManager: this.AppMessagesManager,
AppDocsManager: this.AppDocsManager,
AppPeersManager: {},
ErrorService: this.ErrorService
})
}) })
}) })
// define tests // define tests
it('sets the document in the scope', function (done) { it('sets the document in the scope', function (done) {
createController(false, false) expect(this.AppDocsManager.wrapForHistory).toHaveBeenCalledWith(this.$scope.docID)
expect($docManager.wrapForHistory).toHaveBeenCalledWith($scope.docID)
done() done()
}) })
it('forwards a message with a document', function (done) { it('forwards a message with a document', function (done) {
createController(true, false) this.$scope.messageID = 'id039'
$scope.messageID = 'id039' var messageID = this.$scope.messageID
$scope.forward() this.$scope.forward()
expect($input).toEqual({canSend: true}) expect(this.PeersSelectService.$input).toEqual({canSend: true})
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', { expect(this.$scope.$broadcast).toHaveBeenCalledWith('history_focus', {
peerString: 'Peerselected', peerString: 'Peerselected',
attachment: { attachment: {
_: 'fwd_messages', _: 'fwd_messages',
id: [$scope.messageID] id: [messageID]
} }
}) })
done() done()
}) })
it('deletes a message with a document', function (done) { it('deletes a message with a document', function (done) {
createController(false, false) this.$scope.messageID = 'id123'
$scope.messageID = 'id123'
$scope.delete() this.$scope.delete()
expect($input).toEqual({type: 'MESSAGE_DELETE'}) expect(this.ErrorService.$input).toEqual({type: 'MESSAGE_DELETE'})
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID]) expect(this.AppMessagesManager.deleteMessages).toHaveBeenCalledWith([this.$scope.messageID])
done() done()
}) })
it('downloads the document', function (done) { it('downloads the document', function (done) {
createController(false, false) this.$scope.download()
expect(this.AppDocsManager.saveDocFile).toHaveBeenCalledWith(this.$scope.docID)
$scope.download()
expect($docManager.saveDocFile).toHaveBeenCalledWith($scope.docID)
done() done()
}) })
it('delete a document linked to a message', function (done) { it('can not delete a document not linked to a message', function (done) {
createController(false, true) this.$scope.messageID = 'id42'
$scope.messageID = 'id33'
var historyUpdate = {}
this.$rootScope.$broadcast('history_delete', historyUpdate)
expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect(this.$modalInstance.dismiss).not.toHaveBeenCalled()
$rootScope.$broadcast('history_delete') historyUpdate.msgs = {}
expect($scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function)) this.$rootScope.$broadcast('history_delete', historyUpdate)
expect($modalI.dismiss).not.toHaveBeenCalled() expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect(this.$modalInstance.dismiss).not.toHaveBeenCalled()
done() done()
}) })
it('delete a document linked to a modal instance', function (done) { describe('when the document is related to the message', function () {
createController(false, false) beforeEach(function () {
$scope.messageID = 'id876' this.historyUpdate = {
msgs: {}
}
})
it('delete that document', function (done) {
this.$scope.messageID = 'id33'
this.historyUpdate.msgs[this.$scope.messageID] = 'an update for id33'
var $msgs = {} this.$rootScope.$broadcast('history_delete', this.historyUpdate)
$msgs[$scope.messageID] = {message: 'some non-empty message'} expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
$rootScope.$broadcast('history_delete', {msgs: $msgs}) expect(this.$modalInstance.dismiss).toHaveBeenCalled()
expect($modalI.dismiss).toHaveBeenCalled()
done() done()
}) })
})
}) })

74
test/unit/controllers/EmbedModalController.js

@ -2,18 +2,17 @@
/* global describe, it, inject, expect, beforeEach, jasmine */ /* global describe, it, inject, expect, beforeEach, jasmine */
describe('EmbedModalController', function () { describe('EmbedModalController', function () {
var $scope, $rootScope, $webpageManager, $errService, $input, $messManager, $pSelectService, $modalI
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
$webpageManager = {} this.AppWebPagesManager = {
$webpageManager.wrapForFull = jasmine.createSpy('wrapForFull') wrapForFull: jasmine.createSpy('wrapForFull')
}
$input = {} this.ErrorService = {
$errService = { input: {},
confirm: function (message) { confirm: function (message) {
$input = message this.input = message
return { return {
then: function (f) { then: function (f) {
f() f()
@ -22,9 +21,10 @@ describe('EmbedModalController', function () {
} }
} }
$pSelectService = { this.PeersSelectService = {
input: {},
selectPeer: function (options) { selectPeer: function (options) {
$input = options this.input = options
return { return {
then: function (f) { then: function (f) {
f('Peerselected') f('Peerselected')
@ -33,60 +33,64 @@ describe('EmbedModalController', function () {
} }
} }
$messManager = {} this.AppMessagesManager = {
$messManager.deleteMessages = jasmine.createSpy('deleteMessages') deleteMessages: jasmine.createSpy('deleteMessages')
}
$modalI = {} this.$modalInstance = {
$modalI.dismiss = jasmine.createSpy('dismissModal') dismiss: jasmine.createSpy('dismissModal')
}
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
$rootScope.$broadcast = jasmine.createSpy('$broadcast') this.$rootScope.$broadcast = jasmine.createSpy('$broadcast')
$scope = $rootScope.$new() this.$scope = this.$rootScope.$new()
$scope.webpageID = 'www.notRelevant.com' this.$scope.webpageID = 'www.notRelevant.com'
_$controller_('EmbedModalController', { _$controller_('EmbedModalController', {
$q: {}, $q: {},
$scope: $scope, $scope: this.$scope,
$rootScope: $rootScope, $rootScope: this.$rootScope,
$modalInstance: $modalI, $modalInstance: this.$modalInstance,
PeersSelectService: $pSelectService, PeersSelectService: this.PeersSelectService,
AppMessagesManager: $messManager, AppMessagesManager: this.AppMessagesManager,
AppPeersManager: {}, AppPeersManager: {},
AppPhotosManager: {}, AppPhotosManager: {},
AppWebPagesManager: $webpageManager, AppWebPagesManager: this.AppWebPagesManager,
ErrorService: $errService ErrorService: this.ErrorService
}) })
}) })
}) })
// define tests // define tests
it('sets the embeded webpage in the scope', function (done) { it('sets the embeded webpage in the scope', function (done) {
expect($scope.nav).toEqual({}) expect(this.$scope.nav).toEqual({})
expect($webpageManager.wrapForFull).toHaveBeenCalledWith($scope.webpageID) expect(this.AppWebPagesManager.wrapForFull).toHaveBeenCalledWith(this.$scope.webpageID)
done() done()
}) })
it('forwards a message with an embeded link', function (done) { it('forwards a message with an embeded link', function (done) {
$scope.messageID = 'id1234234' this.$scope.messageID = 'id1234234'
var messageID = this.$scope.messageID
$scope.forward() this.$scope.forward()
expect($input).toEqual({canSend: true}) expect(this.PeersSelectService.input).toEqual({canSend: true})
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', { expect(this.$scope.$broadcast).toHaveBeenCalledWith('history_focus', {
peerString: 'Peerselected', peerString: 'Peerselected',
attachment: { attachment: {
_: 'fwd_messages', _: 'fwd_messages',
id: [$scope.messageID] id: [messageID]
} }
}) })
done() done()
}) })
it('deletes a message with an embeded link', function (done) { it('deletes a message with an embeded link', function (done) {
$scope.messageID = 'id979565673' this.$scope.messageID = 'id979565673'
$scope.delete() this.$scope.delete()
expect($input).toEqual({type: 'MESSAGE_DELETE'}) expect(this.ErrorService.input).toEqual({type: 'MESSAGE_DELETE'})
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID]) expect(this.AppMessagesManager.deleteMessages).toHaveBeenCalledWith([this.$scope.messageID])
done() done()
}) })
}) })

235
test/unit/controllers/PeerSelectControllerSpec.js

@ -2,22 +2,20 @@
/* global describe, it, inject, expect, beforeEach */ /* global describe, it, inject, expect, beforeEach */
describe('PeerSelectController', function () { describe('PeerSelectController', function () {
var $controller, $scope, $q, $mod, $APManager, $EService, createController, timeoutTime, $promiseData, $promise, $promiseFlag
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
// The modalInstance will propably usually give a boolean as return. // The modalInstance will propably usually give a boolean as return.
// However, for testing purposes it is important to gain knowledge about the input of the function // However, for testing purposes it is important to gain knowledge about the input of the function
$mod = { this.$modalInstance = {
close: function (arr) { close: function (arr) {
return arr return arr
} }
} }
timeoutTime = 1000 this.oneSecond = 1000
$APManager = { this.AppPeersManager = {
getPeerString: function (str) { getPeerString: function (str) {
return 'P'.concat(str) return 'P'.concat(str)
}, },
@ -29,229 +27,232 @@ describe('PeerSelectController', function () {
} }
} }
// The controller is created in the test in order to test different initial content of scope variables. this.promise = {
createController = function () { promiseFlag: false,
$controller('PeerSelectController', {
$scope: $scope,
$modalInstance: $mod,
$q: $q,
AppPeersManager: $APManager,
ErrorService: $EService
})
}
$promiseFlag = false
$promise = {
then: function (f) { then: function (f) {
$promiseFlag = true this.$promiseFlag = true
f() f()
} }
} }
$EService = { var promise = this.promise
confirm: function (data) {
$promiseData = data this.$q = {
return $promise when: function () {
return promise
} }
} }
$q = { this.ErrorService = {
when: function () { $promiseData: {},
return $promise confirm: function (data) {
this.$promiseData = data
return promise
} }
} }
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$controller = _$controller_ this.$controller = _$controller_
$scope = _$rootScope_.$new() this.$scope = _$rootScope_.$new()
// The controller is created in the test in order to test different initial content of scope variables.
this.createController = function () {
this.$controller('PeerSelectController', {
$scope: this.$scope,
$modalInstance: this.$modalInstance,
$q: this.$q,
AppPeersManager: this.AppPeersManager,
ErrorService: this.ErrorService
})
}
}) })
}) })
it('initialises properties', function (done) { it('initialises properties', function (done) {
createController() this.createController()
// Set timer to give the controller time to resolve. // Set timer to give the controller time to resolve.
setTimeout(function () { setTimeout(function () {
expect($scope.selectedPeers).toBeDefined() expect(this.$scope.selectedPeers).toBeDefined()
expect($scope.selectedPeersIDs).toBeDefined() expect(this.$scope.selectedPeersIDs).toBeDefined()
expect($scope.selectedCount).toBeDefined() expect(this.$scope.selectedCount).toBeDefined()
}, timeoutTime) }, this.oneSecond)
done() done()
}) })
it('compiles with a shareLinkPromise that resolves', function (done) { it('compiles with a shareLinkPromise that resolves', function (done) {
var expected = 'testURL' var expected = 'testURL'
$scope.shareLinkPromise = { var oneSecond = this.oneSecond
this.$scope.shareLinkPromise = {
then: function (resolve, reject) { then: function (resolve, reject) {
setTimeout(resolve(expected), timeoutTime) setTimeout(resolve(expected), oneSecond)
} }
} }
createController() this.createController()
setTimeout(function () { function afterLoad () {
expect($scope.shareLink.loading).toBe(true) expect(this.$scope.shareLink.url).toBe(expected)
expect($scope.shareLink.url).not.toBeDefined() }
setTimeout(function () {
expect($scope.shareLink.url).toBe(expected) function duringLoad () {
}, timeoutTime) expect(this.$scope.shareLink.loading).toBe(true)
}, timeoutTime) expect(this.$scope.shareLink.url).not.toBeDefined()
setTimeout(afterLoad, oneSecond)
}
setTimeout(duringLoad, oneSecond)
done() done()
}) })
it('compiles with a shareLinkPromise that doesn\'t resolve', function (done) { it('compiles with a shareLinkPromise that doesn\'t resolve', function (done) {
$scope.shareLinkPromise = { var oneSecond = this.oneSecond
this.$scope.shareLinkPromise = {
then: function (resolve, reject) { then: function (resolve, reject) {
setTimeout(reject(), timeoutTime) setTimeout(reject(), oneSecond)
} }
} }
createController() this.createController()
setTimeout(function () { function afterLoad () {
expect($scope.shareLink.loading).toBe(true) expect(this.$scope.shareLink).not.toBeDefined()
setTimeout(function () { }
expect($scope.shareLink).not.toBeDefined()
}, timeoutTime) function duringLoad () {
}, timeoutTime) expect(this.$scope.shareLink.loading).toBe(true)
setTimeout(afterLoad, oneSecond)
}
setTimeout(duringLoad, oneSecond)
done() done()
}) })
it('can select and submit a single dialog without confirmed type', function (done) { describe('after initialisation', function () {
createController() beforeEach(function () {
this.createController()
})
$scope.dialogSelect('dialogX') it('can select and submit a single dialog without confirmed type', function (done) {
this.$scope.dialogSelect('dialogX')
expect($promiseData).not.toBeDefined() expect(this.ErrorService.$promiseData).toEqual({})
expect($promiseFlag).toBe(true) expect(this.promise.$promiseFlag).toBe(true)
done() done()
}) })
it('can select and submit a single dialog with confirmed type', function (done) { it('can select and submit a single dialog with confirmed type', function (done) {
createController() this.$scope.confirm_type = 'INVITE_TO_GROUP'
this.$scope.dialogSelect('dialogX')
$scope.confirm_type = 'INVITE_TO_GROUP'
$scope.dialogSelect('dialogX')
var peerId = 'X'
var expected = { var expected = {
type: 'INVITE_TO_GROUP', type: 'INVITE_TO_GROUP',
peer_id: 'X', peer_id: peerId,
peer_data: 'Xpeer' peer_data: this.AppPeersManager.getPeer(peerId)
} }
expect($promiseData).toEqual(expected) expect(this.ErrorService.$promiseData).toEqual(expected)
expect($promiseFlag).toBe(true) expect(this.promise.$promiseFlag).toBe(true)
done() done()
}) })
it('can select a dialog', function (done) { it('can select a dialog', function (done) {
createController() this.$scope.multiSelect = true
this.$scope.dialogSelect('dialogX')
$scope.multiSelect = true
$scope.dialogSelect('dialogX')
var expected = ['X'] var expected = {
selectedPeers: 'Xpeer',
selectedPeerIDs: ['X']
}
expect($scope.selectedPeers['X']).toBe('Xpeer') expect(this.$scope.selectedPeers['X']).toBe(expected.selectedPeers)
expect($scope.selectedCount).toBe(1) expect(this.$scope.selectedCount).toBe(1)
expect($scope.selectedPeerIDs).toEqual(expected) expect(this.$scope.selectedPeerIDs).toEqual(expected.selectedPeerIDs)
done() done()
}) })
it('can select multiple dialogs', function (done) { it('can select multiple dialogs', function (done) {
createController() this.$scope.multiSelect = true
this.$scope.dialogSelect('dialogX')
$scope.multiSelect = true this.$scope.dialogSelect('dialogZ')
$scope.dialogSelect('dialogX') this.$scope.dialogSelect('dialogY')
$scope.dialogSelect('dialogZ')
$scope.dialogSelect('dialogY')
var expected = ['Y', 'Z', 'X'] var expected = ['Y', 'Z', 'X']
expect($scope.selectedCount).toBe(3) expect(this.$scope.selectedCount).toBe(3)
expect($scope.selectedPeerIDs).toEqual(expected) expect(this.$scope.selectedPeerIDs).toEqual(expected)
done() done()
}) })
it('can unselect a dialog', function (done) { it('can unselect a dialog', function (done) {
createController() this.$scope.multiSelect = true
this.$scope.selectedCount = 1
this.$scope.selectedPeers['Y'] = 'aYPeer'
this.$scope.selectedPeerIDs.unshift('Y')
$scope.multiSelect = true this.$scope.dialogSelect('dialogY')
$scope.selectedCount = 1
$scope.selectedPeers['Y'] = 'aYPeer'
$scope.selectedPeerIDs.unshift('Y')
$scope.dialogSelect('dialogY')
var expected = [] var expected = []
expect($scope.selectedPeers['Y']).not.toBeDefined() expect(this.$scope.selectedPeers['Y']).not.toBeDefined()
expect($scope.selectedCount).toBe(0) expect(this.$scope.selectedCount).toBe(0)
expect($scope.selectedPeerIDs).toEqual(expected) expect(this.$scope.selectedPeerIDs).toEqual(expected)
done() done()
}) })
it('can select multiple dialogs', function (done) { it('can select multiple dialogs', function (done) {
createController() this.$scope.multiSelect = true
this.$scope.dialogSelect('dialogX')
$scope.multiSelect = true this.$scope.dialogSelect('dialogZ')
$scope.dialogSelect('dialogX') this.$scope.dialogSelect('dialogY')
$scope.dialogSelect('dialogZ') this.$scope.dialogSelect('dialogZ')
$scope.dialogSelect('dialogY')
$scope.dialogSelect('dialogZ')
var expected = ['Y', 'X'] var expected = ['Y', 'X']
expect($scope.selectedCount).toBe(2) expect(this.$scope.selectedCount).toBe(2)
expect($scope.selectedPeerIDs).toEqual(expected) expect(this.$scope.selectedPeerIDs).toEqual(expected)
done() done()
}) })
it('can\'t submit a empty set of dialogs', function (done) { it('can\'t submit a empty set of dialogs', function (done) {
createController() expect(this.$scope.submitSelected()).not.toBeDefined()
expect($scope.submitSelected()).not.toBeDefined()
done() done()
}) })
it('can submit one dialog', function (done) { it('can submit one dialog', function (done) {
createController() this.$scope.selectedCount = 1
this.$scope.selectedPeers['test'] = 'peer'
$scope.selectedCount = 1
$scope.selectedPeers['test'] = 'peer'
var expected = ['Ptest'] var expected = ['Ptest']
expect($scope.submitSelected()).toEqual(expected) expect(this.$scope.submitSelected()).toEqual(expected)
done() done()
}) })
it('can submit multiple dialogs', function (done) { it('can submit multiple dialogs', function (done) {
createController() this.$scope.selectedCount = 3
this.$scope.selectedPeers['test1'] = this.$scope.selectedPeers['test2'] = this.$scope.selectedPeers['test4'] = 'peer'
$scope.selectedCount = 3
$scope.selectedPeers['test1'] = $scope.selectedPeers['test2'] = $scope.selectedPeers['test4'] = 'peer'
var expected = ['Ptest4', 'Ptest2', 'Ptest1'] var expected = ['Ptest4', 'Ptest2', 'Ptest1']
expect($scope.submitSelected()).toEqual(expected) expect(this.$scope.submitSelected()).toEqual(expected)
done() done()
}) })
it('can toggle', function (done) { it('can toggle', function (done) {
createController()
var broadcastFlag = '' var broadcastFlag = ''
$scope.$broadcast = function (input) { broadcastFlag = input } this.$scope.$broadcast = function (input) { broadcastFlag = input }
$scope.toggleSearch() this.$scope.toggleSearch()
expect(broadcastFlag).toBe('dialogs_search_toggle') expect(broadcastFlag).toBe('dialogs_search_toggle')
done() done()
}) })
})
}) })

152
test/unit/controllers/VideoModalControllerSpec.js

@ -1,20 +1,19 @@
'use strict' 'use strict'
/* global describe, it, inject, expect, beforeEach, jasmine */ /* global describe, it, inject, expect, beforeEach, jasmine, spyOn */
describe('VideoModalController', function () { describe('VideoModalController', function () {
var $controller, $scope, $rootScope, $docManager, $errService, $input, $messManager, $pSelectService, $modalI, createController
beforeEach(module('myApp.controllers')) beforeEach(module('myApp.controllers'))
beforeEach(function () { beforeEach(function () {
$docManager = {} this.AppDocsManager = {
$docManager.wrapVideoForFull = jasmine.createSpy('wrapVideoForFull') wrapVideoForFull: jasmine.createSpy('wrapVideoForFull'),
$docManager.saveDocFile = jasmine.createSpy('saveDocFile') saveDocFile: jasmine.createSpy('saveDocFile')
}
$input = {} this.ErrorService = {
$errService = { input: {},
confirm: function (message) { confirm: function (message) {
$input = message this.input = message
return { return {
then: function (f) { then: function (f) {
f() f()
@ -23,9 +22,10 @@ describe('VideoModalController', function () {
} }
} }
$pSelectService = { this.PeersSelectService = {
input: {},
selectPeer: function (options) { selectPeer: function (options) {
$input = options this.input = options
return { return {
then: function (f) { then: function (f) {
f('Peerselected') f('Peerselected')
@ -34,102 +34,114 @@ describe('VideoModalController', function () {
} }
} }
createController = function (spyBroadcast, spyOn) { this.AppMessagesManager = {
if (spyBroadcast) { deleteMessages: jasmine.createSpy('deleteMessages')
$rootScope.$broadcast = jasmine.createSpy('$broadcast')
}
if (spyOn) {
$scope.$on = jasmine.createSpy('$on')
}
$controller('VideoModalController', {
$scope: $scope,
$rootScope: $rootScope,
$modalInstance: $modalI,
PeersSelectService: $pSelectService,
AppMessagesManager: $messManager,
AppDocsManager: $docManager,
AppPeersManager: {},
ErrorService: $errService
})
} }
$messManager = {} this.$modalInstance = {
$messManager.deleteMessages = jasmine.createSpy('deleteMessages') dismiss: jasmine.createSpy('dismissModal')
}
$modalI = {}
$modalI.dismiss = jasmine.createSpy('dismissModal')
inject(function (_$controller_, _$rootScope_) { inject(function (_$controller_, _$rootScope_) {
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
$scope = $rootScope.$new() this.$scope = this.$rootScope.$new()
$scope.docID = 'randomvideo' this.$scope.docID = 'randomvideo'
$controller = _$controller_ this.$controller = _$controller_
spyOn(this.$rootScope, '$broadcast').and.callThrough()
spyOn(this.$scope, '$on').and.callThrough()
this.$controller('VideoModalController', {
$scope: this.$scope,
$rootScope: this.$rootScope,
$modalInstance: this.$modalInstance,
PeersSelectService: this.PeersSelectService,
AppMessagesManager: this.AppMessagesManager,
AppDocsManager: this.AppDocsManager,
AppPeersManager: {},
ErrorService: this.ErrorService
})
}) })
}) })
// define tests // define tests
it('sets the video in the scope', function (done) { it('sets the video in the scope', function (done) {
createController(false, false) expect(this.$scope.progress).toEqual({enabled: false})
expect(this.$scope.player).toEqual({})
expect($scope.progress).toEqual({enabled: false}) expect(this.AppDocsManager.wrapVideoForFull).toHaveBeenCalledWith(this.$scope.docID)
expect($scope.player).toEqual({})
expect($docManager.wrapVideoForFull).toHaveBeenCalledWith($scope.docID)
done() done()
}) })
it('forwards a message with a video', function (done) { it('forwards a message with a video', function (done) {
createController(true, false) this.$scope.messageID = 'id68567'
$scope.messageID = 'id68567' var messageID = this.$scope.messageID
$scope.forward() this.$scope.forward()
expect($input).toEqual({canSend: true}) expect(this.PeersSelectService.input).toEqual({canSend: true})
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', { expect(this.$scope.$broadcast).toHaveBeenCalledWith('history_focus', {
peerString: 'Peerselected', peerString: 'Peerselected',
attachment: { attachment: {
_: 'fwd_messages', _: 'fwd_messages',
id: [$scope.messageID] id: [messageID]
} }
}) })
done() done()
}) })
it('deletes a message with a video', function (done) { it('deletes a message with a video', function (done) {
createController(false, false) this.$scope.messageID = 'id235235'
$scope.messageID = 'id235235'
$scope.delete() this.$scope.delete()
expect($input).toEqual({type: 'MESSAGE_DELETE'}) expect(this.ErrorService.input).toEqual({type: 'MESSAGE_DELETE'})
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID]) expect(this.AppMessagesManager.deleteMessages).toHaveBeenCalledWith([this.$scope.messageID])
done() done()
}) })
it('downloads the document (video)', function (done) { it('downloads the document (video)', function (done) {
createController(false, false) this.$scope.download()
expect(this.AppDocsManager.saveDocFile).toHaveBeenCalledWith(this.$scope.docID)
$scope.download()
expect($docManager.saveDocFile).toHaveBeenCalledWith($scope.docID)
done() done()
}) })
it('delete a video linked to a message', function (done) { it('delete a video linked to a message', function (done) {
createController(false, true) this.$scope.messageID = 'id2352'
$scope.messageID = 'id2352'
$rootScope.$broadcast('history_delete') this.$rootScope.$broadcast('history_delete')
expect($scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function)) expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect($modalI.dismiss).not.toHaveBeenCalled() expect(this.$modalInstance.dismiss).not.toHaveBeenCalled()
done() done()
}) })
it('delete a video linked to a modal instance', function (done) { it('can not delete a video not linked to a message', function (done) {
createController(false, false) this.$scope.messageID = 'id42'
$scope.messageID = 'id6234'
var historyUpdate = {}
this.$rootScope.$broadcast('history_delete', historyUpdate)
expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect(this.$modalInstance.dismiss).not.toHaveBeenCalled()
var $msgs = {} historyUpdate.msgs = {}
$msgs[$scope.messageID] = {message: 'some non-empty message'} this.$rootScope.$broadcast('history_delete', historyUpdate)
$rootScope.$broadcast('history_delete', {msgs: $msgs}) expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect($modalI.dismiss).toHaveBeenCalled() expect(this.$modalInstance.dismiss).not.toHaveBeenCalled()
done() done()
}) })
describe('when the video is related to the message', function () {
beforeEach(function () {
this.historyUpdate = {
msgs: {}
}
})
it('delete that video', function (done) {
this.$scope.messageID = 'id33'
this.historyUpdate.msgs[this.$scope.messageID] = 'an update for id33'
this.$rootScope.$broadcast('history_delete', this.historyUpdate)
expect(this.$scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
expect(this.$modalInstance.dismiss).toHaveBeenCalled()
done()
})
})
}) })

14
test/unit/directives/myHeadDirective.js

@ -2,25 +2,23 @@
/* global describe, it, inject, expect, beforeEach */ /* global describe, it, inject, expect, beforeEach */
describe('myHead directive', function () { describe('myHead directive', function () {
var $compile, $rootScope
beforeEach(module('myApp.templates')) beforeEach(module('myApp.templates'))
beforeEach(module('myApp.directives')) beforeEach(module('myApp.directives'))
beforeEach(inject(function (_$compile_, _$rootScope_) { beforeEach(inject(function (_$compile_, _$rootScope_) {
$compile = _$compile_ this.$compile = _$compile_
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
})) }))
it('compiles a my-head attribute', function () { it('compiles a my-head attribute', function () {
var compiledElement = $compile('<div my-head></div>')($rootScope) var compiledElement = this.$compile('<div my-head></div>')(this.$rootScope)
$rootScope.$digest() // Fire watchers this.$rootScope.$digest()
expect(compiledElement.html()).toContain('tg_page_head') expect(compiledElement.html()).toContain('tg_page_head')
}) })
it('compiles a my-head element', function () { it('compiles a my-head element', function () {
var compiledElement = $compile('<my-head></my-head>')($rootScope) var compiledElement = this.$compile('<my-head></my-head>')(this.$rootScope)
$rootScope.$digest() // Fire watchers this.$rootScope.$digest()
expect(compiledElement.html()).toContain('tg_page_head') expect(compiledElement.html()).toContain('tg_page_head')
}) })
}) })

14
test/unit/directives/myLangFooterDirective.js

@ -2,8 +2,6 @@
/* global describe, it, inject, expect, beforeEach */ /* global describe, it, inject, expect, beforeEach */
describe('myLangFooter directive', function () { describe('myLangFooter directive', function () {
var $compile, $rootScope
beforeEach(module('ui.bootstrap')) beforeEach(module('ui.bootstrap'))
beforeEach(module('myApp.templates')) beforeEach(module('myApp.templates'))
// ErrorServiceProvider in myApp.services is needed by // ErrorServiceProvider in myApp.services is needed by
@ -13,20 +11,20 @@ describe('myLangFooter directive', function () {
beforeEach(module('myApp.directives')) beforeEach(module('myApp.directives'))
beforeEach(inject(function (_$compile_, _$rootScope_) { beforeEach(inject(function (_$compile_, _$rootScope_) {
$compile = _$compile_ this.$compile = _$compile_
$rootScope = _$rootScope_ this.$rootScope = _$rootScope_
})) }))
it('compiles a my-lang-footer attribute', function () { it('compiles a my-lang-footer attribute', function () {
var compiledElement = $compile('<div my-lang-footer></div>')($rootScope) var compiledElement = this.$compile('<div my-lang-footer></div>')(this.$rootScope)
$rootScope.$digest() // Fire watchers this.$rootScope.$digest()
expect(compiledElement.html()).toContain('footer_lang_link') expect(compiledElement.html()).toContain('footer_lang_link')
expect(compiledElement.html()).toContain('AppLangSelectController') expect(compiledElement.html()).toContain('AppLangSelectController')
}) })
it('compiles a my-lang-footer element', function () { it('compiles a my-lang-footer element', function () {
var compiledElement = $compile('<my-lang-footer></my-lang-footer>')($rootScope) var compiledElement = this.$compile('<my-lang-footer></my-lang-footer>')(this.$rootScope)
$rootScope.$digest() // Fire watchers this.$rootScope.$digest()
expect(compiledElement.html()).toContain('footer_lang_link') expect(compiledElement.html()).toContain('footer_lang_link')
expect(compiledElement.html()).toContain('AppLangSelectController') expect(compiledElement.html()).toContain('AppLangSelectController')
}) })

20
test/unit/services/PhonebookContactsServiceSpec.js

@ -2,52 +2,50 @@
/* global describe, it, inject, expect, beforeEach, jasmine, xit */ /* global describe, it, inject, expect, beforeEach, jasmine, xit */
describe('PhonebookContactsService', function () { describe('PhonebookContactsService', function () {
var PhonebookContactsService, $modal
beforeEach(module('ui.bootstrap')) beforeEach(module('ui.bootstrap'))
beforeEach(module('myApp.services')) beforeEach(module('myApp.services'))
beforeEach(inject(function (_PhonebookContactsService_) { beforeEach(inject(function (_PhonebookContactsService_) {
PhonebookContactsService = _PhonebookContactsService_ this.PhonebookContactsService = _PhonebookContactsService_
})) }))
describe('Public API:', function () { describe('Public API:', function () {
it('checks availability', function () { it('checks availability', function () {
expect(PhonebookContactsService.isAvailable).toBeDefined() expect(this.PhonebookContactsService.isAvailable).toBeDefined()
}) })
it('open the phonebook for import', function () { it('open the phonebook for import', function () {
expect(PhonebookContactsService.openPhonebookImport).toBeDefined() expect(this.PhonebookContactsService.openPhonebookImport).toBeDefined()
}) })
it('get phonebook contacts', function () { it('get phonebook contacts', function () {
expect(PhonebookContactsService.getPhonebookContacts).toBeDefined() expect(this.PhonebookContactsService.getPhonebookContacts).toBeDefined()
}) })
describe('usage', function () { describe('usage', function () {
describe('of isAvailable()', function () { describe('of isAvailable()', function () {
it('returns false in most cases', function (done) { it('returns false in most cases', function (done) {
expect(PhonebookContactsService.isAvailable()).toBe(false) expect(this.PhonebookContactsService.isAvailable()).toBe(false)
done() done()
}) })
}) })
describe('of openPhonebookImport()', function () { describe('of openPhonebookImport()', function () {
beforeEach(function () { beforeEach(function () {
$modal = { this.$modal = {
open: jasmine.createSpy('open') open: jasmine.createSpy('open')
} }
}) })
xit('opens a modal', function () { xit('opens a modal', function () {
PhonebookContactsService.openPhonebookImport() this.PhonebookContactsService.openPhonebookImport()
expect($modal.open).toHaveBeenCalled() expect(this.$modal.open).toHaveBeenCalled()
}) })
}) })
describe('of getPhonebookContacts()', function () { describe('of getPhonebookContacts()', function () {
xit('will get rejected in most cases', function (done) { xit('will get rejected in most cases', function (done) {
var promise = PhonebookContactsService.getPhonebookContacts() var promise = this.PhonebookContactsService.getPhonebookContacts()
promise.finally(function () { promise.finally(function () {
expect(promise.isFullfilled()).toBe(true) expect(promise.isFullfilled()).toBe(true)
done() done()

Loading…
Cancel
Save