|
|
@ -1,30 +1,29 @@ |
|
|
import PropertySelectView from 'style_manager/view/PropertySelectView'; |
|
|
import PropertySelectView from '../../../../src/style_manager/view/PropertySelectView'; |
|
|
import Property from 'style_manager/model/PropertyRadio'; |
|
|
import Property from '../../../../src/style_manager/model/PropertyRadio'; |
|
|
import Editor from 'editor/model/Editor'; |
|
|
import Editor from '../../../../src/editor/model/Editor'; |
|
|
import DomComponents from 'dom_components'; |
|
|
import DomComponents from '../../../../src/dom_components'; |
|
|
import Component from 'dom_components/model/Component'; |
|
|
import Component from '../../../../src/dom_components/model/Component'; |
|
|
|
|
|
|
|
|
describe('PropertySelectView', () => { |
|
|
describe('PropertySelectView', () => { |
|
|
let em; |
|
|
let em: Editor; |
|
|
let dcomp; |
|
|
let dcomp: Editor['Components']; |
|
|
let compOpts; |
|
|
let compOpts: any; |
|
|
var component; |
|
|
let component: Component; |
|
|
var fixtures; |
|
|
let fixtures: HTMLElement; |
|
|
var target; |
|
|
let target: Component; |
|
|
var model; |
|
|
let model: Property; |
|
|
var view; |
|
|
let view: PropertySelectView; |
|
|
var options; |
|
|
const propName = 'testprop'; |
|
|
var propName = 'testprop'; |
|
|
const propValue = 'test1value'; |
|
|
var propValue = 'test1value'; |
|
|
const defValue = 'test2value'; |
|
|
var defValue = 'test2value'; |
|
|
let options: any = [ |
|
|
var options = [ |
|
|
{ id: 'test1value', style: 'test:style' }, |
|
|
{ value: 'test1value', style: 'test:style' }, |
|
|
{ id: 'test2', value: 'test2value' }, |
|
|
{ name: 'test2', value: 'test2value' }, |
|
|
|
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
beforeEach(() => { |
|
|
em = new Editor({}); |
|
|
em = new Editor({}); |
|
|
dcomp = new DomComponents(em); |
|
|
dcomp = em.Components; |
|
|
compOpts = { em, componentTypes: dcomp.componentTypes }; |
|
|
compOpts = { em, componentTypes: dcomp.componentTypes }; |
|
|
target = new Component({}, compOpts); |
|
|
target = new Component({}, compOpts); |
|
|
component = new Component({}, compOpts); |
|
|
component = new Component({}, compOpts); |
|
|
@ -38,43 +37,39 @@ describe('PropertySelectView', () => { |
|
|
); |
|
|
); |
|
|
view = new PropertySelectView({ model }); |
|
|
view = new PropertySelectView({ model }); |
|
|
document.body.innerHTML = '<div id="fixtures"></div>'; |
|
|
document.body.innerHTML = '<div id="fixtures"></div>'; |
|
|
fixtures = document.body.firstChild; |
|
|
fixtures = document.body.firstChild as HTMLElement; |
|
|
view.render(); |
|
|
view.render(); |
|
|
fixtures.appendChild(view.el); |
|
|
fixtures.appendChild(view.el); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
afterEach(() => { |
|
|
afterEach(() => { |
|
|
//view.remove(); // strange errors ???
|
|
|
em.destroy(); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
afterAll(() => { |
|
|
|
|
|
component = null; |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('Rendered correctly', () => { |
|
|
test('Rendered correctly', () => { |
|
|
var prop = view.el; |
|
|
const prop = view.el; |
|
|
expect(fixtures.querySelector('.property')).toBeTruthy(); |
|
|
expect(fixtures.querySelector('.property')).toBeTruthy(); |
|
|
expect(prop.querySelector('.label')).toBeTruthy(); |
|
|
expect(prop.querySelector('.label')).toBeTruthy(); |
|
|
expect(prop.querySelector('.field')).toBeTruthy(); |
|
|
expect(prop.querySelector('.field')).toBeTruthy(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('Select rendered', () => { |
|
|
test('Select rendered', () => { |
|
|
var prop = view.el; |
|
|
const prop = view.el; |
|
|
expect(prop.querySelector('select')).toBeTruthy(); |
|
|
expect(prop.querySelector('select')).toBeTruthy(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('Options rendered', () => { |
|
|
test('Options rendered', () => { |
|
|
var select = view.el.querySelector('select'); |
|
|
const select = view.el.querySelector('select')!; |
|
|
expect(select.children.length).toEqual(options.length); |
|
|
expect(select.children.length).toEqual(options.length); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('Options rendered correctly', () => { |
|
|
test('Options rendered correctly', () => { |
|
|
var select = view.el.querySelector('select'); |
|
|
const select = view.el.querySelector('select')!; |
|
|
var children = select.children; |
|
|
const children = select.children; |
|
|
expect(children[0].value).toEqual(options[0].value); |
|
|
expect((children[0] as any).value).toEqual(options[0].id); |
|
|
expect(children[1].value).toEqual(options[1].value); |
|
|
expect((children[1] as any).value).toEqual(options[1].id); |
|
|
expect(children[0].textContent).toEqual(options[0].value); |
|
|
expect(children[0].textContent).toEqual(options[0].id); |
|
|
expect(children[1].textContent).toEqual(options[1].name); |
|
|
expect(children[1].textContent).toEqual(options[1].id); |
|
|
expect(children[0].getAttribute('style')).toEqual(options[0].style); |
|
|
expect(children[0].getAttribute('style')).toEqual(options[0].style); |
|
|
expect(children[1].getAttribute('style')).toEqual(null); |
|
|
expect(children[1].getAttribute('style')).toEqual(null); |
|
|
}); |
|
|
}); |
|
|
@ -106,7 +101,7 @@ describe('PropertySelectView', () => { |
|
|
|
|
|
|
|
|
describe('Init property', () => { |
|
|
describe('Init property', () => { |
|
|
beforeEach(() => { |
|
|
beforeEach(() => { |
|
|
component = new Component(); |
|
|
component = new Component({}, compOpts); |
|
|
model = new Property({ |
|
|
model = new Property({ |
|
|
type: 'select', |
|
|
type: 'select', |
|
|
list: options, |
|
|
list: options, |
|
|
@ -132,7 +127,7 @@ describe('PropertySelectView', () => { |
|
|
{ value: 'test2value', name: 'test2' }, |
|
|
{ value: 'test2value', name: 'test2' }, |
|
|
{ value: '', name: 'TestDef' }, |
|
|
{ value: '', name: 'TestDef' }, |
|
|
]; |
|
|
]; |
|
|
component = new Component(); |
|
|
component = new Component({}, compOpts); |
|
|
model = new Property({ |
|
|
model = new Property({ |
|
|
type: 'select', |
|
|
type: 'select', |
|
|
list: options, |
|
|
list: options, |