Merge branch 'hotfix/21.56.9' into master
[gitter.git] / modules / uri-resolver / test / uri-lookup-service-test.js
blob4679daefeb92c8bae9cb4716efaa2d81a4e315cd
1 'use strict';
3 var assert = require('assert');
5 var uriLookupService = require('../lib/uri-lookup-service');
6 var fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
8 describe('uri-lookup-service', function() {
9 var fixture = fixtureLoader.setup({
10 user1: {},
11 troupe1: {},
12 group1: {},
13 troupe2: {}, // used in test 3, for missing lookup
14 user2: { username: true }, // used in test 3, for missing lookup
15 user3: { username: true }
16 });
18 fixtureLoader.disableMongoTableScans();
20 it('should lookup usernames', function() {
21 var uri = fixture.user2.username;
23 return uriLookupService
24 .lookupUri(uri)
25 .then(function(uriLookup) {
26 assert(uriLookup);
27 assert(!uriLookup.troupeId);
28 assert(!uriLookup.groupId);
30 assert.equal(uriLookup.userId, fixture.user2.id);
32 return uriLookupService.lookupUri(uri);
34 .then(function(uriLookup) {
35 assert(uriLookup);
36 assert(!uriLookup.troupeId);
37 assert(!uriLookup.groupId);
39 assert.equal(uriLookup.userId, fixture.user2.id);
40 });
41 });
43 it('should lookup rooms', function() {
44 var uri = fixture.troupe1.uri;
46 return uriLookupService
47 .lookupUri(uri)
48 .then(function(uriLookup) {
49 assert(uriLookup);
50 assert(!uriLookup.userId);
51 assert(!uriLookup.groupId);
52 assert.equal(uriLookup.troupeId, fixture.troupe1.id);
54 return uriLookupService.lookupUri(uri);
56 .then(function(uriLookup) {
57 assert(uriLookup);
58 assert(!uriLookup.userId);
59 assert(!uriLookup.groupId);
60 assert.equal(uriLookup.troupeId, fixture.troupe1.id);
61 });
62 });
64 it('should lookup groups', function() {
65 var uri = fixture.group1.homeUri;
67 return uriLookupService
68 .lookupUri(uri)
69 .then(function(uriLookup) {
70 assert(uriLookup);
71 assert(!uriLookup.userId);
72 assert(!uriLookup.troupeId);
73 assert.equal(uriLookup.groupId, fixture.group1.id);
75 return uriLookupService.lookupUri(uri);
77 .then(function(uriLookup) {
78 assert(uriLookup);
79 assert(!uriLookup.userId);
80 assert(!uriLookup.troupeId);
82 assert.equal(uriLookup.groupId, fixture.group1.id);
83 });
84 });
86 it('should not fail looking up rooms', function() {
87 return uriLookupService.lookupUri('gitterHQ/cloaked-avenger');
88 });
89 });