提交 5eae75a0 编写于 作者: J Joao Moreno

list: more tests

上级 f7f2e31a
......@@ -11,7 +11,17 @@
require(['vs/base/browser/ui/list/listTest'], function (test) {
test.setupList(document.getElementById('list'));
document.getElementById('list-add').onclick = test.addPersonToList;
document.getElementById('list-add').onclick = function () {
test.addPersonToList(
document.getElementById('list-name').value,
document.getElementById('list-index').value
);
};
document.getElementById('list-remove').onclick = function () {
test.removePersonFromList(
document.getElementById('list-index').value
);
};
document.getElementById('list-addmany').onclick = test.addManyPeopleToList;
document.getElementById('list-addmanyreal').onclick = test.addManyRealPeopleToList;
document.getElementById('list-addmanyboring').onclick = test.addManyBoringPeopleToList;
......@@ -34,7 +44,10 @@
<body>
<div>
<div>
<input id="list-name" placeholder="name"></input>
<input id="list-index" placeholder="index"></input>
<button id="list-add">Add Person</button>
<button id="list-remove">Remove Person</button>
<button id="list-addmany">Add Many People</button>
<button id="list-addmanyreal">Add Many Real People</button>
<button id="list-addmanyboring">Add Many Boring People</button>
......
......@@ -70,10 +70,25 @@ export function setupList(container: HTMLElement) {
list = new List(container, new Delegate(), { person: renderer });
}
export function addPersonToList() {
const person = generatePerson();
export function addPersonToList(name, index) {
const person = name
? { name, height: 24 }
: {
name: new Array(16).join().replace(/(.|$)/g, function(){return ((Math.random()*36)|0).toString(36);}),
height: 24
};
index = Number(index);
index = index === NaN ? list.length : Math.min(index, list.length);
list.splice(list.length, 0, person);
list.splice(index, 0, person);
}
export function removePersonFromList(index) {
index = Number(index);
index = index === NaN ? list.length : Math.min(index, list.length - 1);
list.splice(index, 1);
}
export function addManyPeopleToList() {
......@@ -129,7 +144,7 @@ export function setupTree(container: HTMLElement) {
}
export function addPersonToTree() {
treeModel.push(generatePerson());
treeModel.unshift(generatePerson());
tree.refresh();
}
......@@ -162,6 +177,6 @@ export function addManyBoringPeopleToTree() {
people.push(generateBoringPerson());
}
treeModel.push(...people);
treeModel.unshift(...people);
tree.refresh();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册