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-api', function() {
12 fixtureLoader.ensureIntegrationEnvironment('#oauthTokens');
15 if (this._skipFixtureSetup) return;
17 request = require('supertest');
18 app = require('../../server/api');
21 var fixture = fixtureLoader.setupEach({
23 accessToken: 'web-internal'
30 users: ['user1', 'user2']
39 it('GET /v1/user/:userId/suggestedRooms', function() {
41 .get('/v1/user/me/suggestedRooms')
42 .set('x-access-token', fixture.user1.accessToken)
44 .then(function(result) {
45 // For now, this is a very loose test, to prove
46 // https://github.com/troupe/gitter-webapp/pull/2067
47 // We can extend it later
48 var suggestions = result.body;
49 assert(Array.isArray(suggestions));
50 assert(suggestions.length > 0);
51 suggestions.forEach(function(suggestion) {
52 assert(suggestion.hasOwnProperty('uri'));
53 assert(suggestion.hasOwnProperty('avatarUrl'));
54 assert(suggestion.hasOwnProperty('userCount'));
55 assert(suggestion.hasOwnProperty('tags'));
56 assert(suggestion.hasOwnProperty('description'));
57 assert(suggestion.hasOwnProperty('exists'));
59 (suggestion.exists === true && suggestion.id) ||
60 (suggestion.exists === false && !suggestion.id)
66 describe('DELETE /v1/user/:userId', () => {
67 it('should be successful', function() {
69 .delete('/v1/user/me')
70 .set('x-access-token', fixture.user1.accessToken)
72 .then(function(result) {
73 assert.strictEqual(result.status, 200);
74 assert.deepEqual(result.body, {
80 it('should be successful with ghost option', function() {
82 .delete('/v1/user/me')
86 .set('x-access-token', fixture.user1.accessToken)
88 .then(function(result) {
89 assert.strictEqual(result.status, 200);
90 assert.deepEqual(result.body, {
96 it('should clear access tokens', async function() {
99 .delete('/v1/user/me')
100 .set('x-access-token', fixture.user1.accessToken)
103 // Access token should no longer work
106 .set('x-access-token', fixture.user1.accessToken)