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({
13 troupe2: {}, // used in test 3, for missing lookup
14 user2: { username: true }, // used in test 3, for missing lookup
15 user3: { username: true }
18 fixtureLoader.disableMongoTableScans();
20 it('should lookup usernames', function() {
21 var uri = fixture.user2.username;
23 return uriLookupService
25 .then(function(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) {
36 assert(!uriLookup.troupeId);
37 assert(!uriLookup.groupId);
39 assert.equal(uriLookup.userId, fixture.user2.id);
43 it('should lookup rooms', function() {
44 var uri = fixture.troupe1.uri;
46 return uriLookupService
48 .then(function(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) {
58 assert(!uriLookup.userId);
59 assert(!uriLookup.groupId);
60 assert.equal(uriLookup.troupeId, fixture.troupe1.id);
64 it('should lookup groups', function() {
65 var uri = fixture.group1.homeUri;
67 return uriLookupService
69 .then(function(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) {
79 assert(!uriLookup.userId);
80 assert(!uriLookup.troupeId);
82 assert.equal(uriLookup.groupId, fixture.group1.id);
86 it('should not fail looking up rooms', function() {
87 return uriLookupService.lookupUri('gitterHQ/cloaked-avenger');