treetable adding nodes at root level

describe("loadBranch()", function() {
    beforeEach(function() {
    this.newRows = "<tr data-tt-id=‘3‘ data-tt-parent-id=‘2‘><td>N3</td></tr><tr data-tt-id=‘4‘ data-tt-parent-id=‘2‘><td>N4</td></tr>"
    - this.moreRows = "<tr data-tt-id=‘5‘ data-tt-parent-id=‘2‘><td>N5</td></tr>"
    + this.moreRows = "<tr data-tt-id=‘5‘ data-tt-parent-id=‘2‘><td>N5</td></tr>";
     
    this.subject.treetable();
    this.parentNode = this.subject.treetable("node", 2);
  @@ -276,9 +276,32 @@
    expect(this.subject.data("treetable").tree[4]).to.be.defined;
    });
     
    + it("registers nodes", function() {
    + expect(this.subject.data("treetable").nodes.length).to.equal(3);
    + this.subject.treetable("loadBranch", this.parentNode, this.newRows);
    + expect(this.subject.data("treetable").nodes.length).to.equal(5);
    + });
    +
    it("maintains chainability", function() {
    expect(this.subject.treetable("loadBranch", this.parentNode, this.newRows)).to.equal(this.subject);
    });
    +
    + describe("adding nodes at root level", function() {
    + beforeEach(function() {
    + this.rootRows = "<tr data-tt-id=‘6‘><td>N6</td></tr>";
    + });
    +
    + it("registers nodes as root nodes", function () {
    + expect(this.subject.data("treetable").roots.length).to.equal(1);
    + this.subject.treetable("loadBranch", null, this.rootRows);
    + expect(this.subject.data("treetable").roots.length).to.equal(2);
    + });
    +
    + it("inserts rows into DOM", function () {
    + this.subject.treetable("loadBranch", null, this.rootRows);
    + expect($(this.subject[0].rows[3]).data("ttId")).to.equal(6);
    + });
    + });
    });
     
时间: 2024-10-24 18:14:42

treetable adding nodes at root level的相关文章

[GeeksForGeeks] Print leftmost and rightmost nodes at each level of a binary tree.

Given a Binary Tree, Print the corner nodes at each level. The node at the leftmost and the node at the rightmost. For example, output for following is 15, 10, 20, 8, 25. Solution. Level Order Traversal using queue. Core idea:  Level order traversal

[GeeksForGeeks] Connect binary tree nodes of same level

Given a binary tree with each node having one extra field of nextRight. nextRight points to the next right node of the same level. Initially all nodes' nextRight field are set to null. Connect all nodes at the same level by setting each node's nextRi

【leetcode】1080. Insufficient Nodes in Root to Leaf Paths

题目如下: Given the root of a binary tree, consider all root to leaf paths: paths from the root to any leaf.  (A leaf is a node with no children.) A node is insufficient if every such root to leaf path intersecting this node has sum strictly less than li

[GeeksForGeeks] Level order traversal in spiral form of a binary tree.

Write a function to print spiral order traversal of a binary tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7.    Solution. For a normal level order traversal of a binary tree, we traverse every level from left to right. To achieve thi

LeetCode OJ - Binary Tree Level Order Traversal 1 &amp;&amp; 2

BFS以及它的扩展,我发现栈是个很好用的数据结构,特别是对于顺序需要颠倒的时候!!! 这里有个重要的信息:可以用null来标识一个level的结束!!! 下面是AC代码: 1 /** 2 * Given a binary tree, return the bottom-up level order traversal of its nodes' values. 3 * (ie, from left to right, level by level from leaf to root). 4 *

travel the binary tree by level 4 ( from down to top and from left to right every level )

个人信息:就读于燕大本科软件工程专业 目前大三; 本人博客:google搜索"cqs_2012"即可; 个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献; 博客内容:travel the binary tree by level 4 ( from down to top and from left to right every level ) 博客时间:2014-5-3; 编程语言:C++ ; 编程坏境:Windows 7 专业版 x64; 编程工具:vs2008

Pat(Advanced Level)Practice--1090(Highest Price in Supply Chain)

Pat1090代码 题目描述: A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer. Starting from one root supplier, everyone on the chain buys products from one's su

Printing a Binary Tree in Level Orders

BFS: Is it possible that a solution exists using only one single queue? Yes, you bet. The single queue solution requires two extra counting variables which keep tracks of the number of nodes in the current level (nodesInCurrentLevel) and the next lev

[leetcode]Binary Tree Zigzag Level Order Traversal @ Python

原题地址:http://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ 题意: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between