mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Getting TreeDropdownField.js javascript tests to work with async jstree events
This commit is contained in:
parent
89a0b1b281
commit
4591503da6
@ -209,8 +209,8 @@
|
|||||||
this._super($.isArray(val) ? val.join(',') : val);
|
this._super($.isArray(val) ? val.join(',') : val);
|
||||||
},
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
this._super($.isArray(title) : title.join(', ') : val);
|
this._super($.isArray(title) ? title.join(', ') : title);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -115,11 +115,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when field allows multiple selections', function() {
|
describe('when field allows multiple selections', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// load fixture
|
// load fixture (check one child node, one root node)
|
||||||
$('body').append(
|
$('body').append(
|
||||||
'<div id="testfield" class="TreeDropdownField multiple" href="/myurl" data-title="Root Node 1,Child Node 1">' +
|
'<div id="testfield" class="TreeDropdownField multiple" href="/myurl" data-title="Root Node 2,Root Node 3">' +
|
||||||
'<input type="hidden" name="testfield" value="1,2" />' +
|
'<input type="hidden" name="testfield" value="4,5" />' +
|
||||||
'</div>'
|
'</div>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -129,6 +130,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when more than one item is selected', function() {
|
describe('when more than one item is selected', function() {
|
||||||
|
|
||||||
it('doesnt close the panel', function() {
|
it('doesnt close the panel', function() {
|
||||||
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
||||||
loadTree(f);
|
loadTree(f);
|
||||||
@ -141,32 +143,41 @@
|
|||||||
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
||||||
loadTree(f);
|
loadTree(f);
|
||||||
f.entwine('ss').openPanel();
|
f.entwine('ss').openPanel();
|
||||||
expect(f.entwine('ss').getValue()).toEqual(['1','2']);
|
expect(f.entwine('ss').getValue()).toEqual(['4','5']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('it sets the selected values on the input field', function() {
|
it('it sets the selected values on the input field', function() {
|
||||||
// var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
||||||
// loadTree(f);
|
loadTree(f);
|
||||||
// f.entwine('ss').openPanel();
|
f.entwine('ss').openPanel();
|
||||||
// panel.find('li[data-id=2] a').click();
|
|
||||||
// panel.find('li[data-id=3] a').click();
|
// TODO loaded.jstree event works with timeouts, so we have to wait before inspection
|
||||||
// // '1' and '2' were preselected
|
waits(200);
|
||||||
// expect(f.entwine('ss').getValue()).toEqual(['1','2','3']);
|
runs(function() {
|
||||||
//
|
panel.find('li[data-id=6] a').click();
|
||||||
// // Selecting an checked node will remove it from selection
|
// '4' and '5' were preselected
|
||||||
// panel.find('li[data-id=2] a').click();
|
expect(f.entwine('ss').getValue()).toEqual(['4','5','6']);
|
||||||
// expect(f.entwine('ss').getValue()).toEqual(['1','3']);
|
|
||||||
// });
|
// Selecting an checked node will remove it from selection
|
||||||
//
|
panel.find('li[data-id=4] a').click();
|
||||||
// it('it sets the selected titles', function() {
|
expect(f.entwine('ss').getValue()).toEqual(['5','6']);
|
||||||
// var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
});
|
||||||
// loadTree(f);
|
|
||||||
// panel.find('li[data-id=2] a').click();
|
});
|
||||||
// panel.find('li[data-id=3] a').click();
|
|
||||||
// expect(f.entwine('ss').getTitle()).toEqual('Child node 1, Child node 2');
|
it('it sets the selected titles', function() {
|
||||||
// });
|
var f = $('#testfield'), panel = f.entwine('ss').getPanel();
|
||||||
|
loadTree(f);
|
||||||
|
|
||||||
|
// TODO loaded.jstree event works with timeouts, so we have to wait before inspection
|
||||||
|
waits(200);
|
||||||
|
runs(function() {
|
||||||
|
panel.find('li[data-id=6] a').click();
|
||||||
|
expect(f.entwine('ss').getTitle()).toEqual('Root node 2, Root node 3, Root node 4');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -13,4 +13,10 @@
|
|||||||
<li data-id="4">
|
<li data-id="4">
|
||||||
<a href="#">Root node 2</a>
|
<a href="#">Root node 2</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li data-id="5">
|
||||||
|
<a href="#">Root node 3</a>
|
||||||
|
</li>
|
||||||
|
<li data-id="6">
|
||||||
|
<a href="#">Root node 4</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
Loading…
x
Reference in New Issue
Block a user