mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-5755: Infrastructure for Component Testing. (#5814)
This migrates the existing webapp tests to using Jest and Enzyme. The infrastructure is put in place for React component testing, and a few simple example component tests are implemented. This also adds snapshot testing of components, coverage checking for the webapp (although that is not yet integrated to Coveralls), and the ability to run npm run test:watch to automatically re-run affected tests when working on the webapp codebase.
This commit is contained in:
committed by
Christopher Speller
parent
c6ded1dbfd
commit
7d449e0556
@@ -8,5 +8,8 @@
|
||||
"no-unreachable": 0,
|
||||
"new-cap": 0,
|
||||
"max-nested-callbacks": 0
|
||||
},
|
||||
"env": {
|
||||
"jest": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +1,56 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var assert = require('assert');
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Admin', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('Admin.reloadConfig', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.reloadConfig', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().reloadConfig(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.recycleDatabaseConnection', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.recycleDatabaseConnection', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().recycleDatabaseConnection(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getComplianceReports', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getComplianceReports', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getComplianceReports(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.saveComplianceReports', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.saveComplianceReports', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var job = {};
|
||||
@@ -66,97 +63,97 @@ describe('Client.Admin', function() {
|
||||
TestHelper.basicClient().saveComplianceReports(
|
||||
job,
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getLogs', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getLogs', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getLogs(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getServerAudits', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getServerAudits', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getServerAudits(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getConfig', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getConfig', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getConfig(
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getAnalytics', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getAnalytics', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getAnalytics(
|
||||
'standard',
|
||||
null,
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.getTeamAnalytics', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.getTeamAnalytics', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().getTeamAnalytics(
|
||||
TestHelper.basicTeam().id,
|
||||
'standard',
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.saveConfig', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.saveConfig', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var config = {};
|
||||
config.site_name = 'test';
|
||||
@@ -164,18 +161,18 @@ describe('Client.Admin', function() {
|
||||
TestHelper.basicClient().saveConfig(
|
||||
config,
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.testEmail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.testEmail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var config = {};
|
||||
config.site_name = 'test';
|
||||
@@ -183,35 +180,35 @@ describe('Client.Admin', function() {
|
||||
TestHelper.basicClient().testEmail(
|
||||
config,
|
||||
function() {
|
||||
done(new Error('should need system admin permissions'));
|
||||
done.fail(new Error('should need system admin permissions'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.adminResetMfa', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.adminResetMfa', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
TestHelper.basicClient().adminResetMfa(
|
||||
TestHelper.basicUser().id,
|
||||
function() {
|
||||
done(new Error('should need a license'));
|
||||
done.fail(new Error('should need a license'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.adminResetPassword', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.adminResetPassword', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
@@ -223,44 +220,44 @@ describe('Client.Admin', function() {
|
||||
},
|
||||
function(err) {
|
||||
// this should fail since you're not a system admin
|
||||
assert.equal(err.id, 'api.context.invalid_param.app_error');
|
||||
expect(err.id).toBe('api.context.invalid_param.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('License.getClientLicenceConfig', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('License.getClientLicenceConfig', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getClientLicenceConfig(
|
||||
function(data) {
|
||||
assert.equal(data.IsLicensed, 'false');
|
||||
expect(data.IsLicensed).toBe('false');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('License.removeLicenseFile', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('License.removeLicenseFile', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().removeLicenseFile(
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Admin.ldapSyncNow', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('Admin.ldapSyncNow', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
TestHelper.basicClient().ldapSyncNow(
|
||||
@@ -275,20 +272,20 @@ describe('Client.Admin', function() {
|
||||
});
|
||||
});
|
||||
|
||||
/*it('License.uploadLicenseFile', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test.skip('License.uploadLicenseFile', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().uploadLicenseFile(
|
||||
'form data',
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.permissions.app_error');
|
||||
expect(err.id).toBe('api.context.permissions.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});*/
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,55 +1,52 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Channels', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('createChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('createChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.fakeChannel();
|
||||
channel.team_id = TestHelper.basicTeam().id;
|
||||
TestHelper.basicClient().createChannel(
|
||||
channel,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.name, channel.name);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.name).toBe(channel.name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('createDirectChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('createDirectChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().createUser(
|
||||
TestHelper.fakeUser(),
|
||||
function(user2) {
|
||||
TestHelper.basicClient().createDirectChannel(
|
||||
user2.id,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('createGroupChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('createGroupChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().createUser(
|
||||
TestHelper.fakeUser(),
|
||||
(user1) => {
|
||||
@@ -59,84 +56,84 @@ describe('Client.Channels', function() {
|
||||
TestHelper.basicClient().createGroupChannel(
|
||||
[user2.id, user1.id],
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
channel.display_name = 'changed';
|
||||
TestHelper.basicClient().updateChannel(
|
||||
channel,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.display_name, 'changed');
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.display_name).toEqual('changed');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateChannelHeader', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateChannelHeader', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
channel.display_name = 'changed';
|
||||
TestHelper.basicClient().updateChannelHeader(
|
||||
channel.id,
|
||||
'new header',
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.header, 'new header');
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.header).toBe('new header');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateChannelPurpose', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateChannelPurpose', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
channel.display_name = 'changed';
|
||||
TestHelper.basicClient().updateChannelPurpose(
|
||||
channel.id,
|
||||
'new purpose',
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.purpose, 'new purpose');
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.purpose).toEqual('new purpose');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateChannelNotifyProps', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateChannelNotifyProps', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var props = {};
|
||||
props.channel_id = TestHelper.basicChannel().id;
|
||||
props.user_id = TestHelper.basicUser().id;
|
||||
@@ -144,34 +141,34 @@ describe('Client.Channels', function() {
|
||||
TestHelper.basicClient().updateChannelNotifyProps(
|
||||
props,
|
||||
function(data) {
|
||||
assert.equal(data.desktop, 'all');
|
||||
expect(data.desktop).toEqual('all');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('leaveChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('leaveChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().leaveChannel(
|
||||
channel.id,
|
||||
function(data) {
|
||||
assert.equal(data.id, channel.id);
|
||||
expect(data.id).toEqual(channel.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('joinChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('joinChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().leaveChannel(
|
||||
channel.id,
|
||||
@@ -182,19 +179,19 @@ describe('Client.Channels', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('joinChannelByName', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('joinChannelByName', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().leaveChannel(
|
||||
channel.id,
|
||||
@@ -205,35 +202,35 @@ describe('Client.Channels', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().deleteChannel(
|
||||
channel.id,
|
||||
function(data) {
|
||||
assert.equal(data.id, channel.id);
|
||||
expect(data.id).toEqual(channel.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('viewChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('viewChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().viewChannel(
|
||||
channel.id,
|
||||
@@ -243,195 +240,195 @@ describe('Client.Channels', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateLastViewedAt', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateLastViewedAt', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var channel = TestHelper.basicChannel();
|
||||
TestHelper.basicClient().updateLastViewedAt(
|
||||
channel.id,
|
||||
true,
|
||||
function(data) {
|
||||
assert.equal(data.id, channel.id);
|
||||
expect(data.id).toEqual(channel.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannels', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannels', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannels(
|
||||
function(data) {
|
||||
assert.equal(data.length, 3);
|
||||
expect(data.length).toBe(3);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannel(
|
||||
TestHelper.basicChannel().id,
|
||||
function(data) {
|
||||
assert.equal(TestHelper.basicChannel().id, data.channel.id);
|
||||
expect(TestHelper.basicChannel().id).toEqual(data.channel.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMoreChannels', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMoreChannels', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMoreChannels(
|
||||
function(data) {
|
||||
assert.equal(data.length, 0);
|
||||
expect(data.length).toBe(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMoreChannelsPage', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMoreChannelsPage', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMoreChannelsPage(
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(data.length, 0);
|
||||
expect(data.length).toBe(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('searchMoreChannels', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('searchMoreChannels', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().searchMoreChannels(
|
||||
'blargh',
|
||||
function(data) {
|
||||
assert.equal(data.length, 0);
|
||||
expect(data.length).toBe(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('autocompleteChannels', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('autocompleteChannels', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().autocompleteChannels(
|
||||
TestHelper.basicChannel().name,
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
expect(data).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannelCounts', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannelCounts', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannelCounts(
|
||||
function(data) {
|
||||
assert.equal(data.counts[TestHelper.basicChannel().id], 1);
|
||||
expect(data.counts[TestHelper.basicChannel().id]).toBe(1);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMyChannelMembers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMyChannelMembers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMyChannelMembers(
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMyChannelMembersForTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMyChannelMembersForTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMyChannelMembersForTeam(
|
||||
TestHelper.basicTeam().id,
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannelStats', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannelStats', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannelStats(
|
||||
TestHelper.basicChannel().id,
|
||||
function(data) {
|
||||
assert.equal(data.member_count, 1);
|
||||
expect(data.member_count).toBe(1);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannelMember', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannelMember', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannelMember(
|
||||
TestHelper.basicChannel().id,
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data.channel_id, TestHelper.basicChannel().id);
|
||||
assert.equal(data.user_id, TestHelper.basicUser().id);
|
||||
expect(data.channel_id).toEqual(TestHelper.basicChannel().id);
|
||||
expect(data.user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('addChannelMember', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addChannelMember', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().createUserWithInvite(
|
||||
TestHelper.fakeUser(),
|
||||
null,
|
||||
@@ -442,47 +439,47 @@ describe('Client.Channels', function() {
|
||||
TestHelper.basicChannel().id,
|
||||
user2.id,
|
||||
function(data) {
|
||||
assert.equal(data.channel_id.length > 0, true);
|
||||
expect(data.channel_id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('removeChannelMember', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('removeChannelMember', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().removeChannelMember(
|
||||
TestHelper.basicChannel().id,
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data.channel_id.length > 0, true);
|
||||
expect(data.channel_id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getChannelByName', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getChannelByName', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getChannelByName(
|
||||
TestHelper.basicChannel().name,
|
||||
function(data) {
|
||||
assert.equal(data.name, TestHelper.basicChannel().name);
|
||||
expect(data.name).toEqual(TestHelper.basicChannel().name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,61 +1,58 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Commands', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('listCommands', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('listCommands', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().listCommands(
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('listTeamCommands', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('listTeamCommands', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().listTeamCommands(
|
||||
function() {
|
||||
done(new Error('cmds not enabled'));
|
||||
done.fail(new Error('cmds not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.command.disabled.app_error');
|
||||
expect(err.id).toEqual('api.command.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('executeCommand', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('executeCommand', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const args = {};
|
||||
args.channel_id = TestHelper.basicChannel().id;
|
||||
TestHelper.basicClient().executeCommand(
|
||||
'/shrug',
|
||||
args,
|
||||
function(data) {
|
||||
assert.equal(data.response_type, 'in_channel');
|
||||
expect(data.response_type).toEqual('in_channel');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('addCommand', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addCommand', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var cmd = {};
|
||||
@@ -72,18 +69,18 @@ describe('Client.Commands', function() {
|
||||
TestHelper.basicClient().addCommand(
|
||||
cmd,
|
||||
function() {
|
||||
done(new Error('cmds not enabled'));
|
||||
done.fail(new Error('cmds not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.command.disabled.app_error');
|
||||
expect(err.id).toEqual('api.command.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('editCommand', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('editCommand', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var cmd = {};
|
||||
@@ -100,42 +97,42 @@ describe('Client.Commands', function() {
|
||||
TestHelper.basicClient().editCommand(
|
||||
cmd,
|
||||
function() {
|
||||
done(new Error('cmds not enabled'));
|
||||
done.fail(new Error('cmds not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.command.disabled.app_error');
|
||||
expect(err.id).toEqual('api.command.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteCommand', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteCommand', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().deleteCommand(
|
||||
TestHelper.generateId(),
|
||||
function() {
|
||||
done(new Error('cmds not enabled'));
|
||||
done.fail(new Error('cmds not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.command.disabled.app_error');
|
||||
expect(err.id).toEqual('api.command.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('regenCommandToken', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('regenCommandToken', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().regenCommandToken(
|
||||
TestHelper.generateId(),
|
||||
function() {
|
||||
done(new Error('cmds not enabled'));
|
||||
done.fail(new Error('cmds not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.command.disabled.app_error');
|
||||
expect(err.id).toEqual('api.command.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
@@ -1,50 +1,47 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
describe('Client.Emoji', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
const testGifFileName = 'testEmoji.gif';
|
||||
|
||||
before(function() {
|
||||
beforeAll(function() {
|
||||
// write a temporary file so that we have something to upload for testing
|
||||
const buffer = new Buffer('R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=', 'base64');
|
||||
const testGif = fs.openSync(testGifFileName, 'w+');
|
||||
fs.writeFileSync(testGif, buffer);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
afterAll(function() {
|
||||
fs.unlinkSync(testGifFileName);
|
||||
});
|
||||
|
||||
it('addEmoji', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addEmoji', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const name = TestHelper.generateId();
|
||||
|
||||
TestHelper.basicClient().addEmoji(
|
||||
{creator_id: TestHelper.basicUser().id, name},
|
||||
fs.createReadStream(testGifFileName),
|
||||
function(data) {
|
||||
assert.equal(data.name, name);
|
||||
assert.notEqual(data.id, null);
|
||||
expect(data.name).toEqual(name);
|
||||
expect(data.id).not.toBeNull();
|
||||
|
||||
TestHelper.basicClient().deleteEmoji(data.id);
|
||||
//TestHelper.basicClient().deleteEmoji(data.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteEmoji', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteEmoji', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().addEmoji(
|
||||
{creator_id: TestHelper.basicUser().id, name: TestHelper.generateId()},
|
||||
fs.createReadStream(testGifFileName),
|
||||
@@ -55,19 +52,19 @@ describe('Client.Emoji', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('listEmoji', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('listEmoji', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const name = TestHelper.generateId();
|
||||
TestHelper.basicClient().addEmoji(
|
||||
{creator_id: TestHelper.basicUser().id, name},
|
||||
@@ -75,7 +72,7 @@ describe('Client.Emoji', function() {
|
||||
function() {
|
||||
TestHelper.basicClient().listEmoji(
|
||||
function(data) {
|
||||
assert(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
|
||||
let found = false;
|
||||
for (const emoji of data) {
|
||||
@@ -88,16 +85,16 @@ describe('Client.Emoji', function() {
|
||||
if (found) {
|
||||
done();
|
||||
} else {
|
||||
done(new Error('test emoji wasn\'t returned'));
|
||||
done.fail(new Error('test emoji wasn\'t returned'));
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,17 +1,14 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
describe('Client.File', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
const testGifFileName = 'testFile.gif';
|
||||
|
||||
before(function() {
|
||||
beforeAll(function() {
|
||||
// write a temporary file so that we have something to upload for testing
|
||||
const buffer = new Buffer('R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=', 'base64');
|
||||
|
||||
@@ -19,12 +16,12 @@ describe('Client.File', function() {
|
||||
fs.writeFileSync(testGif, buffer);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
afterAll(function() {
|
||||
fs.unlinkSync(testGifFileName);
|
||||
});
|
||||
|
||||
it('uploadFile', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('uploadFile', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const clientId = TestHelper.generateId();
|
||||
|
||||
TestHelper.basicClient().uploadFile(
|
||||
@@ -33,21 +30,21 @@ describe('Client.File', function() {
|
||||
TestHelper.basicChannel().id,
|
||||
clientId,
|
||||
function(resp) {
|
||||
assert.equal(resp.file_infos.length, 1);
|
||||
assert.equal(resp.client_ids.length, 1);
|
||||
assert.equal(resp.client_ids[0], clientId);
|
||||
expect(resp.file_infos.length).toBe(1);
|
||||
expect(resp.client_ids.length).toBe(1);
|
||||
expect(resp.client_ids[0]).toEqual(clientId);
|
||||
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFile', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFile', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -60,19 +57,19 @@ describe('Client.File', function() {
|
||||
done();
|
||||
},
|
||||
function(err2) {
|
||||
done(new Error(err2.message));
|
||||
done.fail(new Error(err2.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFileThumbnail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFileThumbnail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -85,19 +82,19 @@ describe('Client.File', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFilePreview', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFilePreview', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -110,19 +107,19 @@ describe('Client.File', function() {
|
||||
done();
|
||||
},
|
||||
function(err2) {
|
||||
done(new Error(err2.message));
|
||||
done.fail(new Error(err2.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFileInfo', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFileInfo', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -134,25 +131,26 @@ describe('Client.File', function() {
|
||||
TestHelper.basicClient().getFileInfo(
|
||||
fileId,
|
||||
function(info) {
|
||||
assert.equal(info.id, fileId);
|
||||
assert.equal(info.name, testGifFileName);
|
||||
expect(info.id).toEqual(fileId);
|
||||
expect(info.name).toEqual(testGifFileName);
|
||||
|
||||
done();
|
||||
},
|
||||
function(err2) {
|
||||
done(new Error(err2.message));
|
||||
done.fail(new Error(err2.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPublicLink', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPublicLink', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -166,12 +164,12 @@ describe('Client.File', function() {
|
||||
TestHelper.basicClient().createPost(
|
||||
post,
|
||||
function(data) {
|
||||
assert.deepEqual(data.file_ids, post.file_ids);
|
||||
expect(data.file_ids).toEqual(post.file_ids);
|
||||
|
||||
TestHelper.basicClient().getPublicLink(
|
||||
post.file_ids[0],
|
||||
function() {
|
||||
done(new Error('public links should be disabled by default'));
|
||||
done.fail(new Error('public links should be disabled by default'));
|
||||
|
||||
// request.
|
||||
// get(link).
|
||||
@@ -182,31 +180,31 @@ describe('Client.File', function() {
|
||||
// done();
|
||||
// },
|
||||
// function(err4) {
|
||||
// done(new Error(err4.message));
|
||||
// done.fail(new Error(err4.message));
|
||||
// }
|
||||
// ));
|
||||
},
|
||||
function() {
|
||||
done();
|
||||
|
||||
// done(new Error(err3.message));
|
||||
// done.fail(new Error(err3.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err2) {
|
||||
done(new Error(err2.message));
|
||||
done.fail(new Error(err2.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFileInfosForPost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFileInfosForPost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().uploadFile(
|
||||
fs.createReadStream(testGifFileName),
|
||||
testGifFileName,
|
||||
@@ -220,29 +218,29 @@ describe('Client.File', function() {
|
||||
TestHelper.basicClient().createPost(
|
||||
post,
|
||||
function(data) {
|
||||
assert.deepEqual(data.file_ids, post.file_ids);
|
||||
expect(data.file_ids).toEqual(post.file_ids);
|
||||
|
||||
TestHelper.basicClient().getFileInfosForPost(
|
||||
post.channel_id,
|
||||
data.id,
|
||||
function(files) {
|
||||
assert.equal(files.length, 1);
|
||||
assert.equal(files[0].id, resp.file_infos[0].id);
|
||||
expect(files.length).toBe(1);
|
||||
expect(files[0].id).toEqual(resp.file_infos[0].id);
|
||||
|
||||
done();
|
||||
},
|
||||
function(err3) {
|
||||
done(new Error(err3.message));
|
||||
done.fail(new Error(err3.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err2) {
|
||||
done(new Error(err2.message));
|
||||
done.fail(new Error(err2.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,42 +1,39 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var assert = require('assert');
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.General', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('General.getClientConfig', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('General.getClientConfig', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getClientConfig(
|
||||
function(data) {
|
||||
assert.equal(data.SiteName, 'Mattermost');
|
||||
expect(data.SiteName).toEqual('Mattermost');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('General.getPing', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('General.getPing', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPing(
|
||||
function(data) {
|
||||
assert.equal(data.version.length > 0, true);
|
||||
expect(data.version.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('General.logClientError', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('General.logClientError', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var config = {};
|
||||
config.site_name = 'test';
|
||||
TestHelper.basicClient().logClientError('this is a test');
|
||||
@@ -1,14 +1,11 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Hooks', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('addIncomingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addIncomingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var hook = {};
|
||||
@@ -19,18 +16,18 @@ describe('Client.Hooks', function() {
|
||||
TestHelper.basicClient().addIncomingHook(
|
||||
hook,
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.incoming_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.incoming_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateIncomingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateIncomingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var hook = {};
|
||||
@@ -41,49 +38,49 @@ describe('Client.Hooks', function() {
|
||||
TestHelper.basicClient().updateIncomingHook(
|
||||
hook,
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.incoming_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.incoming_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteIncomingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteIncomingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().deleteIncomingHook(
|
||||
TestHelper.generateId(),
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.incoming_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.incoming_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('listIncomingHooks', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('listIncomingHooks', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().listIncomingHooks(
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.incoming_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.incoming_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('addOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var hook = {};
|
||||
@@ -94,65 +91,65 @@ describe('Client.Hooks', function() {
|
||||
TestHelper.basicClient().addOutgoingHook(
|
||||
hook,
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.outgoing_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.outgoing_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().deleteOutgoingHook(
|
||||
TestHelper.generateId(),
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.outgoing_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.outgoing_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('listOutgoingHooks', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('listOutgoingHooks', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().listOutgoingHooks(
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.outgoing_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.outgoing_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('regenOutgoingHookToken', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('regenOutgoingHookToken', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().regenOutgoingHookToken(
|
||||
TestHelper.generateId(),
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.outgoing_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.outgoing_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateOutgoingHook', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var hook = {};
|
||||
@@ -163,10 +160,10 @@ describe('Client.Hooks', function() {
|
||||
TestHelper.basicClient().updateOutgoingHook(
|
||||
hook,
|
||||
function() {
|
||||
done(new Error('hooks not enabled'));
|
||||
done.fail(new Error('hooks not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.outgoing_webhook.disabled.app_error');
|
||||
expect(err.id).toBe('api.outgoing_webhook.disabled.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
@@ -1,14 +1,11 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.OAuth', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('registerOAuthApp', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('registerOAuthApp', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
var app = {};
|
||||
@@ -20,18 +17,18 @@ describe('Client.OAuth', function() {
|
||||
TestHelper.basicClient().registerOAuthApp(
|
||||
app,
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.oauth.register_oauth_app.turn_off.app_error');
|
||||
expect(err.id).toBe('api.oauth.register_oauth_app.turn_off.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('allowOAuth2', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('allowOAuth2', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
TestHelper.basicClient().allowOAuth2(
|
||||
@@ -41,10 +38,10 @@ describe('Client.OAuth', function() {
|
||||
'state',
|
||||
'scope',
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.oauth.allow_oauth.turn_off.app_error');
|
||||
expect(err.id).toBe('api.oauth.allow_oauth.turn_off.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
@@ -1,63 +1,60 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Posts', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('createPost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('createPost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var post = TestHelper.fakePost();
|
||||
post.channel_id = TestHelper.basicChannel().id;
|
||||
|
||||
TestHelper.basicClient().createPost(
|
||||
post,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPostById', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPostById', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPostById(
|
||||
TestHelper.basicPost().id,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPost(
|
||||
TestHelper.basicChannel().id,
|
||||
TestHelper.basicPost().id,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updatePost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updatePost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var post = TestHelper.basicPost();
|
||||
post.message = 'new message';
|
||||
post.channel_id = TestHelper.basicChannel().id;
|
||||
@@ -65,83 +62,83 @@ describe('Client.Posts', function() {
|
||||
TestHelper.basicClient().updatePost(
|
||||
post,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deletePost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deletePost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().deletePost(
|
||||
TestHelper.basicChannel().id,
|
||||
TestHelper.basicPost().id,
|
||||
function(data) {
|
||||
assert.equal(data.id, TestHelper.basicPost().id);
|
||||
expect(data.id).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('searchPost', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('searchPost', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().search(
|
||||
'unit test',
|
||||
false,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPostsPage', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPostsPage', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPostsPage(
|
||||
TestHelper.basicChannel().id,
|
||||
0,
|
||||
10,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPosts', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPosts', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPosts(
|
||||
TestHelper.basicChannel().id,
|
||||
0,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPostsBefore', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPostsBefore', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var post = TestHelper.fakePost();
|
||||
post.channel_id = TestHelper.basicChannel().id;
|
||||
|
||||
@@ -154,23 +151,23 @@ describe('Client.Posts', function() {
|
||||
0,
|
||||
10,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPostsAfter', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPostsAfter', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var post = TestHelper.fakePost();
|
||||
post.channel_id = TestHelper.basicChannel().id;
|
||||
|
||||
@@ -183,23 +180,23 @@ describe('Client.Posts', function() {
|
||||
0,
|
||||
10,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], rpost.id);
|
||||
expect(data.order[0]).toEqual(rpost.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getFlaggedPosts', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getFlaggedPosts', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var pref = {};
|
||||
pref.user_id = TestHelper.basicUser().id;
|
||||
pref.category = 'flagged_post';
|
||||
@@ -216,16 +213,16 @@ describe('Client.Posts', function() {
|
||||
0,
|
||||
2,
|
||||
function(data) {
|
||||
assert.equal(data.order[0], TestHelper.basicPost().id);
|
||||
expect(data.order[0]).toEqual(TestHelper.basicPost().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,29 +1,26 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Preferences', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('getAllPreferences', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getAllPreferences', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getAllPreferences(
|
||||
function(data) {
|
||||
assert.equal(data[0].category, 'tutorial_step');
|
||||
assert.equal(data[0].user_id, TestHelper.basicUser().id);
|
||||
expect(data[0].category).toBe('tutorial_step');
|
||||
expect(data[0].user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('savePreferences', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('savePreferences', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var perf = {};
|
||||
perf.user_id = TestHelper.basicUser().id;
|
||||
perf.category = 'test';
|
||||
@@ -36,27 +33,27 @@ describe('Client.Preferences', function() {
|
||||
TestHelper.basicClient().savePreferences(
|
||||
perfs,
|
||||
function(data) {
|
||||
assert.equal(data, true);
|
||||
expect(data).toBe(true);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getPreferenceCategory', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getPreferenceCategory', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getPreferenceCategory(
|
||||
'tutorial_step',
|
||||
function(data) {
|
||||
assert.equal(data[0].category, 'tutorial_step');
|
||||
assert.equal(data[0].user_id, TestHelper.basicUser().id);
|
||||
expect(data[0].category).toBe('tutorial_step');
|
||||
expect(data[0].user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,13 +1,11 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Reaction', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('saveListReaction', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('saveListReaction', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const channelId = TestHelper.basicChannel().id;
|
||||
const postId = TestHelper.basicPost().id;
|
||||
|
||||
@@ -31,23 +29,23 @@ describe('Client.Reaction', function() {
|
||||
reactions[0].emoji_name === reaction.emoji_name) {
|
||||
done();
|
||||
} else {
|
||||
done(new Error('test reaction wasn\'t returned'));
|
||||
done.fail(new Error('test reaction wasn\'t returned'));
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('deleteReaction', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('deleteReaction', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const channelId = TestHelper.basicChannel().id;
|
||||
const postId = TestHelper.basicPost().id;
|
||||
|
||||
@@ -68,12 +66,12 @@ describe('Client.Reaction', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,168 +1,165 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.Team', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('findTeamByName', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('findTeamByName', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().findTeamByName(
|
||||
TestHelper.basicTeam().name,
|
||||
function(data) {
|
||||
assert.equal(data, true);
|
||||
expect(data).toBe(true);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('createTeam', function(done) {
|
||||
test('createTeam', function(done) {
|
||||
var team = TestHelper.fakeTeam();
|
||||
TestHelper.initBasic(() => {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().createTeam(
|
||||
team,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.name, team.name);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.name).toEqual(team.name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getAllTeams', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getAllTeams', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getAllTeams(
|
||||
function(data) {
|
||||
assert.equal(data[TestHelper.basicTeam().id].name, TestHelper.basicTeam().name);
|
||||
expect(data[TestHelper.basicTeam().id].name).toEqual(TestHelper.basicTeam().name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getAllTeamListings', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getAllTeamListings', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getAllTeamListings(
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
expect(data).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMyTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMyTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMyTeam(
|
||||
function(data) {
|
||||
assert.equal(data.name, TestHelper.basicTeam().name);
|
||||
expect(data.name).toEqual(TestHelper.basicTeam().name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getMyTeamMembers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMyTeamMembers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMyTeamMembers(
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getTeamMembers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getTeamMembers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getTeamMembers(
|
||||
TestHelper.basicTeam().id,
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getTeamMember', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getTeamMember', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getTeamMember(
|
||||
TestHelper.basicTeam().id,
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data.user_id, TestHelper.basicUser().id);
|
||||
assert.equal(data.team_id, TestHelper.basicTeam().id);
|
||||
expect(data.user_id).toEqual(TestHelper.basicUser().id);
|
||||
expect(data.team_id).toEqual(TestHelper.basicTeam().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getTeamStats', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getTeamStats', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getTeamStats(
|
||||
TestHelper.basicTeam().id,
|
||||
function(data) {
|
||||
assert.equal(data.total_member_count > 0, true);
|
||||
expect(data.total_member_count).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getTeamMembersByIds', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getTeamMembersByIds', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getTeamMembersByIds(
|
||||
TestHelper.basicTeam().id,
|
||||
[TestHelper.basicUser().id],
|
||||
function(data) {
|
||||
assert.equal(data[0].user_id, TestHelper.basicUser().id);
|
||||
assert.equal(data[0].team_id, TestHelper.basicTeam().id);
|
||||
expect(data[0].user_id).toEqual(TestHelper.basicUser().id);
|
||||
expect(data[0].team_id).toEqual(TestHelper.basicTeam().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('inviteMembers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('inviteMembers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var data = {};
|
||||
data.invites = [];
|
||||
var invite = {};
|
||||
@@ -174,54 +171,54 @@ describe('Client.Team', function() {
|
||||
TestHelper.basicClient().inviteMembers(
|
||||
data,
|
||||
function(dataBack) {
|
||||
assert.equal(dataBack.invites.length, 1);
|
||||
expect(dataBack.invites.length).toBe(1);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var team = TestHelper.basicTeam();
|
||||
team.display_name = 'test_updated';
|
||||
|
||||
TestHelper.basicClient().updateTeam(
|
||||
team,
|
||||
function(data) {
|
||||
assert.equal(data.display_name, 'test_updated');
|
||||
expect(data.display_name).toBe('test_updated');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateTeamDescription', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateTeamDescription', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var team = TestHelper.basicTeam();
|
||||
team.description = 'test_updated';
|
||||
|
||||
TestHelper.basicClient().updateTeam(
|
||||
team,
|
||||
function(data) {
|
||||
assert.equal(data.description, 'test_updated');
|
||||
expect(data.description).toBe('test_updated');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('addUserToTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('addUserToTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().createUser(
|
||||
TestHelper.fakeUser(),
|
||||
function(user2) {
|
||||
@@ -229,54 +226,54 @@ describe('Client.Team', function() {
|
||||
'',
|
||||
user2.id,
|
||||
function(data) {
|
||||
assert.equal(data.user_id, user2.id);
|
||||
expect(data.user_id).toEqual(user2.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('removeUserFromTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('removeUserFromTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().removeUserFromTeam(
|
||||
'',
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data.user_id, TestHelper.basicUser().id);
|
||||
expect(data.user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getInviteInfo', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getInviteInfo', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getInviteInfo(
|
||||
TestHelper.basicTeam().invite_id,
|
||||
function(data) {
|
||||
assert.equal(data.display_name.length > 0, true);
|
||||
expect(data.display_name.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateTeamMemberRoles', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateTeamMemberRoles', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
var team = TestHelper.basicTeam();
|
||||
|
||||
@@ -288,23 +285,22 @@ describe('Client.Team', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getTeamByName', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getTeamByName', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getTeamByName(
|
||||
TestHelper.basicTeam().name,
|
||||
function(data) {
|
||||
console.log(data);
|
||||
assert.equal(data.name, TestHelper.basicTeam().name);
|
||||
expect(data.name).toEqual(TestHelper.basicTeam().name);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,102 +1,99 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
import TestHelper from './test_helper.jsx';
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
describe('Client.User', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('getMe', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getMe', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getMe(
|
||||
function(data) {
|
||||
assert.equal(data.id, TestHelper.basicUser().id);
|
||||
expect(data.id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getUser', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getUser', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getUser(
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data.id, TestHelper.basicUser().id);
|
||||
expect(data.id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getByUsername', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getByUsername', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getByUsername(
|
||||
TestHelper.basicUser().username,
|
||||
function(data) {
|
||||
assert.equal(data.username, TestHelper.basicUser().username);
|
||||
expect(data.username).toEqual(TestHelper.basicUser().username);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getByEmail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getByEmail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getByEmail(
|
||||
TestHelper.basicUser().email,
|
||||
function(data) {
|
||||
assert.equal(data.email, TestHelper.basicUser().email);
|
||||
expect(data.email).toEqual(TestHelper.basicUser().email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getInitialLoad', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getInitialLoad', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getInitialLoad(
|
||||
function(data) {
|
||||
assert.equal(data.user.id.length > 0, true);
|
||||
expect(data.user.id.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('createUser', function(done) {
|
||||
test('createUser', function(done) {
|
||||
var client = TestHelper.createClient();
|
||||
var user = TestHelper.fakeUser();
|
||||
client.createUser(
|
||||
user,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.email, user.email);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.email).toEqual(user.email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('loginByEmail', function(done) {
|
||||
test('loginByEmail', function(done) {
|
||||
var client = TestHelper.createClient();
|
||||
var user = TestHelper.fakeUser();
|
||||
client.createUser(
|
||||
@@ -107,49 +104,49 @@ describe('Client.User', function() {
|
||||
user.password,
|
||||
null,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.email, user.email);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.email).toEqual(user.email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('loginById', function(done) {
|
||||
test('loginById', function(done) {
|
||||
var client = TestHelper.createClient();
|
||||
var user = TestHelper.fakeUser();
|
||||
client.createUser(
|
||||
user,
|
||||
function(newUser) {
|
||||
assert.equal(user.email, newUser.email);
|
||||
expect(user.email).toEqual(newUser.email);
|
||||
client.loginById(
|
||||
newUser.id,
|
||||
user.password,
|
||||
null,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.email, user.email);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.email).toEqual(user.email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('loginByUsername', function(done) {
|
||||
test('loginByUsername', function(done) {
|
||||
var client = TestHelper.createClient();
|
||||
var user = TestHelper.fakeUser();
|
||||
client.createUser(
|
||||
@@ -160,41 +157,41 @@ describe('Client.User', function() {
|
||||
user.password,
|
||||
null,
|
||||
function(data) {
|
||||
assert.equal(data.id.length > 0, true);
|
||||
assert.equal(data.email, user.email);
|
||||
expect(data.id.length).toBeGreaterThan(0);
|
||||
expect(data.email).toEqual(user.email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('updateUser', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateUser', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
user.nickname = 'updated';
|
||||
|
||||
TestHelper.basicClient().updateUser(
|
||||
user, null,
|
||||
function(data) {
|
||||
assert.equal(data.nickname, 'updated');
|
||||
expect(data.nickname).toBe('updated');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updatePassword', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updatePassword', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
TestHelper.basicClient().updatePassword(
|
||||
@@ -202,18 +199,18 @@ describe('Client.User', function() {
|
||||
user.password,
|
||||
'update_password',
|
||||
function(data) {
|
||||
assert.equal(data.user_id, user.id);
|
||||
expect(data.user_id).toEqual(user.id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateUserNotifyProps', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateUserNotifyProps', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
var notifyProps = {
|
||||
@@ -231,25 +228,26 @@ describe('Client.User', function() {
|
||||
TestHelper.basicClient().updateUserNotifyProps(
|
||||
notifyProps,
|
||||
function(data) {
|
||||
assert.equal(data.notify_props.email, 'false');
|
||||
expect(data.notify_props.email).toBe('false');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateUserRoles', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateUserRoles', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
TestHelper.basicClient().updateUserRoles(
|
||||
user.id,
|
||||
'',
|
||||
function() {
|
||||
done(new Error('Not supposed to work'));
|
||||
done.fail(new Error('Not supposed to work'));
|
||||
},
|
||||
function() {
|
||||
done();
|
||||
@@ -258,43 +256,43 @@ describe('Client.User', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('updateActive', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateActive', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
const user = TestHelper.basicUser();
|
||||
|
||||
TestHelper.basicClient().updateActive(
|
||||
user.id,
|
||||
false,
|
||||
function(data) {
|
||||
assert.ok(data.delete_at > 0);
|
||||
expect(data.delete_at).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('sendPasswordReset', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('sendPasswordReset', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
TestHelper.basicClient().sendPasswordReset(
|
||||
user.email,
|
||||
function(data) {
|
||||
assert.equal(data.email, user.email);
|
||||
expect(data.email).toEqual(user.email);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('resetPassword', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('resetPassword', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
|
||||
TestHelper.basicClient().resetPassword(
|
||||
@@ -305,15 +303,15 @@ describe('Client.User', function() {
|
||||
},
|
||||
function(err) {
|
||||
// this should fail since you're not a system admin
|
||||
assert.equal(err.id, 'api.context.invalid_param.app_error');
|
||||
expect(err.id).toBe('api.context.invalid_param.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('emailToOAuth', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('emailToOAuth', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
@@ -327,33 +325,33 @@ describe('Client.User', function() {
|
||||
},
|
||||
function(err) {
|
||||
// this should fail since you're not a system admin
|
||||
assert.equal(err.id, 'api.user.check_user_password.invalid.app_error');
|
||||
expect(err.id).toBe('api.user.check_user_password.invalid.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('oauthToEmail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('oauthToEmail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
TestHelper.basicClient().oauthToEmail(
|
||||
user.email,
|
||||
'new_password',
|
||||
function(data) {
|
||||
assert.equal(data.follow_link.length > 0, true);
|
||||
expect(data.follow_link.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('emailToLdap', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('emailToLdap', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
@@ -373,8 +371,8 @@ describe('Client.User', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('ldapToEmail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('ldapToEmail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
var user = TestHelper.basicUser();
|
||||
|
||||
@@ -387,47 +385,48 @@ describe('Client.User', function() {
|
||||
throw Error('shouldnt work');
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.user.ldap_to_email.not_ldap_account.app_error');
|
||||
expect(err.id).toBe('api.user.ldap_to_email.not_ldap_account.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('logout', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('logout', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().logout(
|
||||
function(data) {
|
||||
assert.equal(data.user_id, TestHelper.basicUser().id);
|
||||
expect(data.user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('checkMfa', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('checkMfa', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().checkMfa(
|
||||
TestHelper.generateId(),
|
||||
function(data) {
|
||||
assert.equal(data.mfa_required, 'false');
|
||||
expect(data.mfa_required).toBe('false');
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('generateMfaSecret', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('generateMfaSecret', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().generateMfaSecret(
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function() {
|
||||
done();
|
||||
@@ -436,224 +435,224 @@ describe('Client.User', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('getSessions', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getSessions', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getSessions(
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data[0].user_id, TestHelper.basicUser().id);
|
||||
expect(data[0].user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('revokeSession', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('revokeSession', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getSessions(
|
||||
TestHelper.basicUser().id,
|
||||
function(sessions) {
|
||||
TestHelper.basicClient().revokeSession(
|
||||
sessions[0].id,
|
||||
function(data) {
|
||||
assert.equal(data.id, sessions[0].id);
|
||||
expect(data.id).toEqual(sessions[0].id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getAudits', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getAudits', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getAudits(
|
||||
TestHelper.basicUser().id,
|
||||
function(data) {
|
||||
assert.equal(data[0].user_id, TestHelper.basicUser().id);
|
||||
expect(data[0].user_id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getProfiles', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getProfiles', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getProfiles(
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(Object.keys(data).length > 0, true);
|
||||
expect(Object.keys(data).length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getProfilesInTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getProfilesInTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getProfilesInTeam(
|
||||
TestHelper.basicTeam().id,
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(data[TestHelper.basicUser().id].id, TestHelper.basicUser().id);
|
||||
expect(data[TestHelper.basicUser().id].id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getProfilesByIds', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getProfilesByIds', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getProfilesByIds(
|
||||
[TestHelper.basicUser().id],
|
||||
function(data) {
|
||||
assert.equal(data[TestHelper.basicUser().id].id, TestHelper.basicUser().id);
|
||||
expect(data[TestHelper.basicUser().id].id).toEqual(TestHelper.basicUser().id);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getProfilesInChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getProfilesInChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getProfilesInChannel(
|
||||
TestHelper.basicChannel().id,
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(Object.keys(data).length > 0, true);
|
||||
expect(Object.keys(data).length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getProfilesNotInChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getProfilesNotInChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().getProfilesNotInChannel(
|
||||
TestHelper.basicChannel().id,
|
||||
0,
|
||||
100,
|
||||
function(data) {
|
||||
assert.equal(Object.keys(data).length > 0, false);
|
||||
expect(Object.keys(data).length).not.toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('searchUsers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('searchUsers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().searchUsers(
|
||||
'uid',
|
||||
TestHelper.basicTeam().id,
|
||||
{},
|
||||
function(data) {
|
||||
assert.equal(data.length > 0, true);
|
||||
expect(data.length).toBeGreaterThan(0);
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('autocompleteUsersInChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('autocompleteUsersInChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().autocompleteUsersInChannel(
|
||||
'uid',
|
||||
TestHelper.basicChannel().id,
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
expect(data).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('autocompleteUsersInTeam', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('autocompleteUsersInTeam', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().autocompleteUsersInTeam(
|
||||
'uid',
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
expect(data).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('autocompleteUsers', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('autocompleteUsers', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().autocompleteUsers(
|
||||
'uid',
|
||||
function(data) {
|
||||
assert.equal(data != null, true);
|
||||
expect(data).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('getStatusesByIds', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('getStatusesByIds', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var ids = [];
|
||||
ids.push(TestHelper.basicUser().id);
|
||||
|
||||
TestHelper.basicClient().getStatusesByIds(
|
||||
ids,
|
||||
function(data) {
|
||||
assert.equal(data[TestHelper.basicUser().id] != null, true);
|
||||
expect(data[TestHelper.basicUser().id]).not.toBeNull();
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('setActiveChannel', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('setActiveChannel', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
var ids = [];
|
||||
ids.push(TestHelper.basicUser().id);
|
||||
|
||||
@@ -663,31 +662,31 @@ describe('Client.User', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('verifyEmail', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('verifyEmail', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().verifyEmail(
|
||||
'junk',
|
||||
'junk',
|
||||
function() {
|
||||
done(new Error('should be invalid'));
|
||||
done.fail(new Error('should be invalid'));
|
||||
},
|
||||
function(err) {
|
||||
assert.equal(err.id, 'api.context.invalid_param.app_error');
|
||||
expect(err.id).toBe('api.context.invalid_param.app_error');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('resendVerification', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('resendVerification', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().resendVerification(
|
||||
TestHelper.basicUser().email,
|
||||
@@ -695,20 +694,20 @@ describe('Client.User', function() {
|
||||
done();
|
||||
},
|
||||
function(err) {
|
||||
done(new Error(err.message));
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('updateMfa', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('updateMfa', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
|
||||
TestHelper.basicClient().updateMfa(
|
||||
'junk',
|
||||
true,
|
||||
function() {
|
||||
done(new Error('not enabled'));
|
||||
done.fail(new Error('not enabled'));
|
||||
},
|
||||
function() {
|
||||
done();
|
||||
@@ -1,49 +1,46 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
/*
|
||||
var assert = require('assert');
|
||||
import TestHelper from './test_helper.jsx';
|
||||
|
||||
describe('Client.WebSocket', function() {
|
||||
this.timeout(10000);
|
||||
import TestHelper from 'tests/helpers/client-test-helper.jsx';
|
||||
|
||||
it('WebSocket.getStatusesByIds', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
describe.skip('Client.WebSocket', function() {
|
||||
test('WebSocket.getStatusesByIds', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicWebSocketClient().getStatusesByIds(
|
||||
[TestHelper.basicUser().id],
|
||||
function(resp) {
|
||||
TestHelper.basicWebSocketClient().close();
|
||||
assert.equal(resp.data[TestHelper.basicUser().id], 'online');
|
||||
expect(resp.data[TestHelper.basicUser().id]).toBe('online');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}, true);
|
||||
});
|
||||
|
||||
it('WebSocket.getStatuses', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('WebSocket.getStatuses', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicWebSocketClient().getStatuses(
|
||||
function(resp) {
|
||||
TestHelper.basicWebSocketClient().close();
|
||||
assert.equal(resp.data != null, true);
|
||||
expect(resp.data).not.toBe(null);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}, true);
|
||||
});
|
||||
|
||||
it('WebSocket.userTyping', function(done) {
|
||||
TestHelper.initBasic(() => {
|
||||
test('WebSocket.userTyping', function(done) {
|
||||
TestHelper.initBasic(done, () => {
|
||||
TestHelper.basicWebSocketClient().userTyping(
|
||||
TestHelper.basicChannel().id,
|
||||
'',
|
||||
function(resp) {
|
||||
TestHelper.basicWebSocketClient().close();
|
||||
assert.equal(resp.status, 'OK');
|
||||
expect(resp.status).toBe('OK');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}, true);
|
||||
});
|
||||
});*/
|
||||
});
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`components/AboutBuildModal should match snapshot for enterprise edition 1`] = `
|
||||
<Modal
|
||||
animation={true}
|
||||
autoFocus={true}
|
||||
backdrop={true}
|
||||
bsClass="modal"
|
||||
dialogClassName="about-modal"
|
||||
dialogComponentClass={[Function]}
|
||||
enforceFocus={true}
|
||||
keyboard={true}
|
||||
manager={
|
||||
ModalManager {
|
||||
"containers": Array [],
|
||||
"data": Array [],
|
||||
"handleContainerOverflow": true,
|
||||
"hideSiblingNodes": true,
|
||||
"modals": Array [],
|
||||
}
|
||||
}
|
||||
onHide={[Function]}
|
||||
renderBackdrop={[Function]}
|
||||
restoreFocus={true}
|
||||
show={true}
|
||||
>
|
||||
<ModalHeader
|
||||
aria-label="Close"
|
||||
bsClass="modal-header"
|
||||
closeButton={true}
|
||||
>
|
||||
<ModalTitle
|
||||
bsClass="modal-title"
|
||||
componentClass="h4"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="About Mattermost"
|
||||
id="about.title"
|
||||
values={Object {}}
|
||||
/>
|
||||
</ModalTitle>
|
||||
</ModalHeader>
|
||||
<ModalBody
|
||||
bsClass="modal-body"
|
||||
componentClass="div"
|
||||
>
|
||||
<div
|
||||
className="about-modal__content"
|
||||
>
|
||||
<div
|
||||
className="about-modal__logo"
|
||||
>
|
||||
<span
|
||||
className="icon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px'viewBox='0 0 500 500' style='enable-background:new 0 0 500 500;' xml:space='preserve'> <style type='text/css'> .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#222222;} </style> <g id='XMLID_1_'> <g id='XMLID_3_'> <path id='XMLID_4_' class='st0' d='M396.9,47.7l2.6,53.1c43,47.5,60,114.8,38.6,178.1c-32,94.4-137.4,144.1-235.4,110.9 S51.1,253.1,83,158.7C104.5,95.2,159.2,52,222.5,40.5l34.2-40.4C150-2.8,49.3,63.4,13.3,169.9C-31,300.6,39.1,442.5,169.9,486.7 s272.6-25.8,316.9-156.6C522.7,223.9,483.1,110.3,396.9,47.7z'/> </g> <path id='XMLID_2_' class='st0' d='M335.6,204.3l-1.8-74.2l-1.5-42.7l-1-37c0,0,0.2-17.8-0.4-22c-0.1-0.9-0.4-1.6-0.7-2.2 c0-0.1-0.1-0.2-0.1-0.3c0-0.1-0.1-0.2-0.1-0.2c-0.7-1.2-1.8-2.1-3.1-2.6c-1.4-0.5-2.9-0.4-4.2,0.2c0,0-0.1,0-0.1,0 c-0.2,0.1-0.3,0.1-0.4,0.2c-0.6,0.3-1.2,0.7-1.8,1.3c-3,3-13.7,17.2-13.7,17.2l-23.2,28.8l-27.1,33l-46.5,57.8 c0,0-21.3,26.6-16.6,59.4s29.1,48.7,48,55.1c18.9,6.4,48,8.5,71.6-14.7C336.4,238.4,335.6,204.3,335.6,204.3z'/> </g> </svg>",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h3
|
||||
className="about-modal__title"
|
||||
>
|
||||
Mattermost
|
||||
|
||||
<FormattedMessage
|
||||
defaultMessage="Enterprise Edition"
|
||||
id="about.teamEditiont1"
|
||||
values={Object {}}
|
||||
/>
|
||||
</h3>
|
||||
<p
|
||||
className="about-modal__subtitle padding-bottom"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Modern communication from behind your firewall."
|
||||
id="about.enterpriseEditionSt"
|
||||
values={Object {}}
|
||||
/>
|
||||
</p>
|
||||
<div
|
||||
className="form-group less"
|
||||
>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Version:"
|
||||
id="about.version"
|
||||
values={Object {}}
|
||||
/>
|
||||
<span
|
||||
id="versionString"
|
||||
>
|
||||
3.6.0 (3.6.2)
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Database:"
|
||||
id="about.database"
|
||||
values={Object {}}
|
||||
/>
|
||||
Postgres
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="about-modal__footer"
|
||||
>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Learn more about Enterprise Edition at "
|
||||
id="about.enterpriseEditionLearn"
|
||||
values={Object {}}
|
||||
/>
|
||||
<a
|
||||
href="http://about.mattermost.com/"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
about.mattermost.com
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
className="form-group about-modal__copyright"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Copyright 2016 Mattermost, Inc. All rights reserved"
|
||||
id="about.copyright"
|
||||
values={Object {}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="about-modal__hash form-group padding-top x2"
|
||||
>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Build Hash:"
|
||||
id="about.hash"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
abcdef1234567890
|
||||
<br />
|
||||
<FormattedMessage
|
||||
defaultMessage="EE Build Hash:"
|
||||
id="about.hashee"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
0123456789abcdef
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Build Date:"
|
||||
id="about.date"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
21 January 2017
|
||||
</p>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
`;
|
||||
|
||||
exports[`components/AboutBuildModal should match snapshot for team edition 1`] = `
|
||||
<Modal
|
||||
animation={true}
|
||||
autoFocus={true}
|
||||
backdrop={true}
|
||||
bsClass="modal"
|
||||
dialogClassName="about-modal"
|
||||
dialogComponentClass={[Function]}
|
||||
enforceFocus={true}
|
||||
keyboard={true}
|
||||
manager={
|
||||
ModalManager {
|
||||
"containers": Array [],
|
||||
"data": Array [],
|
||||
"handleContainerOverflow": true,
|
||||
"hideSiblingNodes": true,
|
||||
"modals": Array [],
|
||||
}
|
||||
}
|
||||
onHide={[Function]}
|
||||
renderBackdrop={[Function]}
|
||||
restoreFocus={true}
|
||||
show={true}
|
||||
>
|
||||
<ModalHeader
|
||||
aria-label="Close"
|
||||
bsClass="modal-header"
|
||||
closeButton={true}
|
||||
>
|
||||
<ModalTitle
|
||||
bsClass="modal-title"
|
||||
componentClass="h4"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="About Mattermost"
|
||||
id="about.title"
|
||||
values={Object {}}
|
||||
/>
|
||||
</ModalTitle>
|
||||
</ModalHeader>
|
||||
<ModalBody
|
||||
bsClass="modal-body"
|
||||
componentClass="div"
|
||||
>
|
||||
<div
|
||||
className="about-modal__content"
|
||||
>
|
||||
<div
|
||||
className="about-modal__logo"
|
||||
>
|
||||
<span
|
||||
className="icon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px'viewBox='0 0 500 500' style='enable-background:new 0 0 500 500;' xml:space='preserve'> <style type='text/css'> .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#222222;} </style> <g id='XMLID_1_'> <g id='XMLID_3_'> <path id='XMLID_4_' class='st0' d='M396.9,47.7l2.6,53.1c43,47.5,60,114.8,38.6,178.1c-32,94.4-137.4,144.1-235.4,110.9 S51.1,253.1,83,158.7C104.5,95.2,159.2,52,222.5,40.5l34.2-40.4C150-2.8,49.3,63.4,13.3,169.9C-31,300.6,39.1,442.5,169.9,486.7 s272.6-25.8,316.9-156.6C522.7,223.9,483.1,110.3,396.9,47.7z'/> </g> <path id='XMLID_2_' class='st0' d='M335.6,204.3l-1.8-74.2l-1.5-42.7l-1-37c0,0,0.2-17.8-0.4-22c-0.1-0.9-0.4-1.6-0.7-2.2 c0-0.1-0.1-0.2-0.1-0.3c0-0.1-0.1-0.2-0.1-0.2c-0.7-1.2-1.8-2.1-3.1-2.6c-1.4-0.5-2.9-0.4-4.2,0.2c0,0-0.1,0-0.1,0 c-0.2,0.1-0.3,0.1-0.4,0.2c-0.6,0.3-1.2,0.7-1.8,1.3c-3,3-13.7,17.2-13.7,17.2l-23.2,28.8l-27.1,33l-46.5,57.8 c0,0-21.3,26.6-16.6,59.4s29.1,48.7,48,55.1c18.9,6.4,48,8.5,71.6-14.7C336.4,238.4,335.6,204.3,335.6,204.3z'/> </g> </svg>",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h3
|
||||
className="about-modal__title"
|
||||
>
|
||||
Mattermost
|
||||
|
||||
<FormattedMessage
|
||||
defaultMessage="Team Edition"
|
||||
id="about.teamEditiont0"
|
||||
values={Object {}}
|
||||
/>
|
||||
</h3>
|
||||
<p
|
||||
className="about-modal__subtitle padding-bottom"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="All your team communication in one place, instantly searchable and accessible anywhere."
|
||||
id="about.teamEditionSt"
|
||||
values={Object {}}
|
||||
/>
|
||||
</p>
|
||||
<div
|
||||
className="form-group less"
|
||||
>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Version:"
|
||||
id="about.version"
|
||||
values={Object {}}
|
||||
/>
|
||||
<span
|
||||
id="versionString"
|
||||
>
|
||||
3.6.0 (3.6.2)
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Database:"
|
||||
id="about.database"
|
||||
values={Object {}}
|
||||
/>
|
||||
Postgres
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="about-modal__footer"
|
||||
>
|
||||
<div>
|
||||
<FormattedMessage
|
||||
defaultMessage="Join the Mattermost community at "
|
||||
id="about.teamEditionLearn"
|
||||
values={Object {}}
|
||||
/>
|
||||
<a
|
||||
href="http://www.mattermost.org/"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
mattermost.org
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
className="form-group about-modal__copyright"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Copyright 2016 Mattermost, Inc. All rights reserved"
|
||||
id="about.copyright"
|
||||
values={Object {}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="about-modal__hash form-group padding-top x2"
|
||||
>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Build Hash:"
|
||||
id="about.hash"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
abcdef1234567890
|
||||
<br />
|
||||
<FormattedMessage
|
||||
defaultMessage="EE Build Hash:"
|
||||
id="about.hashee"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Build Date:"
|
||||
id="about.date"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
||||
21 January 2017
|
||||
</p>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
`;
|
||||
@@ -0,0 +1,27 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`components/SpinnerButton should match snapshot with children 1`] = `
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
>
|
||||
<span
|
||||
id="child1"
|
||||
/>
|
||||
<span
|
||||
id="child2"
|
||||
/>
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`components/SpinnerButton should match snapshot with required props 1`] = `
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`components/SpinnerButton should match snapshot with spinning 1`] = `
|
||||
<img
|
||||
className="spinner-button__gif"
|
||||
src={Object {}}
|
||||
/>
|
||||
`;
|
||||
129
webapp/tests/components/about_build_modal.test.jsx
Normal file
129
webapp/tests/components/about_build_modal.test.jsx
Normal file
@@ -0,0 +1,129 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {shallow} from 'enzyme';
|
||||
import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
|
||||
|
||||
import AboutBuildModal from 'components/about_build_modal.jsx';
|
||||
import {Modal} from 'react-bootstrap';
|
||||
|
||||
describe('components/AboutBuildModal', () => {
|
||||
afterEach(() => {
|
||||
global.window.mm_config = null;
|
||||
global.window.mm_license = null;
|
||||
});
|
||||
|
||||
test('should match snapshot for enterprise edition', () => {
|
||||
global.window.mm_config = {
|
||||
BuildEnterpriseReady: 'true',
|
||||
Version: '3.6.0',
|
||||
BuildNumber: '3.6.2',
|
||||
SQLDriverName: 'Postgres',
|
||||
BuildHash: 'abcdef1234567890',
|
||||
BuildHashEnterprise: '0123456789abcdef',
|
||||
BuildDate: '21 January 2017'
|
||||
};
|
||||
|
||||
global.window.mm_license = {
|
||||
isLicensed: 'true',
|
||||
Company: 'Mattermost Inc'
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
<AboutBuildModal
|
||||
show={true}
|
||||
onModalDismissed={null}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot for team edition', () => {
|
||||
global.window.mm_config = {
|
||||
BuildEnterpriseReady: 'false',
|
||||
Version: '3.6.0',
|
||||
BuildNumber: '3.6.2',
|
||||
SQLDriverName: 'Postgres',
|
||||
BuildHash: 'abcdef1234567890',
|
||||
BuildDate: '21 January 2017'
|
||||
};
|
||||
|
||||
global.window.mm_license = null;
|
||||
|
||||
const wrapper = shallow(
|
||||
<AboutBuildModal
|
||||
show={true}
|
||||
onModalDismissed={null}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should hide the build number if it is the same as the version number', () => {
|
||||
global.window.mm_config = {
|
||||
BuildEnterpriseReady: 'false',
|
||||
Version: '3.6.0',
|
||||
BuildNumber: '3.6.0',
|
||||
SQLDriverName: 'Postgres',
|
||||
BuildHash: 'abcdef1234567890',
|
||||
BuildDate: '21 January 2017'
|
||||
};
|
||||
|
||||
global.window.mm_license = null;
|
||||
|
||||
const wrapper = shallow(
|
||||
<AboutBuildModal
|
||||
show={true}
|
||||
onModalDismissed={null}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find('#versionString').text()).toBe(' 3.6.0');
|
||||
});
|
||||
|
||||
test('should show the build number if it is the different from the version number', () => {
|
||||
global.window.mm_config = {
|
||||
BuildEnterpriseReady: 'false',
|
||||
Version: '3.6.0',
|
||||
BuildNumber: '3.6.2',
|
||||
SQLDriverName: 'Postgres',
|
||||
BuildHash: 'abcdef1234567890',
|
||||
BuildDate: '21 January 2017'
|
||||
};
|
||||
|
||||
global.window.mm_license = null;
|
||||
|
||||
const wrapper = shallow(
|
||||
<AboutBuildModal
|
||||
show={true}
|
||||
onModalDismissed={null}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find('#versionString').text()).toBe(' 3.6.0\u00a0 (3.6.2)');
|
||||
});
|
||||
|
||||
test('should call onModalDismissed callback when the modal is hidden', (done) => {
|
||||
global.window.mm_config = {
|
||||
BuildEnterpriseReady: 'false',
|
||||
Version: '3.6.0',
|
||||
BuildNumber: '3.6.2',
|
||||
SQLDriverName: 'Postgres',
|
||||
BuildHash: 'abcdef1234567890',
|
||||
BuildDate: '21 January 2017'
|
||||
};
|
||||
|
||||
global.window.mm_license = null;
|
||||
|
||||
function onHide() {
|
||||
done();
|
||||
}
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<AboutBuildModal
|
||||
show={true}
|
||||
onModalDismissed={onHide}
|
||||
/>
|
||||
);
|
||||
wrapper.find(Modal).first().props().onHide();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`components/backstage/components/BackstageHeader should match snapshot with children 1`] = `
|
||||
<div
|
||||
className="backstage-header"
|
||||
>
|
||||
<h1>
|
||||
<div>
|
||||
Child 1
|
||||
</div>
|
||||
<span
|
||||
className="backstage-header__divider"
|
||||
>
|
||||
<i
|
||||
className="fa fa-angle-right"
|
||||
/>
|
||||
</span>
|
||||
<div>
|
||||
Child 2
|
||||
</div>
|
||||
</h1>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`components/backstage/components/BackstageHeader should match snapshot without children 1`] = `
|
||||
<div
|
||||
className="backstage-header"
|
||||
>
|
||||
<h1 />
|
||||
</div>
|
||||
`;
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {shallow} from 'enzyme';
|
||||
|
||||
import BackstageHeader from 'components/backstage/components/backstage_header.jsx';
|
||||
|
||||
describe('components/backstage/components/BackstageHeader', () => {
|
||||
test('should match snapshot without children', () => {
|
||||
const wrapper = shallow(
|
||||
<BackstageHeader/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot with children', () => {
|
||||
const wrapper = shallow(
|
||||
<BackstageHeader>
|
||||
<div>{'Child 1'}</div>
|
||||
<div>{'Child 2'}</div>
|
||||
</BackstageHeader>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
53
webapp/tests/components/spinner_button.test.jsx
Normal file
53
webapp/tests/components/spinner_button.test.jsx
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {shallow, mount} from 'enzyme';
|
||||
|
||||
import SpinnerButton from 'components/spinner_button.jsx';
|
||||
|
||||
describe('components/SpinnerButton', () => {
|
||||
test('should match snapshot with required props', () => {
|
||||
const wrapper = shallow(
|
||||
<SpinnerButton
|
||||
spinning={false}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot with spinning', () => {
|
||||
const wrapper = shallow(
|
||||
<SpinnerButton
|
||||
spinning={true}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot with children', () => {
|
||||
const wrapper = shallow(
|
||||
<SpinnerButton
|
||||
spinning={false}
|
||||
>
|
||||
<span id='child1'/>
|
||||
<span id='child2'/>
|
||||
</SpinnerButton>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should handle onClick', (done) => {
|
||||
function onClick() {
|
||||
done();
|
||||
}
|
||||
|
||||
const wrapper = mount(
|
||||
<SpinnerButton
|
||||
spinning={false}
|
||||
onClick={onClick}
|
||||
/>
|
||||
);
|
||||
wrapper.find('button').first().props().onClick();
|
||||
});
|
||||
});
|
||||
16
webapp/tests/components/suggestion/suggestion_box.test.jsx
Normal file
16
webapp/tests/components/suggestion/suggestion_box.test.jsx
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import SuggestionBox from 'components/suggestion/suggestion_box.jsx';
|
||||
|
||||
describe('components/SuggestionBox', function() {
|
||||
test('findOverlap', () => {
|
||||
expect(SuggestionBox.findOverlap('', 'blue')).toBe('');
|
||||
expect(SuggestionBox.findOverlap('red', '')).toBe('');
|
||||
expect(SuggestionBox.findOverlap('red', 'blue')).toBe('');
|
||||
expect(SuggestionBox.findOverlap('red', 'dog')).toBe('d');
|
||||
expect(SuggestionBox.findOverlap('red', 'education')).toBe('ed');
|
||||
expect(SuggestionBox.findOverlap('red', 'reduce')).toBe('red');
|
||||
expect(SuggestionBox.findOverlap('black', 'ack')).toBe('ack');
|
||||
});
|
||||
});
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
|
||||
import EmojiStore from 'stores/emoji_store.jsx';
|
||||
import * as Emoticons from 'utils/emoticons.jsx';
|
||||
|
||||
describe('Emoticons', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
it('handleEmoticons', function(done) {
|
||||
const emojis = EmojiStore.getEmojis();
|
||||
|
||||
assert.equal(
|
||||
Emoticons.handleEmoticons(':goat: :dash:', new Map(), emojis),
|
||||
'$MM_EMOTICON0 $MM_EMOTICON1',
|
||||
'should replace emoticons with tokens'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
Emoticons.handleEmoticons(':goat::dash:', new Map(), emojis),
|
||||
'$MM_EMOTICON0$MM_EMOTICON1',
|
||||
'should replace emoticons not separated by whitespace'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
Emoticons.handleEmoticons('/:goat:..:dash:)', new Map(), emojis),
|
||||
'/$MM_EMOTICON0..$MM_EMOTICON1)',
|
||||
'should replace emoticons separated by punctuation'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
Emoticons.handleEmoticons('asdf:goat:asdf:dash:asdf', new Map(), emojis),
|
||||
'asdf$MM_EMOTICON0asdf$MM_EMOTICON1asdf',
|
||||
'should replace emoticons separated by text'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
Emoticons.handleEmoticons(':asdf: :goat : : dash:', new Map(), emojis),
|
||||
':asdf: :goat : : dash:',
|
||||
'shouldn\'t replace invalid emoticons'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -103,11 +103,11 @@ class TestHelperClass {
|
||||
return post;
|
||||
}
|
||||
|
||||
initBasic = (callback, connectWS) => {
|
||||
initBasic = (done, callback, connectWS) => {
|
||||
this.basicc = this.createClient();
|
||||
|
||||
function throwerror(err) {
|
||||
throw err;
|
||||
done.fail(new Error(err.message));
|
||||
}
|
||||
|
||||
var d1 = jqd.Deferred();
|
||||
22
webapp/tests/helpers/intl-test-helper.jsx
Normal file
22
webapp/tests/helpers/intl-test-helper.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {mount, shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
import {IntlProvider, intlShape} from 'react-intl';
|
||||
|
||||
const intlProvider = new IntlProvider({locale: 'en'}, {});
|
||||
const {intl} = intlProvider.getChildContext();
|
||||
|
||||
export function shallowWithIntl(node, {context} = {}) {
|
||||
return shallow(React.cloneElement(node, {intl}), {
|
||||
context: Object.assign({}, context, {intl})
|
||||
});
|
||||
}
|
||||
|
||||
export function mountWithIntl(node, {context, childContextTypes} = {}) {
|
||||
return mount(React.cloneElement(node, {intl}), {
|
||||
context: Object.assign({}, context, {intl}),
|
||||
childContextTypes: Object.assign({}, {intl: intlShape}, childContextTypes)
|
||||
});
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
var jsdom = require('mocha-jsdom');
|
||||
var assert = require('assert');
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import SpinnerButton from '../components/spinner_button.jsx';
|
||||
import React from 'react';
|
||||
|
||||
describe('SpinnerButton', function() {
|
||||
this.timeout(10000);
|
||||
jsdom();
|
||||
|
||||
it('check props', function() {
|
||||
const spinner = TestUtils.renderIntoDocument(
|
||||
<SpinnerButton spinning={false}/>
|
||||
);
|
||||
|
||||
assert.equal(spinner.props.spinning, false, 'should start in the default false state');
|
||||
});
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
|
||||
import SuggestionBox from 'components/suggestion/suggestion_box.jsx';
|
||||
|
||||
describe('SuggestionBox', function() {
|
||||
it('findOverlap', function(done) {
|
||||
assert.equal(SuggestionBox.findOverlap('', 'blue'), '');
|
||||
assert.equal(SuggestionBox.findOverlap('red', ''), '');
|
||||
assert.equal(SuggestionBox.findOverlap('red', 'blue'), '');
|
||||
assert.equal(SuggestionBox.findOverlap('red', 'dog'), 'd');
|
||||
assert.equal(SuggestionBox.findOverlap('red', 'education'), 'ed');
|
||||
assert.equal(SuggestionBox.findOverlap('red', 'reduce'), 'red');
|
||||
assert.equal(SuggestionBox.findOverlap('black', 'ack'), 'ack');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
36
webapp/tests/utils/emoticons.test.jsx
Normal file
36
webapp/tests/utils/emoticons.test.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import EmojiStore from 'stores/emoji_store.jsx';
|
||||
import * as Emoticons from 'utils/emoticons.jsx';
|
||||
|
||||
describe('Emoticons', () => {
|
||||
describe('handleEmoticons', () => {
|
||||
const emojis = EmojiStore.getEmojis();
|
||||
|
||||
test('should replace emoticons with tokens', () => {
|
||||
expect(Emoticons.handleEmoticons(':goat: :dash:', new Map(), emojis)).
|
||||
toEqual('$MM_EMOTICON0 $MM_EMOTICON1');
|
||||
});
|
||||
|
||||
test('should replace emoticons not separated by whitespace', () => {
|
||||
expect(Emoticons.handleEmoticons(':goat::dash:', new Map(), emojis)).
|
||||
toEqual('$MM_EMOTICON0$MM_EMOTICON1');
|
||||
});
|
||||
|
||||
test('should replace emoticons separated by punctuation', () => {
|
||||
expect(Emoticons.handleEmoticons('/:goat:..:dash:)', new Map(), emojis)).
|
||||
toEqual('/$MM_EMOTICON0..$MM_EMOTICON1)');
|
||||
});
|
||||
|
||||
test('should replace emoticons separated by text', () => {
|
||||
expect(Emoticons.handleEmoticons('asdf:goat:asdf:dash:asdf', new Map(), emojis)).
|
||||
toEqual('asdf$MM_EMOTICON0asdf$MM_EMOTICON1asdf');
|
||||
});
|
||||
|
||||
test('shouldn\'t replace invalid emoticons', () => {
|
||||
expect(Emoticons.handleEmoticons(':asdf: :goat : : dash:', new Map(), emojis)).
|
||||
toEqual(':asdf: :goat : : dash:');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -6,8 +6,6 @@ import assert from 'assert';
|
||||
import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||
|
||||
describe('TextFormatting.AtMentions', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('At mentions', function() {
|
||||
assert.equal(
|
||||
TextFormatting.autolinkAtMentions('@user', new Map(), {user: {}}),
|
||||
@@ -6,8 +6,6 @@ import assert from 'assert';
|
||||
import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||
|
||||
describe('TextFormatting.Hashtags', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('Not hashtags', function(done) {
|
||||
assert.equal(
|
||||
TextFormatting.formatText('# hashtag').trim(),
|
||||
@@ -6,8 +6,6 @@ import assert from 'assert';
|
||||
import * as Markdown from 'utils/markdown.jsx';
|
||||
|
||||
describe('Markdown.Imgs', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('Inline mage', function(done) {
|
||||
assert.equal(
|
||||
Markdown.format('').trim(),
|
||||
@@ -7,8 +7,6 @@ import * as Markdown from 'utils/markdown.jsx';
|
||||
import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||
|
||||
describe('Markdown.Links', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('Not links', function(done) {
|
||||
assert.equal(
|
||||
Markdown.format('example.com').trim(),
|
||||
@@ -1,9 +1,7 @@
|
||||
import assert from 'assert';
|
||||
import * as CommonUtils from 'utils/commons.jsx';
|
||||
|
||||
describe('CommonUtils.getNearestPoint', function() {
|
||||
this.timeout(10000);
|
||||
it('should return nearest point', function() {
|
||||
test('should return nearest point', function() {
|
||||
for (const data of [
|
||||
{
|
||||
points: [{x: 30, y: 40}, {x: 50, y: 50}, {x: 100, y: 2}, {x: 500, y: 200}, {x: 110, y: 20}, {x: 10, y: 20}],
|
||||
@@ -26,8 +24,8 @@ describe('CommonUtils.getNearestPoint', function() {
|
||||
]) {
|
||||
const nearestPoint = CommonUtils.getNearestPoint(data.pivotPoint, data.points);
|
||||
|
||||
assert.equal(nearestPoint.x, data.nearestPoint.x);
|
||||
assert.equal(nearestPoint.y, data.nearestPoint.y);
|
||||
expect(nearestPoint.x).toEqual(data.nearestPoint.x);
|
||||
expect(nearestPoint.y).toEqual(data.nearestPoint.y);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user