Skip to content

Commit ee575ad

Browse files
committed
1 parent a90338b commit ee575ad

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

src/linagora.esn.contact/app/sidebar/sidebar.controller.spec.js

+37-5
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ describe('The ContactSidebarController controller', function() {
4646
userAPI = _userAPI_;
4747
userUtils = _userUtils_;
4848
CONTACT_ADDRESSBOOK_EVENTS = _CONTACT_ADDRESSBOOK_EVENTS_;
49-
50-
contactAddressbookDisplayService.categorizeDisplayShells = function() {
51-
return {
49+
contactAddressbookDisplayService.categorizeDisplayShells = sinon.stub()
50+
.returns({
5251
userAddressbooks: [],
5352
externalAddressbooks: []
54-
};
55-
};
53+
});
5654
});
5755
});
5856

@@ -260,6 +258,40 @@ describe('The ContactSidebarController controller', function() {
260258
]);
261259
});
262260

261+
it('should avoid listing duplicate entries when an adressbook is shared an delegated to the same user', () => {
262+
contactAddressbookService.listAddressbooks = sinon.stub().returns($q.when([]));
263+
contactAddressbookDisplayService.categorizeDisplayShells.returns({
264+
userAddressbooks: [
265+
{
266+
name: 'bookA',
267+
shell: {
268+
source: { bookId: 'user0', href: '0' }
269+
}
270+
}
271+
],
272+
sharedAddressbooks: [
273+
{
274+
name: 'bookB',
275+
shell: {
276+
source: { bookId: 'user1', href: '1' }
277+
}
278+
},
279+
{
280+
name: 'bookC',
281+
shell: {
282+
source: { bookId: 'user1', href: '1' }
283+
}
284+
}
285+
]
286+
});
287+
288+
const controller = initController();
289+
290+
$rootScope.$digest();
291+
292+
expect(controller.sharedAddressbooks.length).to.equal(1);
293+
});
294+
263295
describe('On updated address book event', function() {
264296
it('should update an address book when updated address book event is fired', function() {
265297
var addressbooks = [

0 commit comments

Comments
 (0)