diff options
author | George Goldberg <george@gberg.me> | 2017-03-23 18:05:36 +0000 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-03-23 14:05:36 -0400 |
commit | 7d449e05562c76bb430efc1c36bd715675a84152 (patch) | |
tree | b6d5bbd143fbd31483c9c931b5031aec280ace2d /webapp/tests/client_channel.test.jsx | |
parent | c6ded1dbfd69a1da69add8d2b554f4b7dd0341b3 (diff) | |
download | chat-7d449e05562c76bb430efc1c36bd715675a84152.tar.gz chat-7d449e05562c76bb430efc1c36bd715675a84152.tar.bz2 chat-7d449e05562c76bb430efc1c36bd715675a84152.zip |
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.
Diffstat (limited to 'webapp/tests/client_channel.test.jsx')
-rw-r--r-- | webapp/tests/client_channel.test.jsx | 491 |
1 files changed, 0 insertions, 491 deletions
diff --git a/webapp/tests/client_channel.test.jsx b/webapp/tests/client_channel.test.jsx deleted file mode 100644 index e1ee6cf6d..000000000 --- a/webapp/tests/client_channel.test.jsx +++ /dev/null @@ -1,491 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import assert from 'assert'; -import TestHelper from './test_helper.jsx'; - -describe('Client.Channels', function() { - this.timeout(100000); - - it('createChannel', function(done) { - TestHelper.initBasic(() => { - 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); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('createDirectChannel', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().createUser( - TestHelper.fakeUser(), - function(user2) { - TestHelper.basicClient().createDirectChannel( - user2.id, - function(data) { - assert.equal(data.id.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('createGroupChannel', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().createUser( - TestHelper.fakeUser(), - (user1) => { - TestHelper.basicClient().createUser( - TestHelper.fakeUser(), - function(user2) { - TestHelper.basicClient().createGroupChannel( - [user2.id, user1.id], - function(data) { - assert.equal(data.id.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('updateChannel', function(done) { - TestHelper.initBasic(() => { - 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'); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('updateChannelHeader', function(done) { - TestHelper.initBasic(() => { - 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'); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('updateChannelPurpose', function(done) { - TestHelper.initBasic(() => { - 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'); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('updateChannelNotifyProps', function(done) { - TestHelper.initBasic(() => { - var props = {}; - props.channel_id = TestHelper.basicChannel().id; - props.user_id = TestHelper.basicUser().id; - props.desktop = 'all'; - TestHelper.basicClient().updateChannelNotifyProps( - props, - function(data) { - assert.equal(data.desktop, 'all'); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('leaveChannel', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().leaveChannel( - channel.id, - function(data) { - assert.equal(data.id, channel.id); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('joinChannel', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().leaveChannel( - channel.id, - function() { - TestHelper.basicClient().joinChannel( - channel.id, - function() { - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('joinChannelByName', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().leaveChannel( - channel.id, - function() { - TestHelper.basicClient().joinChannelByName( - channel.name, - function() { - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('deleteChannel', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().deleteChannel( - channel.id, - function(data) { - assert.equal(data.id, channel.id); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('viewChannel', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().viewChannel( - channel.id, - '', - 0, - function() { - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('updateLastViewedAt', function(done) { - TestHelper.initBasic(() => { - var channel = TestHelper.basicChannel(); - TestHelper.basicClient().updateLastViewedAt( - channel.id, - true, - function(data) { - assert.equal(data.id, channel.id); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannels', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getChannels( - function(data) { - assert.equal(data.length, 3); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannel', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getChannel( - TestHelper.basicChannel().id, - function(data) { - assert.equal(TestHelper.basicChannel().id, data.channel.id); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getMoreChannels', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getMoreChannels( - function(data) { - assert.equal(data.length, 0); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getMoreChannelsPage', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getMoreChannelsPage( - 0, - 100, - function(data) { - assert.equal(data.length, 0); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('searchMoreChannels', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().searchMoreChannels( - 'blargh', - function(data) { - assert.equal(data.length, 0); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('autocompleteChannels', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().autocompleteChannels( - TestHelper.basicChannel().name, - function(data) { - assert.equal(data != null, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannelCounts', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getChannelCounts( - function(data) { - assert.equal(data.counts[TestHelper.basicChannel().id], 1); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getMyChannelMembers', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getMyChannelMembers( - function(data) { - assert.equal(data.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getMyChannelMembersForTeam', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getMyChannelMembersForTeam( - TestHelper.basicTeam().id, - function(data) { - assert.equal(data.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannelStats', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getChannelStats( - TestHelper.basicChannel().id, - function(data) { - assert.equal(data.member_count, 1); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannelMember', function(done) { - TestHelper.initBasic(() => { - 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); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('addChannelMember', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().createUserWithInvite( - TestHelper.fakeUser(), - null, - null, - TestHelper.basicTeam().invite_id, - function(user2) { - TestHelper.basicClient().addChannelMember( - TestHelper.basicChannel().id, - user2.id, - function(data) { - assert.equal(data.channel_id.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('removeChannelMember', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().removeChannelMember( - TestHelper.basicChannel().id, - TestHelper.basicUser().id, - function(data) { - assert.equal(data.channel_id.length > 0, true); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); - - it('getChannelByName', function(done) { - TestHelper.initBasic(() => { - TestHelper.basicClient().getChannelByName( - TestHelper.basicChannel().name, - function(data) { - assert.equal(data.name, TestHelper.basicChannel().name); - done(); - }, - function(err) { - done(new Error(err.message)); - } - ); - }); - }); -}); - |