diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2017-05-22 18:20:15 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-05-22 18:20:15 -0500 |
commit | 1f0a785db8da867a1a4070e96f7807be92bff262 (patch) | |
tree | 32b1be37a8720f53f42a2856f47522ca757a0df5 /spec | |
parent | a5a7b574df131897e87404c8ef5059821984f81f (diff) | |
download | gitlab-ce-1f0a785db8da867a1a4070e96f7807be92bff262.tar.gz |
Add basic tests for groups component
[ci skip]
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/groups/groups_spec.js | 38 | ||||
-rw-r--r-- | spec/javascripts/groups/mock_data.js | 40 |
2 files changed, 78 insertions, 0 deletions
diff --git a/spec/javascripts/groups/groups_spec.js b/spec/javascripts/groups/groups_spec.js new file mode 100644 index 00000000000..1427095f21a --- /dev/null +++ b/spec/javascripts/groups/groups_spec.js @@ -0,0 +1,38 @@ +import Vue from 'vue'; +import GroupFolder from '~/groups/components/group_folder.vue'; +import GroupItem from '~/groups/components/group_item.vue'; +import groupsComponent from '~/groups/components/groups.vue'; +import GroupsStore from '~/groups/stores/groups_store'; +import groupsData from './mock_data'; + +describe('Groups', () => { + let GroupsComponent; + let store; + + beforeEach(() => { + Vue.component('group-folder', GroupFolder); + Vue.component('group-item', GroupItem); + + store = new GroupsStore(); + store.setGroups(groupsData.groups); + store.storePagination(groupsData.pagination); + + GroupsComponent = Vue.extend(groupsComponent); + }); + + describe('with data', () => { + it('should render a list of groups', (done) => { + const component = new GroupsComponent({ + propsData: { + groups: store.state.groups, + pageInfo: store.state.pageInfo, + }, + }).$mount(); + + setTimeout(() => { + expect(component.$el.classList.contains('groups-list-tree-container')).toBe(true); + done(); + }); + }); + }); +}); diff --git a/spec/javascripts/groups/mock_data.js b/spec/javascripts/groups/mock_data.js new file mode 100644 index 00000000000..14fe9ef71d0 --- /dev/null +++ b/spec/javascripts/groups/mock_data.js @@ -0,0 +1,40 @@ +export default { + groups: [{ + id: '12', + name: 'level1', + path: 'level1', + description: '', + visibility: 'public', + avatar_url: null, + web_url: 'http://localhost:3000/groups/level1', + full_name: 'level1', + full_path: 'level1', + parent_id: null, + created_at: '2017-05-15T19:01:23.670Z', + updated_at: '2017-05-15T19:01:23.670Z', + permissions: { + group_access: 50, + }, + }, + ], + pagination: { + Date: 'Mon, 22 May 2017 22:31:52 GMT', + 'X-Prev-Page': '1', + 'X-Content-Type-Options': 'nosniff', + 'X-Total': '31', + 'Transfer-Encoding': 'chunked', + 'X-Runtime': '0.611144', + 'X-Xss-Protection': '1; mode=block', + 'X-Request-Id': 'f5db8368-3ce5-4aa4-89d2-a125d9dead09', + 'X-Ua-Compatible': 'IE=edge', + 'X-Per-Page': '20', + Link: '<http://localhost:3000/dashboard/groups.json?page=1&per_page=20>; rel="prev", <http://localhost:3000/dashboard/groups.json?page=1&per_page=20>; rel="first", <http://localhost:3000/dashboard/groups.json?page=2&per_page=20>; rel="last"', + 'X-Next-Page': '', + Etag: 'W/"a82f846947136271cdb7d55d19ef33d2"', + 'X-Frame-Options': 'DENY', + 'Content-Type': 'application/json; charset=utf-8', + 'Cache-Control': 'max-age=0, private, must-revalidate', + 'X-Total-Pages': '2', + 'X-Page': '2', + }, +}; |