From 7d449e05562c76bb430efc1c36bd715675a84152 Mon Sep 17 00:00:00 2001
From: George Goldberg <george@gberg.me>
Date: Thu, 23 Mar 2017 18:05:36 +0000
Subject: 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.
---
 webapp/tests/client_team.test.jsx | 313 --------------------------------------
 1 file changed, 313 deletions(-)
 delete mode 100644 webapp/tests/client_team.test.jsx

(limited to 'webapp/tests/client_team.test.jsx')

diff --git a/webapp/tests/client_team.test.jsx b/webapp/tests/client_team.test.jsx
deleted file mode 100644
index 20610f676..000000000
--- a/webapp/tests/client_team.test.jsx
+++ /dev/null
@@ -1,313 +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.Team', function() {
-    this.timeout(100000);
-
-    it('findTeamByName', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().findTeamByName(
-                TestHelper.basicTeam().name,
-                function(data) {
-                    assert.equal(data, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('createTeam', function(done) {
-        var team = TestHelper.fakeTeam();
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().createTeam(
-                team,
-                function(data) {
-                    assert.equal(data.id.length > 0, true);
-                    assert.equal(data.name, team.name);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getAllTeams', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getAllTeams(
-                function(data) {
-                    assert.equal(data[TestHelper.basicTeam().id].name, TestHelper.basicTeam().name);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getAllTeamListings', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getAllTeamListings(
-                function(data) {
-                    assert.equal(data != null, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getMyTeam', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getMyTeam(
-                function(data) {
-                    assert.equal(data.name, TestHelper.basicTeam().name);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getMyTeamMembers', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getMyTeamMembers(
-                function(data) {
-                    assert.equal(data.length > 0, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getTeamMembers', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getTeamMembers(
-                TestHelper.basicTeam().id,
-                0,
-                100,
-                function(data) {
-                    assert.equal(data.length > 0, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getTeamMember', function(done) {
-        TestHelper.initBasic(() => {
-            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);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getTeamStats', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getTeamStats(
-                TestHelper.basicTeam().id,
-                function(data) {
-                    assert.equal(data.total_member_count > 0, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getTeamMembersByIds', function(done) {
-        TestHelper.initBasic(() => {
-            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);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('inviteMembers', function(done) {
-        TestHelper.initBasic(() => {
-            var data = {};
-            data.invites = [];
-            var invite = {};
-            invite.email = TestHelper.fakeEmail();
-            invite.firstName = 'first';
-            invite.lastName = 'last';
-            data.invites.push(invite);
-
-            TestHelper.basicClient().inviteMembers(
-                data,
-                function(dataBack) {
-                    assert.equal(dataBack.invites.length, 1);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('updateTeam', function(done) {
-        TestHelper.initBasic(() => {
-            var team = TestHelper.basicTeam();
-            team.display_name = 'test_updated';
-
-            TestHelper.basicClient().updateTeam(
-                team,
-                function(data) {
-                    assert.equal(data.display_name, 'test_updated');
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('updateTeamDescription', function(done) {
-        TestHelper.initBasic(() => {
-            var team = TestHelper.basicTeam();
-            team.description = 'test_updated';
-
-            TestHelper.basicClient().updateTeam(
-                team,
-                function(data) {
-                    assert.equal(data.description, 'test_updated');
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('addUserToTeam', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().createUser(
-                TestHelper.fakeUser(),
-                function(user2) {
-                    TestHelper.basicClient().addUserToTeam(
-                        '',
-                        user2.id,
-                        function(data) {
-                            assert.equal(data.user_id, user2.id);
-                            done();
-                        },
-                        function(err) {
-                            done(new Error(err.message));
-                        }
-                    );
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('removeUserFromTeam', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().removeUserFromTeam(
-                '',
-                TestHelper.basicUser().id,
-                function(data) {
-                    assert.equal(data.user_id, TestHelper.basicUser().id);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getInviteInfo', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getInviteInfo(
-                TestHelper.basicTeam().invite_id,
-                function(data) {
-                    assert.equal(data.display_name.length > 0, true);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('updateTeamMemberRoles', function(done) {
-        TestHelper.initBasic(() => {
-            var user = TestHelper.basicUser();
-            var team = TestHelper.basicTeam();
-
-            TestHelper.basicClient().updateTeamMemberRoles(
-                team.id,
-                user.id,
-                '',
-                function() {
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-
-    it('getTeamByName', function(done) {
-        TestHelper.initBasic(() => {
-            TestHelper.basicClient().getTeamByName(
-                TestHelper.basicTeam().name,
-                function(data) {
-                    console.log(data);
-                    assert.equal(data.name, TestHelper.basicTeam().name);
-                    done();
-                },
-                function(err) {
-                    done(new Error(err.message));
-                }
-            );
-        });
-    });
-});
-
-- 
cgit v1.2.3-1-g7c22

