Merge branch 'hotfix/21.56.9' into master
[gitter.git] / modules / chats / test / group-resolve-test.js
blob43746a81f4e791d084cb152d52731bd3c5423ea0
1 'use strict';
3 var proxyquireNoCallThru = require('proxyquire').noCallThru();
4 var fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
5 var assert = require('assert');
6 var Promise = require('bluebird');
8 describe('group-resolver', function() {
9   describe('#slow', function() {
10     var groupResolver;
11     var adminPermission;
13     var fixture = fixtureLoader.setup({
14       user1: {},
15       troupe1: { users: ['user1'] }
16     });
18     beforeEach(function() {
19       var createPolicyForRoom = function() {
20         return Promise.resolve({
21           canAdmin: function() {
22             return Promise.resolve(adminPermission);
23           }
24         });
25       };
27       groupResolver = proxyquireNoCallThru('../lib/group-resolver', {
28         'gitter-web-permissions/lib/policy-factory': {
29           createPolicyForRoom: createPolicyForRoom
30         }
31       });
32     });
34     it('should resolve @/all mentions for admins', function() {
35       var troupe = fixture.troupe1;
36       var user1 = fixture.user1;
37       adminPermission = true;
39       return groupResolver(troupe, user1, ['all']).then(function(result) {
40         assert.strictEqual(result.all.announcement, true);
41       });
42     });
44     it('should resolve not resolve mentions for non-admins', function() {
45       var troupe = fixture.troupe1;
46       var user1 = fixture.user1;
47       adminPermission = false;
49       return groupResolver(troupe, user1, ['all']).then(function(result) {
50         assert(!result.all);
51       });
52     });
53   });
54 });