var parser = require("../../lib/parser2/parser.js"),
expect     = require("expect.js");

describe("parser/node#", function () {

  it("can parse a node without children", function () {
    parser.parse("<a>");
  });

  it("accepts many types of characters in the tag name", function () {
    parser.parse("<a>");
    parser.parse("<h3>");
    parser.parse("<a_v>");
    parser.parse("<a:n>");
  });

  it("can parse a node an end statement", function () {
    parser.parse("<a />");
  });

  it("fails if there is a closing tag without an open tag", function () {
    try {
      parser.parse("<a></b>");
    } catch (e) {
      expect(e.message).to.be("Expected </a> but \"<\" found.");
    }
  });

  it("can parse a node with a closing tag", function () {
    parser.parse("<a></a>");
  });

  it("can parse node attributes without values", function () {
    var ast = parser.parse("<a a b>")[0];
    expect(ast.name).to.be("a");
    expect(ast.attributes[0].name).to.be("a");
    expect(ast.attributes[0].value).to.be(void 0);
  });

  it("can parse node attributes with values", function () {
    parser.parse("<a b=\"c\" d='e'>")[0];
  });

  it("can parse attributes with escaped strings", function () {
    var ast = parser.parse("<a b='\\'c'>")[0];
    expect(ast.name).to.be("a");
    expect(ast.attributes[0].name).to.be("b");
    expect(ast.attributes[0].value).to.be("\\'c");
  });

  it("can parse a node with children", function () {
    var ast = parser.parse("<a><b></b></a>")[0];
    expect(ast.type).to.be("element");
    expect(ast.children[0].name).to.be("b");
  });

  it("can parse text", function () {
    var ast = parser.parse("abcde")[0];
    expect(ast.type).to.be("text");
    expect(ast.value).to.be("abcde");
  });

  it("can parse text with a node", function () {
    var ast = parser.parse("text<a></a>");
    expect(ast[0].type).to.be("text");
    expect(ast[0].value).to.be("text");
    expect(ast[1].type).to.be("element");
    expect(ast[1].name).to.be("a");
  });

  describe("bindings", function () {
    it("can parse text blocks", function () {

    });
  });

  it("can parse a text binding", function () {
    var ast = parser.parse("text{{ ab }}");
    expect(ast[1].type).to.be("binding");
  });
});

@@ -2083,16 +2083,777 @@
 ) %7B%0A
+      var ast= parser.parse(%22aa %7B%7Babc%7D%7D bb%22);%0A      expect(ast%5B1%5D.type).to.be(%22binding%22);%0A    %7D);%0A%0A    it(%22can parse binding blocks%22, function () %7B%0A      var ast = parser.parse(%22%7B%7B#a%7D%7D 123 %7B%7B/%7D%7D%22)%5B0%5D;%0A      expect(ast.type).to.be(%22bindingBlock%22);%0A      expect(ast.fragment%5B0%5D.type).to.be(%22text%22);%0A    %7D);%0A%0A    it(%22can parse binding blocks with children%22, function () %7B%0A      var ast = parser.parse(%22%7B%7B#a%7D%7D123%7B%7B/b%7D%7D456%7B%7B/c%7D%7D789%7B%7B/%7D%7D%22)%5B0%5D;%0A%0A      expect(ast.type).to.be(%22bindingBlock%22);%0A      expect(ast.fragment%5B0%5D.value).to.be(%22123%22);%0A      expect(ast.child.type).to.be(%22bindingBlock%22);%0A      expect(ast.child.fragment%5B0%5D.value).to.be(%22456%22);%0A      expect(ast.child.child.type).to.be(%22bindingBlock%22);%0A      expect(ast.child.child.fragment%5B0%5D.value).to.be(%22789%22);
 %0A    %7D)
-;
 %0A  %7D

add tests for bindnig blocks