2 /* eslint-disable jest/valid-title */
4 var isValidRoomUri = require('./valid-room-uri');
5 var RESERVED = require('gitter-web-validators/lib/reserved-namespaces').list;
6 var RESERVED_SUB = require('gitter-web-validators/lib/reserved-sub-namespaces').list;
7 var assert = require('assert');
9 function test(name, expected) {
10 expected = typeof expected === 'undefined' ? true : expected;
11 var result = isValidRoomUri(name);
12 // keeping this as it is useful for seeing which one actually broke
13 //if (result !== expected) {
16 assert.equal(result, expected);
19 describe('valid-room-uri', function() {
20 it('rejects vanity keywords', function() {
21 RESERVED.forEach(function(keyword) {
22 test('/' + keyword, false);
24 RESERVED_SUB.forEach(function(keyword) {
25 test('/foo/' + keyword, false);
29 it("accepts rooms with vanity keywords, but aren't vanity keyworkds", function() {
32 test('/aboutandrew?test=true');
33 test('/apiguy?test=true');
34 test('/aboutandrew/roomname');
35 test('/aboutandrew/topicsname');
38 it('rejects undefined and empty string', function() {
41 test(undefined, false);
46 it('rejects archive links', function() {
47 test('/gitterHQ/gitter/archives/all', false);
48 test('/gitterHQ/gitter/archives/2014/12/11', false);
49 test('/gitterHQ/gitter/archives/all?test=true', false);
50 test('/gitterHQ/gitter/archives/2014/12/11?test=true', false);
53 it('accepts room URIs', function() {
55 test('/i-love-cats/Lobby');
56 test('/i-love-cats/community');
58 test('/gitterHQ/gitter');
59 test('/gitterHQ/gitter/channel');
60 test('/gitterHQ?test=true');
61 test('/gitterHQ/gitter?test=true');
62 test('/gitterHQ/gitter/channel?test=true');
66 * https://github.com/troupe/gitter-webapp/issues/683
68 it('should detect orgs with dashes in their names', function() {
69 test('/orgs/dev-ua/rooms', false);
73 * https://github.com/troupe/gitter-webapp/issues/683
75 it('should detect orgs community with underscores in their names', function() {
76 test('/orgs/dev_ua/rooms', false);
81 * https://github.com/troupe/gitter-webapp/issues/683
83 it('should anything under /orgs/', function() {
84 test('/orgs/blah/blah/blah', false);
90 it.skip('should ensure that org names do not have underscores in them', function() {
91 test('/gitter_hq', false);