✅ Point and Attributes tests
This commit is contained in:
parent
1c4507c5bd
commit
7803d1b996
9 changed files with 2935 additions and 134 deletions
30
tests/attributes.test.js
Normal file
30
tests/attributes.test.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
var expect = require("chai").expect;
|
||||
var Point = require("../dist/index.js").Point;
|
||||
|
||||
function newAttr() {
|
||||
return new Point(0, 0).attributes;
|
||||
}
|
||||
|
||||
it("should return false when getting an unset attribute", () => {
|
||||
let a = newAttr();
|
||||
expect(a.get("test")).to.equal(false);
|
||||
});
|
||||
|
||||
it("should render attributes correctly", () => {
|
||||
let a = newAttr()
|
||||
.set("class", "test")
|
||||
.add("class", "render")
|
||||
.set("transform", "scale(1)");
|
||||
expect(a.render()).to.equal(' class="test render" transform="scale(1)"');
|
||||
});
|
||||
|
||||
it("should render attributes with given prefix only", () => {
|
||||
let a = newAttr()
|
||||
.set("class", "test")
|
||||
.add("class", "render")
|
||||
.add("data-text", "foo")
|
||||
.add("data-text", "bar")
|
||||
.add("data-mode", "test")
|
||||
.set("transform", "scale(1)");
|
||||
expect(a.renderIfPrefixIs("data-")).to.equal(' text="foo bar" mode="test"');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue