3 process.env.DISABLE_MATRIX_BRIDGE = '1';
4 process.env.DISABLE_API_LISTEN = '1';
6 var fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
7 var assert = require('assert');
9 describe('user-rooms-api', function() {
13 request = require('supertest');
14 app = require('../../server/api');
17 var fixture = fixtureLoader.setup({
18 user1: { accessToken: 'web-internal' },
19 user2: { accessToken: 'web-internal' },
30 it('GET /v1/user/:userId/rooms', function() {
32 .get(`/v1/user/${fixture.user1.id}/rooms`)
33 .set('x-access-token', fixture.user1.accessToken)
35 .then(function(result) {
36 var rooms = result.body;
39 rooms.some(function(r) {
40 return r.id === fixture.troupe1.id;
45 rooms.some(function(r) {
46 return r.id === fixture.troupe2.id;
50 assert.strictEqual(rooms.length, 2);
54 it('GET /v1/user/:userId/rooms/:roomId/unreadItems', function() {
56 .get(`/v1/user/${fixture.user1.id}/rooms/${fixture.troupe1.id}/unreadItems`)
57 .set('x-access-token', fixture.user1.accessToken)
59 .then(function(result) {
60 var { chat, mention } = result.body;
62 assert.strictEqual(chat.length, 0);
63 assert.strictEqual(mention.length, 0);
67 it('PATCH /v1/user/:userId/rooms/:roomId', () => {
69 .put(`/v1/user/${fixture.user1.id}/rooms/${fixture.troupe2.id}`)
70 .set('x-access-token', fixture.user1.accessToken)
71 .send({ favourite: 1 })
75 it('PATCH /v1/user/:userId/rooms/:roomId is forbidden for unauthorized user', () => {
77 .patch(`/v1/user/${fixture.user2.id}/rooms/${fixture.troupe2.id}`)
78 .set('x-access-token', fixture.user2.accessToken)