summaryrefslogtreecommitdiffstats
path: root/webapp/tests/client_general.test.jsx
blob: 61e7832dab902fc417b8eae2ccfa898ad3869283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 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.General', function() {
    this.timeout(10000);

    it('General.getClientConfig', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().getClientConfig(
                function(data) {
                    assert.equal(data.SiteName, 'Mattermost');
                    done();
                },
                function(err) {
                    done(new Error(err.message));
                }
            );
        });
    });

    it('General.getPing', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().getPing(
                function(data) {
                    assert.equal(data.version.length > 0, true);
                    done();
                },
                function(err) {
                    done(new Error(err.message));
                }
            );
        });
    });

    it('General.logClientError', function(done) {
        TestHelper.initBasic(() => {
            var config = {};
            config.site_name = 'test';
            TestHelper.basicClient().logClientError('this is a test');
            done();
        });
    });

    it('File.getFileInfo', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error

            TestHelper.basicClient().getFileInfo(
                `/${TestHelper.basicChannel().id}/${TestHelper.basicUser().id}/filename.txt`,
                function(data) {
                    assert.equal(data.filename, 'filename.txt');
                    done();
                },
                function(err) {
                    done(new Error(err.message));
                }
            );
        });
    });

    it('File.getPublicLink', function(done) {
        TestHelper.initBasic(() => {
            TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
            var data = {};
            data.channel_id = TestHelper.basicChannel().id;
            data.user_id = TestHelper.basicUser().id;
            data.filename = `/${TestHelper.basicChannel().id}/${TestHelper.basicUser().id}/filename.txt`;

            TestHelper.basicClient().getPublicLink(
                data,
                function() {
                    done(new Error('not enabled'));
                },
                function(err) {
                    assert.equal(err.id, 'api.file.get_public_link.disabled.app_error');
                    done();
                }
            );
        });
    });
});