require("./chai.helper");
var domHelper = require("./dom.helper");
describe("attr", function () {
beforeEach(function () {
domHelper(
"
" +
"should not be selected when inside context" +
"
" +
"" +
"this should also not be selected"
);
});
it("should select a single element by ID", function () {
var elt = $("#single1");
elt.size().should.equal(1);
elt.get(0).id.should.equal("single1");
});
it("should select multiple elements", function () {
var elts = $("div");
elts.size().should.equal(2);
});
it("should wrap native DOM elements", function () {
var elt = document.createElement("div");
$(elt).get(0).should.equal(elt);
});
it("should not wrap af objects more than once", function () {
var elt = $("#single1").get(0);
$($("#single1")).get(0).should.equal(elt);
});
it("should create elements", function () {
var elt = $("").get(0);
elt.id.should.equal("foobar");
});
it("should select within a context if supplied", function () {
var text = "" +
"
" +
"Foo" +
"Foo" +
"
"+
"
" +
"Foo" +
"
" +
"
" +
"
" +
"Foo
" +
"" +
"
";
$("#single2").append(text);
var tmp = $("#parent_test_cont");
$("span", tmp).length.should.equal(4);
});
it("should remove spaces when constructing HTML", function () {
$(" ").length.should.equal(1);
});
});