|
|
@@ -248,6 +248,25 @@ describe('Tree change', () => {
|
|
|
expect(node3).to.have.property('seq', 4);
|
|
|
});
|
|
|
|
|
|
+ it('specialUpMove', () => {
|
|
|
+ const tree = new Tree([
|
|
|
+ { ID: '1', parentID: '-1', seq: 1 },
|
|
|
+ { ID: '2', parentID: '-1', seq: 2 },
|
|
|
+ { ID: '3', parentID: '-1', seq: 2 },
|
|
|
+ { ID: '4', parentID: '-1', seq: 2 },
|
|
|
+ { ID: '5', parentID: '-1', seq: 5 },
|
|
|
+ ]);
|
|
|
+ const nodes = [tree.find('3'), tree.find('4')];
|
|
|
+ const updateData = tree.prepareUpMove(nodes as TreeNode[]);
|
|
|
+ tree.move(nodes as TreeNode[], updateData);
|
|
|
+ const IDList = getIDList(tree.data);
|
|
|
+ expect(IDList).to.have.ordered.members(['1', '3', '4', '2', '5']);
|
|
|
+ expect(nodes[0]).to.have.property('seq', 1);
|
|
|
+ expect(nodes[1]).to.have.property('seq', 2);
|
|
|
+ const node3 = tree.find('1');
|
|
|
+ expect(node3).to.have.property('seq', 0);
|
|
|
+ });
|
|
|
+
|
|
|
it('downMove', () => {
|
|
|
const tree = new Tree(cloneDeep(rawData));
|
|
|
const nodes = [tree.find('3'), tree.find('2')];
|
|
|
@@ -271,6 +290,24 @@ describe('Tree change', () => {
|
|
|
expect(node4).to.have.property('seq', 2);
|
|
|
});
|
|
|
|
|
|
+ it('specialDownMove', () => {
|
|
|
+ const tree = new Tree([
|
|
|
+ { ID: '1', parentID: '-1', seq: 1 },
|
|
|
+ { ID: '2', parentID: '-1', seq: 2 },
|
|
|
+ { ID: '3', parentID: '-1', seq: 2 },
|
|
|
+ { ID: '4', parentID: '-1', seq: 4 },
|
|
|
+ { ID: '5', parentID: '-1', seq: 5 },
|
|
|
+ ]);
|
|
|
+ const nodes = [tree.find('2')];
|
|
|
+ const updateData = tree.prepareDownMove(nodes as TreeNode[]);
|
|
|
+ tree.move(nodes as TreeNode[], updateData);
|
|
|
+ const IDList = getIDList(tree.data);
|
|
|
+ expect(IDList).to.have.ordered.members(['1', '3', '2', '4', '5']);
|
|
|
+ expect(nodes[0]).to.have.property('seq', 2);
|
|
|
+ const node3 = tree.find('3');
|
|
|
+ expect(node3).to.have.property('seq', 1);
|
|
|
+ });
|
|
|
+
|
|
|
it('single-upLevel', () => {
|
|
|
const tree = new Tree(cloneDeep(complicatedRawData));
|
|
|
const node10 = tree.find('10');
|