|
|
|
@ -8,8 +8,7 @@ module.exports = { |
|
|
|
describe('PropertySelectView', () => { |
|
|
|
|
|
|
|
var component; |
|
|
|
var $fixtures; |
|
|
|
var $fixture; |
|
|
|
var fixtures; |
|
|
|
var target; |
|
|
|
var model; |
|
|
|
var view; |
|
|
|
@ -23,11 +22,6 @@ module.exports = { |
|
|
|
{name: 'test2', value: 'test2value'} |
|
|
|
]; |
|
|
|
|
|
|
|
before(() => { |
|
|
|
$fixtures = $("#fixtures"); |
|
|
|
$fixture = $('<div class="sm-fixture"></div>'); |
|
|
|
}); |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
propTarget = Object.assign({}, Backbone.Events); |
|
|
|
target = new Component(); |
|
|
|
@ -42,9 +36,10 @@ module.exports = { |
|
|
|
model, |
|
|
|
propTarget |
|
|
|
}); |
|
|
|
$fixture.empty().appendTo($fixtures); |
|
|
|
document.body.innerHTML = '<div id="fixtures"></div>'; |
|
|
|
fixtures = document.body.firstChild; |
|
|
|
view.render(); |
|
|
|
$fixture.html(view.el); |
|
|
|
fixtures.appendChild(view.el); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
@ -52,13 +47,12 @@ module.exports = { |
|
|
|
}); |
|
|
|
|
|
|
|
after(() => { |
|
|
|
$fixture.remove(); |
|
|
|
component = null; |
|
|
|
}); |
|
|
|
|
|
|
|
it('Rendered correctly', () => { |
|
|
|
var prop = view.el; |
|
|
|
expect($fixture.get(0).querySelector('.property')).toExist(); |
|
|
|
expect(fixtures.querySelector('.property')).toExist(); |
|
|
|
expect(prop.querySelector('.label')).toExist(); |
|
|
|
expect(prop.querySelector('.field')).toExist(); |
|
|
|
}); |
|
|
|
@ -120,9 +114,9 @@ module.exports = { |
|
|
|
model, |
|
|
|
propTarget: target |
|
|
|
}); |
|
|
|
$fixture.empty().appendTo($fixtures); |
|
|
|
fixtures.innerHTML = ''; |
|
|
|
view.render(); |
|
|
|
$fixture.html(view.el); |
|
|
|
fixtures.appendChild(view.el); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Update value and input on target swap', () => { |
|
|
|
@ -161,9 +155,9 @@ module.exports = { |
|
|
|
view = new PropertySelectView({ |
|
|
|
model |
|
|
|
}); |
|
|
|
$fixture.empty().appendTo($fixtures); |
|
|
|
fixtures.innerHTML = ''; |
|
|
|
view.render(); |
|
|
|
$fixture.html(view.el); |
|
|
|
fixtures.appendChild(view.el); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Value as default', () => { |
|
|
|
@ -188,7 +182,8 @@ module.exports = { |
|
|
|
model |
|
|
|
}); |
|
|
|
view.render(); |
|
|
|
$fixture.html(view.el); |
|
|
|
fixtures.innerHTML = ''; |
|
|
|
fixtures.appendChild(view.el); |
|
|
|
expect(view.getInputValue()).toEqual(''); |
|
|
|
}); |
|
|
|
|
|
|
|
|