2017-08-01 05:08:09 -04:00
|
|
|
import Vue from 'vue';
|
2017-08-30 01:52:29 -04:00
|
|
|
import identiconComponent from '~/vue_shared/components/identicon.vue';
|
2017-08-01 05:08:09 -04:00
|
|
|
|
2017-09-04 11:42:27 -04:00
|
|
|
const createComponent = (sizeClass) => {
|
2017-08-30 01:52:29 -04:00
|
|
|
const Component = Vue.extend(identiconComponent);
|
2017-08-01 05:08:09 -04:00
|
|
|
|
|
|
|
return new Component({
|
|
|
|
propsData: {
|
2017-08-30 01:52:29 -04:00
|
|
|
entityId: 1,
|
|
|
|
entityName: 'entity-name',
|
2017-09-04 11:42:27 -04:00
|
|
|
sizeClass,
|
2017-08-01 05:08:09 -04:00
|
|
|
},
|
2017-08-02 05:15:30 -04:00
|
|
|
}).$mount();
|
2017-08-01 05:08:09 -04:00
|
|
|
};
|
|
|
|
|
2017-08-30 01:52:29 -04:00
|
|
|
describe('IdenticonComponent', () => {
|
2017-09-04 11:42:27 -04:00
|
|
|
describe('computed', () => {
|
|
|
|
let vm;
|
2017-08-01 05:08:09 -04:00
|
|
|
|
2017-09-04 11:42:27 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
vm = createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
2017-08-01 05:08:09 -04:00
|
|
|
|
|
|
|
describe('identiconStyles', () => {
|
|
|
|
it('should return styles attribute value with `background-color` property', () => {
|
|
|
|
vm.entityId = 4;
|
|
|
|
|
|
|
|
expect(vm.identiconStyles).toBeDefined();
|
|
|
|
expect(vm.identiconStyles.indexOf('background-color: #E0F2F1;') > -1).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return styles attribute value with `color` property', () => {
|
|
|
|
vm.entityId = 4;
|
|
|
|
|
|
|
|
expect(vm.identiconStyles).toBeDefined();
|
|
|
|
expect(vm.identiconStyles.indexOf('color: #555;') > -1).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('identiconTitle', () => {
|
|
|
|
it('should return first letter of entity title in uppercase', () => {
|
|
|
|
vm.entityName = 'dummy-group';
|
|
|
|
|
|
|
|
expect(vm.identiconTitle).toBeDefined();
|
|
|
|
expect(vm.identiconTitle).toBe('D');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('template', () => {
|
|
|
|
it('should render identicon', () => {
|
2017-09-04 11:42:27 -04:00
|
|
|
const vm = createComponent();
|
|
|
|
|
2017-08-02 05:15:30 -04:00
|
|
|
expect(vm.$el.nodeName).toBe('DIV');
|
|
|
|
expect(vm.$el.classList.contains('identicon')).toBeTruthy();
|
2017-09-04 11:42:27 -04:00
|
|
|
expect(vm.$el.classList.contains('s40')).toBeTruthy();
|
2017-08-02 05:15:30 -04:00
|
|
|
expect(vm.$el.getAttribute('style').indexOf('background-color') > -1).toBeTruthy();
|
2017-09-04 11:42:27 -04:00
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render identicon with provided sizing class', () => {
|
|
|
|
const vm = createComponent('s32');
|
|
|
|
|
|
|
|
expect(vm.$el.classList.contains('s32')).toBeTruthy();
|
|
|
|
vm.$destroy();
|
2017-08-01 05:08:09 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|