Browse Source
* 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 VideoModalControllermaster
Bart
8 years ago
committed by
Igor Zhukov
12 changed files with 594 additions and 201 deletions
@ -0,0 +1,21 @@
@@ -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() |
||||
}) |
||||
}) |
@ -0,0 +1,132 @@
@@ -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() |
||||
}) |
||||
}) |
@ -0,0 +1,91 @@
@@ -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 @@
@@ -1,56 +1,58 @@
|
||||
/* global describe, it, inject, expect, beforeEach, jasmine, xit */ |
||||
|
||||
describe('PhonebookContactsService', function () { |
||||
var PhonebookContactsService; |
||||
var PhonebookContactsService, $modal |
||||
|
||||
beforeEach(module('ui.bootstrap')); |
||||
beforeEach(module('myApp.services')); |
||||
beforeEach(module('ui.bootstrap')) |
||||
beforeEach(module('myApp.services')) |
||||
|
||||
beforeEach(inject(function (_PhonebookContactsService_) { |
||||
PhonebookContactsService = _PhonebookContactsService_; |
||||
})); |
||||
PhonebookContactsService = _PhonebookContactsService_ |
||||
})) |
||||
|
||||
describe('Public API:', function () { |
||||
it('checks availability', function () { |
||||
expect(PhonebookContactsService.isAvailable).toBeDefined(); |
||||
}); |
||||
expect(PhonebookContactsService.isAvailable).toBeDefined() |
||||
}) |
||||
|
||||
it('open the phonebook for import', function () { |
||||
expect(PhonebookContactsService.openPhonebookImport).toBeDefined(); |
||||
}); |
||||
expect(PhonebookContactsService.openPhonebookImport).toBeDefined() |
||||
}) |
||||
|
||||
it('get phonebook contacts', function () { |
||||
expect(PhonebookContactsService.getPhonebookContacts).toBeDefined(); |
||||
}); |
||||
expect(PhonebookContactsService.getPhonebookContacts).toBeDefined() |
||||
}) |
||||
|
||||
describe('usage', function () { |
||||
describe('of isAvailable()', function () { |
||||
it('returns false in most cases', function (done) { |
||||
expect(PhonebookContactsService.isAvailable()).toBe(false); |
||||
done(); |
||||
}); |
||||
}); |
||||
expect(PhonebookContactsService.isAvailable()).toBe(false) |
||||
done() |
||||
}) |
||||
}) |
||||
|
||||
describe('of openPhonebookImport()', function () { |
||||
beforeEach(function () { |
||||
$modal = { |
||||
open: jasmine.createSpy('open') |
||||
}; |
||||
}); |
||||
} |
||||
}) |
||||
|
||||
xit('opens a modal', function () { |
||||
PhonebookContactsService.openPhonebookImport(); |
||||
expect($modal.open).toHaveBeenCalled(); |
||||
}); |
||||
}); |
||||
PhonebookContactsService.openPhonebookImport() |
||||
expect($modal.open).toHaveBeenCalled() |
||||
}) |
||||
}) |
||||
|
||||
describe('of getPhonebookContacts()', function () { |
||||
xit('will get rejected in most cases', function (done) { |
||||
promise = PhonebookContactsService.getPhonebookContacts(); |
||||
var promise = PhonebookContactsService.getPhonebookContacts() |
||||
promise.finally(function () { |
||||
expect(promise.isFullfilled()).toBe(true); |
||||
done(); |
||||
}); |
||||
}); |
||||
}); |
||||
}); |
||||
}); |
||||
}); |
||||
expect(promise.isFullfilled()).toBe(true) |
||||
done() |
||||
}) |
||||
}) |
||||
}) |
||||
}) |
||||
}) |
||||
}) |
||||
|
@ -0,0 +1,134 @@
@@ -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 @@
@@ -1,31 +1,33 @@
|
||||
/* global describe, it, inject, expect, beforeEach */ |
||||
|
||||
describe('chatTitle filter', function () { |
||||
var $filter, _, chatTitleFilter; |
||||
var $filter, _, chatTitleFilter |
||||
|
||||
beforeEach(module('myApp.filters')); |
||||
beforeEach(module('myApp.filters')) |
||||
|
||||
beforeEach(inject(function (_$filter_, ___) { |
||||
$filter = _$filter_; |
||||
_ = ___; |
||||
})); |
||||
$filter = _$filter_ |
||||
_ = ___ |
||||
})) |
||||
|
||||
beforeEach(function () { |
||||
chatTitleFilter = $filter('chatTitle'); |
||||
}); |
||||
chatTitleFilter = $filter('chatTitle') |
||||
}) |
||||
|
||||
it('displays chat title deleted', function () { |
||||
var expected = _('chat_title_deleted'); |
||||
var actual = chatTitleFilter(null); |
||||
var expected = _('chat_title_deleted') |
||||
var actual = chatTitleFilter(null) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
|
||||
it('displays the chat title', function () { |
||||
var chat = { |
||||
title: 'Telegraph is hot!' |
||||
}; |
||||
var expected = chat.title; |
||||
var actual = chatTitleFilter(chat); |
||||
} |
||||
var expected = chat.title |
||||
var actual = chatTitleFilter(chat) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
}) |
||||
|
@ -1,23 +1,25 @@
@@ -1,23 +1,25 @@
|
||||
/* global describe, it, inject, expect, beforeEach */ |
||||
|
||||
describe('myHead directive', function () { |
||||
var $compile, $rootScope; |
||||
var $compile, $rootScope |
||||
|
||||
beforeEach(module('myApp.templates')); |
||||
beforeEach(module('myApp.directives')); |
||||
beforeEach(module('myApp.templates')) |
||||
beforeEach(module('myApp.directives')) |
||||
|
||||
beforeEach(inject(function (_$compile_, _$rootScope_) { |
||||
$compile = _$compile_; |
||||
$rootScope = _$rootScope_; |
||||
})); |
||||
$compile = _$compile_ |
||||
$rootScope = _$rootScope_ |
||||
})) |
||||
|
||||
it('compiles a my-head attribute', function () { |
||||
var compiledElement = $compile('<div my-head></div>')($rootScope); |
||||
$rootScope.$digest(); // Fire watchers
|
||||
expect(compiledElement.html()).toContain('tg_page_head'); |
||||
}); |
||||
var compiledElement = $compile('<div my-head></div>')($rootScope) |
||||
$rootScope.$digest() // Fire watchers
|
||||
expect(compiledElement.html()).toContain('tg_page_head') |
||||
}) |
||||
|
||||
it('compiles a my-head element', function () { |
||||
var compiledElement = $compile('<my-head></my-head>')($rootScope); |
||||
$rootScope.$digest(); // Fire watchers
|
||||
expect(compiledElement.html()).toContain('tg_page_head'); |
||||
}); |
||||
}); |
||||
var compiledElement = $compile('<my-head></my-head>')($rootScope) |
||||
$rootScope.$digest() // Fire watchers
|
||||
expect(compiledElement.html()).toContain('tg_page_head') |
||||
}) |
||||
}) |
||||
|
@ -1,30 +1,32 @@
@@ -1,30 +1,32 @@
|
||||
/* global describe, it, inject, expect, beforeEach */ |
||||
|
||||
describe('myLangFooter directive', function () { |
||||
var $compile, $rootScope; |
||||
var $compile, $rootScope |
||||
|
||||
beforeEach(module('ui.bootstrap')); |
||||
beforeEach(module('myApp.templates')); |
||||
beforeEach(module('ui.bootstrap')) |
||||
beforeEach(module('myApp.templates')) |
||||
// ErrorServiceProvider in myApp.services is needed by
|
||||
// AppLangSelectController in myApp.controllers
|
||||
beforeEach(module('myApp.services')); |
||||
beforeEach(module('myApp.controllers')); |
||||
beforeEach(module('myApp.directives')); |
||||
beforeEach(module('myApp.services')) |
||||
beforeEach(module('myApp.controllers')) |
||||
beforeEach(module('myApp.directives')) |
||||
|
||||
beforeEach(inject(function (_$compile_, _$rootScope_) { |
||||
$compile = _$compile_; |
||||
$rootScope = _$rootScope_; |
||||
})); |
||||
$compile = _$compile_ |
||||
$rootScope = _$rootScope_ |
||||
})) |
||||
|
||||
it('compiles a my-lang-footer attribute', function () { |
||||
var compiledElement = $compile('<div my-lang-footer></div>')($rootScope); |
||||
$rootScope.$digest(); // Fire watchers
|
||||
expect(compiledElement.html()).toContain('footer_lang_link'); |
||||
expect(compiledElement.html()).toContain('AppLangSelectController'); |
||||
}); |
||||
var compiledElement = $compile('<div my-lang-footer></div>')($rootScope) |
||||
$rootScope.$digest() // Fire watchers
|
||||
expect(compiledElement.html()).toContain('footer_lang_link') |
||||
expect(compiledElement.html()).toContain('AppLangSelectController') |
||||
}) |
||||
|
||||
it('compiles a my-lang-footer element', function () { |
||||
var compiledElement = $compile('<my-lang-footer></my-lang-footer>')($rootScope); |
||||
$rootScope.$digest(); // Fire watchers
|
||||
expect(compiledElement.html()).toContain('footer_lang_link'); |
||||
expect(compiledElement.html()).toContain('AppLangSelectController'); |
||||
}); |
||||
}); |
||||
var compiledElement = $compile('<my-lang-footer></my-lang-footer>')($rootScope) |
||||
$rootScope.$digest() // Fire watchers
|
||||
expect(compiledElement.html()).toContain('footer_lang_link') |
||||
expect(compiledElement.html()).toContain('AppLangSelectController') |
||||
}) |
||||
}) |
||||
|
@ -1,42 +1,43 @@
@@ -1,42 +1,43 @@
|
||||
/* global describe, it, inject, expect, beforeEach */ |
||||
|
||||
describe('userFirstName filter', function () { |
||||
var $filter, _, userFirstNameFilter; |
||||
var $filter, _, userFirstNameFilter |
||||
|
||||
beforeEach(module('myApp.filters')); |
||||
beforeEach(module('myApp.filters')) |
||||
|
||||
beforeEach(inject(function (_$filter_, ___) { |
||||
$filter = _$filter_; |
||||
_ = ___; |
||||
})); |
||||
$filter = _$filter_ |
||||
_ = ___ |
||||
})) |
||||
|
||||
beforeEach(function () { |
||||
userFirstNameFilter = $filter('userFirstName'); |
||||
}); |
||||
userFirstNameFilter = $filter('userFirstName') |
||||
}) |
||||
|
||||
it('displays user first name deleted', function () { |
||||
var expected = _('user_first_name_deleted'); |
||||
var actual = userFirstNameFilter(null); |
||||
var expected = _('user_first_name_deleted') |
||||
var actual = userFirstNameFilter(null) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
|
||||
it('displays the first name', function () { |
||||
var user = { |
||||
first_name: 'John' |
||||
}; |
||||
var expected = user.first_name; |
||||
var actual = userFirstNameFilter(user); |
||||
} |
||||
var expected = user.first_name |
||||
var actual = userFirstNameFilter(user) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
|
||||
it('displays the last name alternatively', function () { |
||||
var user = { |
||||
last_name: 'Doe' |
||||
}; |
||||
var expected = user.last_name; |
||||
var actual = userFirstNameFilter(user); |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
} |
||||
var expected = user.last_name |
||||
var actual = userFirstNameFilter(user) |
||||
|
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
}) |
||||
|
@ -1,42 +1,44 @@
@@ -1,42 +1,44 @@
|
||||
/* global describe, it, inject, expect, beforeEach */ |
||||
|
||||
describe('userName filter', function () { |
||||
var $filter, _, userNameFilter; |
||||
var $filter, _, userNameFilter |
||||
|
||||
beforeEach(module('myApp.filters')); |
||||
beforeEach(module('myApp.filters')) |
||||
|
||||
beforeEach(inject(function (_$filter_, ___) { |
||||
$filter = _$filter_; |
||||
_ = ___; |
||||
})); |
||||
$filter = _$filter_ |
||||
_ = ___ |
||||
})) |
||||
|
||||
beforeEach(function () { |
||||
userNameFilter = $filter('userName'); |
||||
}); |
||||
userNameFilter = $filter('userName') |
||||
}) |
||||
|
||||
it('displays user name deleted', function () { |
||||
var expected = _('user_name_deleted'); |
||||
var actual = userNameFilter(null); |
||||
var expected = _('user_name_deleted') |
||||
var actual = userNameFilter(null) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
|
||||
it('displays the first name', function () { |
||||
var user = { |
||||
first_name: 'John' |
||||
}; |
||||
var expected = user.first_name; |
||||
var actual = userNameFilter(user); |
||||
} |
||||
var expected = user.first_name |
||||
var actual = userNameFilter(user) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
|
||||
it('displays both, the first and the last name', function () { |
||||
var user = { |
||||
first_name: 'John', |
||||
last_name: 'Doe' |
||||
}; |
||||
var expected = user.first_name + ' ' + user.last_name; |
||||
var actual = userNameFilter(user); |
||||
} |
||||
var expected = user.first_name + ' ' + user.last_name |
||||
var actual = userNameFilter(user) |
||||
|
||||
expect(actual).toEqual(expected); |
||||
}); |
||||
}); |
||||
expect(actual).toEqual(expected) |
||||
}) |
||||
}) |
||||
|
Loading…
Reference in new issue