2017-05-25 20:49:46 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import groupItemComponent from '~/groups/components/group_item.vue';
|
|
|
|
import GroupsStore from '~/groups/stores/groups_store';
|
|
|
|
import { group1 } from './mock_data';
|
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
describe('Groups Component', () => {
|
2017-05-25 20:49:46 -04:00
|
|
|
let GroupItemComponent;
|
|
|
|
let component;
|
2017-06-01 14:40:22 -04:00
|
|
|
let store;
|
2017-05-25 20:49:46 -04:00
|
|
|
let group;
|
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
describe('group with default data', () => {
|
|
|
|
beforeEach((done) => {
|
|
|
|
GroupItemComponent = Vue.extend(groupItemComponent);
|
|
|
|
store = new GroupsStore();
|
|
|
|
group = store.decorateGroup(group1);
|
2017-05-25 20:49:46 -04:00
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
component = new GroupItemComponent({
|
|
|
|
propsData: {
|
|
|
|
group,
|
|
|
|
},
|
|
|
|
}).$mount();
|
2017-05-25 20:49:46 -04:00
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
Vue.nextTick(() => {
|
|
|
|
done();
|
|
|
|
});
|
2017-05-25 20:49:46 -04:00
|
|
|
});
|
|
|
|
|
2017-06-07 11:05:17 -04:00
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
it('should render the group item correctly', () => {
|
|
|
|
expect(component.$el.classList.contains('group-row')).toBe(true);
|
|
|
|
expect(component.$el.classList.contains('.no-description')).toBe(false);
|
|
|
|
expect(component.$el.querySelector('.number-projects').textContent).toContain(group.numberProjects);
|
|
|
|
expect(component.$el.querySelector('.number-users').textContent).toContain(group.numberUsers);
|
|
|
|
expect(component.$el.querySelector('.group-visibility')).toBeDefined();
|
|
|
|
expect(component.$el.querySelector('.avatar-container')).toBeDefined();
|
|
|
|
expect(component.$el.querySelector('.title').textContent).toContain(group.name);
|
2017-06-08 00:00:03 -04:00
|
|
|
expect(component.$el.querySelector('.access-type').textContent).toContain(group.permissions.humanGroupAccess);
|
2017-06-07 04:45:48 -04:00
|
|
|
expect(component.$el.querySelector('.description').textContent).toContain(group.description);
|
|
|
|
expect(component.$el.querySelector('.edit-group')).toBeDefined();
|
|
|
|
expect(component.$el.querySelector('.leave-group')).toBeDefined();
|
|
|
|
});
|
2017-05-25 20:49:46 -04:00
|
|
|
});
|
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
describe('group without description', () => {
|
|
|
|
beforeEach((done) => {
|
|
|
|
GroupItemComponent = Vue.extend(groupItemComponent);
|
|
|
|
store = new GroupsStore();
|
|
|
|
group1.description = '';
|
|
|
|
group = store.decorateGroup(group1);
|
|
|
|
|
|
|
|
component = new GroupItemComponent({
|
|
|
|
propsData: {
|
|
|
|
group,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-08 04:45:18 -04:00
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-06-07 04:45:48 -04:00
|
|
|
it('should render group item correctly', () => {
|
|
|
|
expect(component.$el.querySelector('.description').textContent).toBe('');
|
|
|
|
expect(component.$el.classList.contains('.no-description')).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2017-06-08 04:45:18 -04:00
|
|
|
|
|
|
|
describe('user has not access to group', () => {
|
|
|
|
beforeEach((done) => {
|
|
|
|
GroupItemComponent = Vue.extend(groupItemComponent);
|
|
|
|
store = new GroupsStore();
|
|
|
|
group1.permissions.human_group_access = null;
|
|
|
|
group = store.decorateGroup(group1);
|
|
|
|
|
|
|
|
component = new GroupItemComponent({
|
|
|
|
propsData: {
|
|
|
|
group,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not display access type', () => {
|
|
|
|
expect(component.$el.querySelector('.access-type')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
2017-05-25 20:49:46 -04:00
|
|
|
});
|