mattermost-mobile/test/actions/general.test.js
Harrison Healey 45f8a56d15 Fixed unit tests for the other changes I've made recently (#80)
* Removed mocking from client tests

* Updated Client tests to remove Client.setTeamId

* Fixed actions/general.test.js

* Updated test/reducer/channel.test.js for the updated store structure

* Commented out general reducer tests until the store structure is more finalized

* Properly used the team ID when creating a channel
2016-11-22 11:46:50 -05:00

72 lines
2.3 KiB
JavaScript

// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import assert from 'assert';
import * as Actions from 'actions/general.js';
import Client from 'client/client_instance.js';
import configureStore from 'store/configureStore.js';
import TestHelper from 'test_helper.js';
describe('Actions.General', () => {
it('getClientConfig', (done) => {
TestHelper.initBasic(Client).then(() => {
const store = configureStore();
store.subscribe(() => {
const clientConfig = store.getState().entities.general.clientConfig;
if (!clientConfig.loading) {
if (clientConfig.error) {
done(new Error(clientConfig.error));
} else {
// Check a few basic fields since they may change over time
assert.ok(clientConfig.Version);
assert.ok(clientConfig.BuildNumber);
assert.ok(clientConfig.BuildDate);
assert.ok(clientConfig.BuildHash);
done();
}
}
});
Actions.getClientConfig()(store.dispatch, store.getState);
});
});
it('getPing', (done) => {
TestHelper.initBasic(Client).then(() => {
const store = configureStore();
store.subscribe(() => {
const ping = store.getState().entities.general.ping;
if (ping.error) {
done(new Error(ping.error));
} else if (!ping.loading) {
done();
}
});
Actions.getPing()(store.dispatch, store.getState);
});
});
it('getPing - Invalid URL', (done) => {
TestHelper.initBasic(Client).then(() => {
const store = configureStore();
store.subscribe(() => {
const ping = store.getState().entities.general.ping;
if (!ping.loading && ping.error) {
done();
}
});
Client.setUrl('https://example.com/fake/url');
Actions.getPing()(store.dispatch, store.getState);
});
});
});