chore(core): Updated tests
This commit is contained in:
parent
9125b49841
commit
7a67761a30
4 changed files with 1 additions and 109 deletions
|
@ -12,7 +12,6 @@ it("Should contain all hooks", () => {
|
||||||
preRender: [],
|
preRender: [],
|
||||||
postRender: [],
|
postRender: [],
|
||||||
insertText: [],
|
insertText: [],
|
||||||
debug: []
|
|
||||||
};
|
};
|
||||||
expect(h).to.eql(test);
|
expect(h).to.eql(test);
|
||||||
});
|
});
|
||||||
|
|
|
@ -47,19 +47,6 @@ it("Should register and run a macro", () => {
|
||||||
expect(part.points.macro.y).to.equal(456);
|
expect(part.points.macro.y).to.equal(456);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should run debug", () => {
|
|
||||||
let pattern = new freesewing.Pattern();
|
|
||||||
let part = new pattern.Part();
|
|
||||||
let debug = part.debugClosure();
|
|
||||||
expect(typeof debug).to.equal("function");
|
|
||||||
let d = 1;
|
|
||||||
let e = 11;
|
|
||||||
let b = 111;
|
|
||||||
let u = 1111;
|
|
||||||
let g = 11111;
|
|
||||||
expect(debug(d, e, b, u, g)).to.equal(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should return a free ID", () => {
|
it("Should return a free ID", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let pattern = new freesewing.Pattern();
|
||||||
let part = new pattern.Part();
|
let part = new pattern.Part();
|
||||||
|
|
|
@ -136,16 +136,6 @@ it("Should throw an error if per-part draft method is missing", () => {
|
||||||
expect(() => pattern.draft()).to.throw();
|
expect(() => pattern.draft()).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should throw an error if a part draft method doesn't return", () => {
|
|
||||||
const Test = new freesewing.Design({
|
|
||||||
name: "test",
|
|
||||||
parts: ["back"]
|
|
||||||
});
|
|
||||||
Test.prototype.draftBack = part => {};
|
|
||||||
let pattern = new Test();
|
|
||||||
expect(() => pattern.draft()).to.throw();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should sample an option", () => {
|
it("Should sample an option", () => {
|
||||||
let pattern = new freesewing.Pattern({
|
let pattern = new freesewing.Pattern({
|
||||||
options: {
|
options: {
|
||||||
|
@ -174,90 +164,6 @@ it("Should sample an option", () => {
|
||||||
expect(pattern.parts.b.paths.test_10.ops[1].to.y).to.equal(10);
|
expect(pattern.parts.b.paths.test_10.ops[1].to.y).to.equal(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should sample a measurement", () => {
|
|
||||||
let pattern = new freesewing.Pattern();
|
|
||||||
pattern.settings.measurements = { headToToe: 1980 };
|
|
||||||
pattern.draft = function() {
|
|
||||||
pattern.parts.a = new pattern.Part();
|
|
||||||
pattern.parts.b = new pattern.Part();
|
|
||||||
let a = pattern.parts.a;
|
|
||||||
a.points.from = new a.Point(0, 0);
|
|
||||||
a.points.to = new a.Point(10, a.context.settings.measurements.headToToe);
|
|
||||||
a.paths.test = new a.Path().move(a.points.from).line(a.points.to);
|
|
||||||
pattern.parts.b.inject(a);
|
|
||||||
};
|
|
||||||
pattern.settings.sample = {
|
|
||||||
type: "measurement",
|
|
||||||
measurement: "headToToe"
|
|
||||||
};
|
|
||||||
pattern.sample();
|
|
||||||
expect(pattern.parts.a.paths.test_1.render).to.equal(true);
|
|
||||||
expect(pattern.parts.b.paths.test_10.ops[1].to.x).to.equal(10);
|
|
||||||
expect(() => pattern.sampleMeasurement("unknown")).to.throw();
|
|
||||||
});
|
|
||||||
/* FIXME: this needs work
|
|
||||||
it("Should sample models", () => {
|
|
||||||
const Test = new freesewing.Design({
|
|
||||||
name: "test",
|
|
||||||
dependencies: { b: "a" },
|
|
||||||
inject: { b: "a" },
|
|
||||||
});
|
|
||||||
Test.prototype.draftA = part => {
|
|
||||||
console.log(part.shorthand());
|
|
||||||
part.points.from = new part.Point(0, 0);
|
|
||||||
part.points.to = new part.Point(10, part.context.settings.measurements.headToToe);
|
|
||||||
part.points.anchor = new part.Point(20, 30);
|
|
||||||
part.paths.test = new part.Path().move(part.points.from).line(part.points.to);
|
|
||||||
return part;
|
|
||||||
};
|
|
||||||
Test.prototype.draftB = part => part;
|
|
||||||
|
|
||||||
let pattern = new Test({
|
|
||||||
sample: {
|
|
||||||
type: "models",
|
|
||||||
models: {
|
|
||||||
a: { headToToe: 1980 },
|
|
||||||
b: { headToToe: 1700 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
pattern.sample();
|
|
||||||
console.log(pattern);
|
|
||||||
//expect(pattern.parts.a.paths.test_1.render).to.equal(true);
|
|
||||||
//expect(pattern.parts.b.paths.test_2.ops[1].to.x).to.equal(10);
|
|
||||||
});
|
|
||||||
/*
|
|
||||||
it("Should sample models with focus", () => {
|
|
||||||
let pattern = new freesewing.Pattern();
|
|
||||||
pattern.settings.sample = {
|
|
||||||
type: "models",
|
|
||||||
focus: "a",
|
|
||||||
models: {
|
|
||||||
a: { headToToe: 1980 },
|
|
||||||
b: { headToToe: 1700 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
pattern.draft = function() {
|
|
||||||
pattern.parts.a = new pattern.Part();
|
|
||||||
pattern.parts.b = new pattern.Part();
|
|
||||||
let a = pattern.parts.a;
|
|
||||||
a.points.from = new a.Point(0, 0);
|
|
||||||
a.points.to = new a.Point(10, a.context.settings.measurements.headToToe);
|
|
||||||
a.points.anchor = new a.Point(20, 30);
|
|
||||||
a.paths.test = new a.Path().move(a.points.from).line(a.points.to);
|
|
||||||
pattern.parts.b.inject(a);
|
|
||||||
};
|
|
||||||
pattern.sample();
|
|
||||||
expect(pattern.parts.a.paths.test_1.render).to.equal(true);
|
|
||||||
expect(pattern.parts.b.paths.test_2.ops[1].to.x).to.equal(10);
|
|
||||||
expect(pattern.parts.a.paths.test_1.attributes.get("class")).to.equal(
|
|
||||||
"sample-focus"
|
|
||||||
);
|
|
||||||
expect(pattern.parts.b.paths.test_2.attributes.get("style")).to.equal(
|
|
||||||
"stroke: hsl(165, 100%, 35%);"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
it("Should register a hook via on", () => {
|
it("Should register a hook via on", () => {
|
||||||
let pattern = new freesewing.Pattern();
|
let pattern = new freesewing.Pattern();
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
|
@ -185,7 +185,7 @@ it("Should find no intersection between two curves", () => {
|
||||||
|
|
||||||
it("Should correctly format units", () => {
|
it("Should correctly format units", () => {
|
||||||
expect(freesewing.utils.units(123.456)).to.equal("12.35cm");
|
expect(freesewing.utils.units(123.456)).to.equal("12.35cm");
|
||||||
expect(freesewing.utils.units(123.456, "imperial")).to.equal('4.86"');
|
expect(freesewing.utils.units(123.456, "imperial")).to.equal('4.86"');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should find a start or end point on beam", () => {
|
it("Should find a start or end point on beam", () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue