wip(core): Work on late-stage config resolver
This moves resolving of the config from the pattern constructor to the init() method. The idea is that adding a part to a pattern is exactly the same as adding a part to a design. In other words, late-stage adding of parts would be no different as the config gets resolved after that. This is currently broken in many different ways, but the unit tests particular to this new way of resolving the config do pass.
This commit is contained in:
parent
58c15f6c81
commit
0cbffd6dc6
32 changed files with 4536 additions and 3384 deletions
|
@ -1,33 +1,29 @@
|
|||
import chai from "chai"
|
||||
import { Snippet, Point } from "./dist/index.mjs"
|
||||
import chai from 'chai'
|
||||
import { Snippet, Point } from '../src/index.mjs'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Snippet', () => {
|
||||
it("Should create a snippet", () => {
|
||||
let snip1 = new Snippet("test", new Point(12, 34));
|
||||
expect(snip1.def).to.equal("test");
|
||||
expect(snip1.anchor.x).to.equal(12);
|
||||
expect(snip1.anchor.y).to.equal(34);
|
||||
});
|
||||
it('Should create a snippet', () => {
|
||||
let snip1 = new Snippet('test', new Point(12, 34))
|
||||
expect(snip1.def).to.equal('test')
|
||||
expect(snip1.anchor.x).to.equal(12)
|
||||
expect(snip1.anchor.y).to.equal(34)
|
||||
})
|
||||
|
||||
it("Should clone a snippet", () => {
|
||||
let snip3 = new Snippet("boo", new Point(56, 78));
|
||||
expect(snip3.clone().def).to.equal("boo");
|
||||
expect(snip3.clone().anchor.x).to.equal(56);
|
||||
expect(snip3.clone().anchor.y).to.equal(78);
|
||||
});
|
||||
|
||||
it("Should set an attribute", () => {
|
||||
let s = new Snippet("test", new Point(12, -34)).attr(
|
||||
"class",
|
||||
"test"
|
||||
);
|
||||
expect(s.attributes.get("class")).to.equal("test");
|
||||
s.attr("class", "more");
|
||||
expect(s.attributes.get("class")).to.equal("test more");
|
||||
s.attr("class", "less", true);
|
||||
expect(s.attributes.get("class")).to.equal("less");
|
||||
});
|
||||
});
|
||||
it('Should clone a snippet', () => {
|
||||
let snip3 = new Snippet('boo', new Point(56, 78))
|
||||
expect(snip3.clone().def).to.equal('boo')
|
||||
expect(snip3.clone().anchor.x).to.equal(56)
|
||||
expect(snip3.clone().anchor.y).to.equal(78)
|
||||
})
|
||||
|
||||
it('Should set an attribute', () => {
|
||||
let s = new Snippet('test', new Point(12, -34)).attr('class', 'test')
|
||||
expect(s.attributes.get('class')).to.equal('test')
|
||||
s.attr('class', 'more')
|
||||
expect(s.attributes.get('class')).to.equal('test more')
|
||||
s.attr('class', 'less', true)
|
||||
expect(s.attributes.get('class')).to.equal('less')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue