Added tests for AppImPanelController, DocumentModalController, EmbedModalController and VideoModalController (#1362)
* Added test for AppImPanelControllerSpec, cleaned up style of all tests All tests give 0 errors when running gulp standard All credits for those test still go to @Ryuno-Ki, I did not functionaly change the testing code * add Test for DocumentModalController * added tests for the EmbedModalController and VideoModalController
This commit is contained in:
parent
e2b1314427
commit
03bc92006d
21
test/unit/AppImPanelControllerSpec.js
Normal file
21
test/unit/AppImPanelControllerSpec.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/* global describe, it, inject, expect, beforeEach, jasmine */
|
||||||
|
|
||||||
|
describe('AppImPanelController', function () {
|
||||||
|
var $scope
|
||||||
|
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
inject(function (_$controller_, _$rootScope_) {
|
||||||
|
$scope = _$rootScope_.$new()
|
||||||
|
$scope.$on = jasmine.createSpy('$on')
|
||||||
|
_$controller_('AppImPanelController', { $scope: $scope })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// define tests
|
||||||
|
it('sets $on(user_update) to no-operation function', function (done) {
|
||||||
|
expect($scope.$on).toHaveBeenCalledWith('user_update', angular.noop)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
@ -1,13 +1,15 @@
|
|||||||
describe('AppLangSelectController', function () {
|
/* global describe, it, inject, expect, beforeEach, xit */
|
||||||
var $controller, $scope;
|
|
||||||
|
|
||||||
beforeEach(module('ui.bootstrap'));
|
describe('AppLangSelectController', function () {
|
||||||
beforeEach(module('myApp.services'));
|
var $controller, $scope
|
||||||
beforeEach(module('myApp.controllers'));
|
|
||||||
|
beforeEach(module('ui.bootstrap'))
|
||||||
|
beforeEach(module('myApp.services'))
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
inject(function (_$controller_, _$rootScope_, _, Storage, ErrorService, AppRuntimeManager) {
|
inject(function (_$controller_, _$rootScope_, _, Storage, ErrorService, AppRuntimeManager) {
|
||||||
$controller = _$controller_;
|
$controller = _$controller_
|
||||||
$scope = _$rootScope_.$new()
|
$scope = _$rootScope_.$new()
|
||||||
$controller('AppLangSelectController', {
|
$controller('AppLangSelectController', {
|
||||||
$scope: $scope,
|
$scope: $scope,
|
||||||
@ -15,36 +17,36 @@ describe('AppLangSelectController', function () {
|
|||||||
Storage: Storage,
|
Storage: Storage,
|
||||||
ErrorService: ErrorService,
|
ErrorService: ErrorService,
|
||||||
AppRuntimeManager: AppRuntimeManager
|
AppRuntimeManager: AppRuntimeManager
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
it('holds the supportedLocales', function () {
|
it('holds the supportedLocales', function () {
|
||||||
expect($scope.supportedLocales).toBeDefined();
|
expect($scope.supportedLocales).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('holds langNames', function () {
|
it('holds langNames', function () {
|
||||||
expect($scope.langNames).toBeDefined();
|
expect($scope.langNames).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('holds the current locale', function () {
|
it('holds the current locale', function () {
|
||||||
expect($scope.curLocale).toBeDefined();
|
expect($scope.curLocale).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('has a locale form', function () {
|
it('has a locale form', function () {
|
||||||
expect($scope.form).toBeDefined();
|
expect($scope.form).toBeDefined()
|
||||||
expect($scope.form.locale).toBeDefined();
|
expect($scope.form.locale).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('allows to select a locale', function () {
|
it('allows to select a locale', function () {
|
||||||
expect($scope.localeSelect).toBeDefined();
|
expect($scope.localeSelect).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
describe('when the user switches the locale', function () {
|
describe('when the user switches the locale', function () {
|
||||||
describe('and confirms the dialogue', function () {
|
describe('and confirms the dialogue', function () {
|
||||||
xit('reloads the app', function (done) {
|
xit('reloads the app', function (done) {
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
@ -1,36 +1,38 @@
|
|||||||
describe('AppWelcomeController', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $controller, $rootScope, $scope, $location, MtApiManager, ErrorService,
|
|
||||||
ChangelogNotifyService, LayoutSwitchService;
|
|
||||||
|
|
||||||
beforeEach(module('myApp.controllers'));
|
describe('AppWelcomeController', function () {
|
||||||
|
var $controller, $rootScope, $scope, $location, MtpApiManager, ErrorService,
|
||||||
|
ChangelogNotifyService, LayoutSwitchService
|
||||||
|
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
ChangelogNotifyService = {
|
ChangelogNotifyService = {
|
||||||
checkUpdate: function () {}
|
checkUpdate: function () {}
|
||||||
};
|
}
|
||||||
|
|
||||||
LayoutSwitchService = {
|
LayoutSwitchService = {
|
||||||
start: function () {}
|
start: function () {}
|
||||||
};
|
}
|
||||||
|
|
||||||
MtpApiManager = {
|
MtpApiManager = {
|
||||||
getUserID: function () {
|
getUserID: function () {
|
||||||
return {
|
return {
|
||||||
then: function () {}
|
then: function () {}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module(function ($provide) {
|
module(function ($provide) {
|
||||||
$provide.value('MtpApiManager', MtpApiManager);
|
$provide.value('MtpApiManager', MtpApiManager)
|
||||||
});
|
})
|
||||||
|
|
||||||
inject(function (_$controller_, _$rootScope_, _$location_) {
|
inject(function (_$controller_, _$rootScope_, _$location_) {
|
||||||
$controller = _$controller_;
|
$controller = _$controller_
|
||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_
|
||||||
$location = _$location_;
|
$location = _$location_
|
||||||
|
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new()
|
||||||
$controller('AppWelcomeController', {
|
$controller('AppWelcomeController', {
|
||||||
$scope: $scope,
|
$scope: $scope,
|
||||||
$location: $location,
|
$location: $location,
|
||||||
@ -38,13 +40,13 @@ describe('AppWelcomeController', function () {
|
|||||||
ErrorService: ErrorService,
|
ErrorService: ErrorService,
|
||||||
ChangelogNotifyService: ChangelogNotifyService,
|
ChangelogNotifyService: ChangelogNotifyService,
|
||||||
LayoutSwitchService: LayoutSwitchService
|
LayoutSwitchService: LayoutSwitchService
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
// https://stackoverflow.com/a/36460924
|
// https://stackoverflow.com/a/36460924
|
||||||
it('executes a dummy spec', function (done) {
|
it('executes a dummy spec', function (done) {
|
||||||
expect(true).toBe(true);
|
expect(true).toBe(true)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
132
test/unit/DocumentModalControllerSpec.js
Normal file
132
test/unit/DocumentModalControllerSpec.js
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/* global describe, it, inject, expect, beforeEach, jasmine */
|
||||||
|
|
||||||
|
describe('DocumentModalController', function () {
|
||||||
|
var $controller, $scope, $rootScope, $docManager, $errService, $input, $messManager, $pSelectService, $modalI, createController
|
||||||
|
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$docManager = {}
|
||||||
|
$docManager.wrapForHistory = jasmine.createSpy('wrapForHistory')
|
||||||
|
$docManager.saveDocFile = jasmine.createSpy('saveDocFile')
|
||||||
|
|
||||||
|
$input = {}
|
||||||
|
$errService = {
|
||||||
|
confirm: function (message) {
|
||||||
|
$input = message
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pSelectService = {
|
||||||
|
selectPeer: function (options) {
|
||||||
|
$input = options
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f('Peerselected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createController = function (spyBroadcast, spyOn) {
|
||||||
|
if (spyBroadcast) {
|
||||||
|
$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 = {}
|
||||||
|
$modalI.dismiss = jasmine.createSpy('dismissModal')
|
||||||
|
|
||||||
|
inject(function (_$controller_, _$rootScope_) {
|
||||||
|
$rootScope = _$rootScope_
|
||||||
|
$scope = $rootScope.$new()
|
||||||
|
$scope.docID = 'randomdoc'
|
||||||
|
|
||||||
|
$controller = _$controller_
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// define tests
|
||||||
|
it('sets the document in the scope', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
|
||||||
|
expect($docManager.wrapForHistory).toHaveBeenCalledWith($scope.docID)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('forwards a message with a document', function (done) {
|
||||||
|
createController(true, false)
|
||||||
|
$scope.messageID = 'id039'
|
||||||
|
|
||||||
|
$scope.forward()
|
||||||
|
expect($input).toEqual({canSend: true})
|
||||||
|
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', {
|
||||||
|
peerString: 'Peerselected',
|
||||||
|
attachment: {
|
||||||
|
_: 'fwd_messages',
|
||||||
|
id: [$scope.messageID]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('deletes a message with a document', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
$scope.messageID = 'id123'
|
||||||
|
|
||||||
|
$scope.delete()
|
||||||
|
expect($input).toEqual({type: 'MESSAGE_DELETE'})
|
||||||
|
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID])
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('downloads the document', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
|
||||||
|
$scope.download()
|
||||||
|
expect($docManager.saveDocFile).toHaveBeenCalledWith($scope.docID)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('delete a document linked to a message', function (done) {
|
||||||
|
createController(false, true)
|
||||||
|
$scope.messageID = 'id33'
|
||||||
|
|
||||||
|
$rootScope.$broadcast('history_delete')
|
||||||
|
expect($scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
|
||||||
|
expect($modalI.dismiss).not.toHaveBeenCalled()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('delete a document linked to a modal instance', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
$scope.messageID = 'id876'
|
||||||
|
|
||||||
|
var $msgs = {}
|
||||||
|
$msgs[$scope.messageID] = {message: 'some non-empty message'}
|
||||||
|
$rootScope.$broadcast('history_delete', {msgs: $msgs})
|
||||||
|
expect($modalI.dismiss).toHaveBeenCalled()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
91
test/unit/EmbedModalController.js
Normal file
91
test/unit/EmbedModalController.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/* global describe, it, inject, expect, beforeEach, jasmine */
|
||||||
|
|
||||||
|
describe('EmbedModalController', function () {
|
||||||
|
var $scope, $rootScope, $webpageManager, $errService, $input, $messManager, $pSelectService, $modalI
|
||||||
|
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$webpageManager = {}
|
||||||
|
$webpageManager.wrapForFull = jasmine.createSpy('wrapForFull')
|
||||||
|
|
||||||
|
$input = {}
|
||||||
|
$errService = {
|
||||||
|
confirm: function (message) {
|
||||||
|
$input = message
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pSelectService = {
|
||||||
|
selectPeer: function (options) {
|
||||||
|
$input = options
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f('Peerselected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$messManager = {}
|
||||||
|
$messManager.deleteMessages = jasmine.createSpy('deleteMessages')
|
||||||
|
|
||||||
|
$modalI = {}
|
||||||
|
$modalI.dismiss = jasmine.createSpy('dismissModal')
|
||||||
|
|
||||||
|
inject(function (_$controller_, _$rootScope_) {
|
||||||
|
$rootScope = _$rootScope_
|
||||||
|
$rootScope.$broadcast = jasmine.createSpy('$broadcast')
|
||||||
|
$scope = $rootScope.$new()
|
||||||
|
$scope.webpageID = 'www.notRelevant.com'
|
||||||
|
_$controller_('EmbedModalController', {
|
||||||
|
$q: {},
|
||||||
|
$scope: $scope,
|
||||||
|
$rootScope: $rootScope,
|
||||||
|
$modalInstance: $modalI,
|
||||||
|
PeersSelectService: $pSelectService,
|
||||||
|
AppMessagesManager: $messManager,
|
||||||
|
AppPeersManager: {},
|
||||||
|
AppPhotosManager: {},
|
||||||
|
AppWebPagesManager: $webpageManager,
|
||||||
|
ErrorService: $errService
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// define tests
|
||||||
|
it('sets the embeded webpage in the scope', function (done) {
|
||||||
|
expect($scope.nav).toEqual({})
|
||||||
|
expect($webpageManager.wrapForFull).toHaveBeenCalledWith($scope.webpageID)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('forwards a message with an embeded link', function (done) {
|
||||||
|
$scope.messageID = 'id1234234'
|
||||||
|
|
||||||
|
$scope.forward()
|
||||||
|
expect($input).toEqual({canSend: true})
|
||||||
|
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', {
|
||||||
|
peerString: 'Peerselected',
|
||||||
|
attachment: {
|
||||||
|
_: 'fwd_messages',
|
||||||
|
id: [$scope.messageID]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('deletes a message with an embeded link', function (done) {
|
||||||
|
$scope.messageID = 'id979565673'
|
||||||
|
|
||||||
|
$scope.delete()
|
||||||
|
expect($input).toEqual({type: 'MESSAGE_DELETE'})
|
||||||
|
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID])
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
@ -1,56 +1,58 @@
|
|||||||
describe('PhonebookContactsService', function () {
|
/* global describe, it, inject, expect, beforeEach, jasmine, xit */
|
||||||
var PhonebookContactsService;
|
|
||||||
|
|
||||||
beforeEach(module('ui.bootstrap'));
|
describe('PhonebookContactsService', function () {
|
||||||
beforeEach(module('myApp.services'));
|
var PhonebookContactsService, $modal
|
||||||
|
|
||||||
|
beforeEach(module('ui.bootstrap'))
|
||||||
|
beforeEach(module('myApp.services'))
|
||||||
|
|
||||||
beforeEach(inject(function (_PhonebookContactsService_) {
|
beforeEach(inject(function (_PhonebookContactsService_) {
|
||||||
PhonebookContactsService = _PhonebookContactsService_;
|
PhonebookContactsService = _PhonebookContactsService_
|
||||||
}));
|
}))
|
||||||
|
|
||||||
describe('Public API:', function () {
|
describe('Public API:', function () {
|
||||||
it('checks availability', function () {
|
it('checks availability', function () {
|
||||||
expect(PhonebookContactsService.isAvailable).toBeDefined();
|
expect(PhonebookContactsService.isAvailable).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('open the phonebook for import', function () {
|
it('open the phonebook for import', function () {
|
||||||
expect(PhonebookContactsService.openPhonebookImport).toBeDefined();
|
expect(PhonebookContactsService.openPhonebookImport).toBeDefined()
|
||||||
});
|
})
|
||||||
|
|
||||||
it('get phonebook contacts', function () {
|
it('get phonebook contacts', function () {
|
||||||
expect(PhonebookContactsService.getPhonebookContacts).toBeDefined();
|
expect(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(PhonebookContactsService.isAvailable()).toBe(false)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
describe('of openPhonebookImport()', function () {
|
describe('of openPhonebookImport()', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$modal = {
|
$modal = {
|
||||||
open: jasmine.createSpy('open')
|
open: jasmine.createSpy('open')
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
xit('opens a modal', function () {
|
xit('opens a modal', function () {
|
||||||
PhonebookContactsService.openPhonebookImport();
|
PhonebookContactsService.openPhonebookImport()
|
||||||
expect($modal.open).toHaveBeenCalled();
|
expect($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) {
|
||||||
promise = PhonebookContactsService.getPhonebookContacts();
|
var promise = PhonebookContactsService.getPhonebookContacts()
|
||||||
promise.finally(function () {
|
promise.finally(function () {
|
||||||
expect(promise.isFullfilled()).toBe(true);
|
expect(promise.isFullfilled()).toBe(true)
|
||||||
done();
|
done()
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
134
test/unit/VideoModalControllerSpec.js
Normal file
134
test/unit/VideoModalControllerSpec.js
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/* global describe, it, inject, expect, beforeEach, jasmine */
|
||||||
|
|
||||||
|
describe('VideoModalController', function () {
|
||||||
|
var $controller, $scope, $rootScope, $docManager, $errService, $input, $messManager, $pSelectService, $modalI, createController
|
||||||
|
|
||||||
|
beforeEach(module('myApp.controllers'))
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$docManager = {}
|
||||||
|
$docManager.wrapVideoForFull = jasmine.createSpy('wrapVideoForFull')
|
||||||
|
$docManager.saveDocFile = jasmine.createSpy('saveDocFile')
|
||||||
|
|
||||||
|
$input = {}
|
||||||
|
$errService = {
|
||||||
|
confirm: function (message) {
|
||||||
|
$input = message
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pSelectService = {
|
||||||
|
selectPeer: function (options) {
|
||||||
|
$input = options
|
||||||
|
return {
|
||||||
|
then: function (f) {
|
||||||
|
f('Peerselected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createController = function (spyBroadcast, spyOn) {
|
||||||
|
if (spyBroadcast) {
|
||||||
|
$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 = {}
|
||||||
|
$messManager.deleteMessages = jasmine.createSpy('deleteMessages')
|
||||||
|
|
||||||
|
$modalI = {}
|
||||||
|
$modalI.dismiss = jasmine.createSpy('dismissModal')
|
||||||
|
|
||||||
|
inject(function (_$controller_, _$rootScope_) {
|
||||||
|
$rootScope = _$rootScope_
|
||||||
|
$scope = $rootScope.$new()
|
||||||
|
$scope.docID = 'randomvideo'
|
||||||
|
|
||||||
|
$controller = _$controller_
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// define tests
|
||||||
|
it('sets the video in the scope', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
|
||||||
|
expect($scope.progress).toEqual({enabled: false})
|
||||||
|
expect($scope.player).toEqual({})
|
||||||
|
expect($docManager.wrapVideoForFull).toHaveBeenCalledWith($scope.docID)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('forwards a message with a video', function (done) {
|
||||||
|
createController(true, false)
|
||||||
|
$scope.messageID = 'id68567'
|
||||||
|
|
||||||
|
$scope.forward()
|
||||||
|
expect($input).toEqual({canSend: true})
|
||||||
|
expect($scope.$broadcast).toHaveBeenCalledWith('history_focus', {
|
||||||
|
peerString: 'Peerselected',
|
||||||
|
attachment: {
|
||||||
|
_: 'fwd_messages',
|
||||||
|
id: [$scope.messageID]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('deletes a message with a video', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
$scope.messageID = 'id235235'
|
||||||
|
|
||||||
|
$scope.delete()
|
||||||
|
expect($input).toEqual({type: 'MESSAGE_DELETE'})
|
||||||
|
expect($messManager.deleteMessages).toHaveBeenCalledWith([$scope.messageID])
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('downloads the document (video)', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
|
||||||
|
$scope.download()
|
||||||
|
expect($docManager.saveDocFile).toHaveBeenCalledWith($scope.docID)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('delete a video linked to a message', function (done) {
|
||||||
|
createController(false, true)
|
||||||
|
$scope.messageID = 'id2352'
|
||||||
|
|
||||||
|
$rootScope.$broadcast('history_delete')
|
||||||
|
expect($scope.$on).toHaveBeenCalledWith('history_delete', jasmine.any(Function))
|
||||||
|
expect($modalI.dismiss).not.toHaveBeenCalled()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('delete a video linked to a modal instance', function (done) {
|
||||||
|
createController(false, false)
|
||||||
|
$scope.messageID = 'id6234'
|
||||||
|
|
||||||
|
var $msgs = {}
|
||||||
|
$msgs[$scope.messageID] = {message: 'some non-empty message'}
|
||||||
|
$rootScope.$broadcast('history_delete', {msgs: $msgs})
|
||||||
|
expect($modalI.dismiss).toHaveBeenCalled()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
@ -1,31 +1,33 @@
|
|||||||
describe('chatTitle filter', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $filter, _, chatTitleFilter;
|
|
||||||
|
|
||||||
beforeEach(module('myApp.filters'));
|
describe('chatTitle filter', function () {
|
||||||
|
var $filter, _, chatTitleFilter
|
||||||
|
|
||||||
|
beforeEach(module('myApp.filters'))
|
||||||
|
|
||||||
beforeEach(inject(function (_$filter_, ___) {
|
beforeEach(inject(function (_$filter_, ___) {
|
||||||
$filter = _$filter_;
|
$filter = _$filter_
|
||||||
_ = ___;
|
_ = ___
|
||||||
}));
|
}))
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
chatTitleFilter = $filter('chatTitle');
|
chatTitleFilter = $filter('chatTitle')
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays chat title deleted', function () {
|
it('displays chat title deleted', function () {
|
||||||
var expected = _('chat_title_deleted');
|
var expected = _('chat_title_deleted')
|
||||||
var actual = chatTitleFilter(null);
|
var actual = chatTitleFilter(null)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays the chat title', function () {
|
it('displays the chat title', function () {
|
||||||
var chat = {
|
var chat = {
|
||||||
title: 'Telegraph is hot!'
|
title: 'Telegraph is hot!'
|
||||||
};
|
}
|
||||||
var expected = chat.title;
|
var expected = chat.title
|
||||||
var actual = chatTitleFilter(chat);
|
var actual = chatTitleFilter(chat)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
describe('myHead directive', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $compile, $rootScope;
|
|
||||||
|
|
||||||
beforeEach(module('myApp.templates'));
|
describe('myHead directive', function () {
|
||||||
beforeEach(module('myApp.directives'));
|
var $compile, $rootScope
|
||||||
|
|
||||||
|
beforeEach(module('myApp.templates'))
|
||||||
|
beforeEach(module('myApp.directives'))
|
||||||
|
|
||||||
beforeEach(inject(function (_$compile_, _$rootScope_) {
|
beforeEach(inject(function (_$compile_, _$rootScope_) {
|
||||||
$compile = _$compile_;
|
$compile = _$compile_
|
||||||
$rootScope = _$rootScope_;
|
$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 = $compile('<div my-head></div>')($rootScope)
|
||||||
$rootScope.$digest(); // Fire watchers
|
$rootScope.$digest() // Fire watchers
|
||||||
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 = $compile('<my-head></my-head>')($rootScope)
|
||||||
$rootScope.$digest(); // Fire watchers
|
$rootScope.$digest() // Fire watchers
|
||||||
expect(compiledElement.html()).toContain('tg_page_head');
|
expect(compiledElement.html()).toContain('tg_page_head')
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
describe('myLangFooter directive', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $compile, $rootScope;
|
|
||||||
|
|
||||||
beforeEach(module('ui.bootstrap'));
|
describe('myLangFooter directive', function () {
|
||||||
beforeEach(module('myApp.templates'));
|
var $compile, $rootScope
|
||||||
|
|
||||||
|
beforeEach(module('ui.bootstrap'))
|
||||||
|
beforeEach(module('myApp.templates'))
|
||||||
// ErrorServiceProvider in myApp.services is needed by
|
// ErrorServiceProvider in myApp.services is needed by
|
||||||
// AppLangSelectController in myApp.controllers
|
// AppLangSelectController in myApp.controllers
|
||||||
beforeEach(module('myApp.services'));
|
beforeEach(module('myApp.services'))
|
||||||
beforeEach(module('myApp.controllers'));
|
beforeEach(module('myApp.controllers'))
|
||||||
beforeEach(module('myApp.directives'));
|
beforeEach(module('myApp.directives'))
|
||||||
|
|
||||||
beforeEach(inject(function (_$compile_, _$rootScope_) {
|
beforeEach(inject(function (_$compile_, _$rootScope_) {
|
||||||
$compile = _$compile_;
|
$compile = _$compile_
|
||||||
$rootScope = _$rootScope_;
|
$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 = $compile('<div my-lang-footer></div>')($rootScope)
|
||||||
$rootScope.$digest(); // Fire watchers
|
$rootScope.$digest() // Fire watchers
|
||||||
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 = $compile('<my-lang-footer></my-lang-footer>')($rootScope)
|
||||||
$rootScope.$digest(); // Fire watchers
|
$rootScope.$digest() // Fire watchers
|
||||||
expect(compiledElement.html()).toContain('footer_lang_link');
|
expect(compiledElement.html()).toContain('footer_lang_link')
|
||||||
expect(compiledElement.html()).toContain('AppLangSelectController');
|
expect(compiledElement.html()).toContain('AppLangSelectController')
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
@ -1,42 +1,43 @@
|
|||||||
describe('userFirstName filter', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $filter, _, userFirstNameFilter;
|
|
||||||
|
|
||||||
beforeEach(module('myApp.filters'));
|
describe('userFirstName filter', function () {
|
||||||
|
var $filter, _, userFirstNameFilter
|
||||||
|
|
||||||
|
beforeEach(module('myApp.filters'))
|
||||||
|
|
||||||
beforeEach(inject(function (_$filter_, ___) {
|
beforeEach(inject(function (_$filter_, ___) {
|
||||||
$filter = _$filter_;
|
$filter = _$filter_
|
||||||
_ = ___;
|
_ = ___
|
||||||
}));
|
}))
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
userFirstNameFilter = $filter('userFirstName');
|
userFirstNameFilter = $filter('userFirstName')
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays user first name deleted', function () {
|
it('displays user first name deleted', function () {
|
||||||
var expected = _('user_first_name_deleted');
|
var expected = _('user_first_name_deleted')
|
||||||
var actual = userFirstNameFilter(null);
|
var actual = userFirstNameFilter(null)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays the first name', function () {
|
it('displays the first name', function () {
|
||||||
var user = {
|
var user = {
|
||||||
first_name: 'John'
|
first_name: 'John'
|
||||||
};
|
}
|
||||||
var expected = user.first_name;
|
var expected = user.first_name
|
||||||
var actual = userFirstNameFilter(user);
|
var actual = userFirstNameFilter(user)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays the last name alternatively', function () {
|
it('displays the last name alternatively', function () {
|
||||||
var user = {
|
var user = {
|
||||||
last_name: 'Doe'
|
last_name: 'Doe'
|
||||||
};
|
}
|
||||||
var expected = user.last_name;
|
var expected = user.last_name
|
||||||
var actual = userFirstNameFilter(user);
|
var actual = userFirstNameFilter(user)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
})
|
||||||
});
|
|
||||||
|
@ -1,42 +1,44 @@
|
|||||||
describe('userName filter', function () {
|
/* global describe, it, inject, expect, beforeEach */
|
||||||
var $filter, _, userNameFilter;
|
|
||||||
|
|
||||||
beforeEach(module('myApp.filters'));
|
describe('userName filter', function () {
|
||||||
|
var $filter, _, userNameFilter
|
||||||
|
|
||||||
|
beforeEach(module('myApp.filters'))
|
||||||
|
|
||||||
beforeEach(inject(function (_$filter_, ___) {
|
beforeEach(inject(function (_$filter_, ___) {
|
||||||
$filter = _$filter_;
|
$filter = _$filter_
|
||||||
_ = ___;
|
_ = ___
|
||||||
}));
|
}))
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
userNameFilter = $filter('userName');
|
userNameFilter = $filter('userName')
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays user name deleted', function () {
|
it('displays user name deleted', function () {
|
||||||
var expected = _('user_name_deleted');
|
var expected = _('user_name_deleted')
|
||||||
var actual = userNameFilter(null);
|
var actual = userNameFilter(null)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays the first name', function () {
|
it('displays the first name', function () {
|
||||||
var user = {
|
var user = {
|
||||||
first_name: 'John'
|
first_name: 'John'
|
||||||
};
|
}
|
||||||
var expected = user.first_name;
|
var expected = user.first_name
|
||||||
var actual = userNameFilter(user);
|
var actual = userNameFilter(user)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
|
|
||||||
it('displays both, the first and the last name', function () {
|
it('displays both, the first and the last name', function () {
|
||||||
var user = {
|
var user = {
|
||||||
first_name: 'John',
|
first_name: 'John',
|
||||||
last_name: 'Doe'
|
last_name: 'Doe'
|
||||||
};
|
}
|
||||||
var expected = user.first_name + ' ' + user.last_name;
|
var expected = user.first_name + ' ' + user.last_name
|
||||||
var actual = userNameFilter(user);
|
var actual = userNameFilter(user)
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user