Skip to content

Commit

Permalink
Light test of getSourceContributions
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Sep 17, 2023
1 parent 287d460 commit b70be91
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test-js/test-var-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
piecewiseLinearMap,
supportScalar,
} from "../src/fontra/client/core/var-model.js";
import { parametrize } from "./test-support.js";

describe("var-model tests", () => {
describe("VariationModel tests", () => {
Expand Down Expand Up @@ -341,4 +342,25 @@ describe("var-model tests", () => {
expect(mapBackward(location, axes)).to.deep.equal({ weight: 10, width: 100 });
});
});

describe("getSourceContributions tests", () => {
const locations = [{}, { wght: 1 }, { wdth: 1 }];
const model = new VariationModel(locations, ["wght", "wdth"]);
parametrize(
"test contrib",
[
{ location: { wght: 0, wdth: 0 }, result: [1, 0, 0] },
{ location: { wght: 0.5, wdth: 0 }, result: [0.5, 0.5, 0] },
{ location: { wght: 1, wdth: 0 }, result: [0, 1, 0] },
{ location: { wght: 0, wdth: 0.5 }, result: [0.5, 0, 0.5] },
{ location: { wght: 0, wdth: 1 }, result: [0, 0, 1] },
{ location: { wght: 1, wdth: 1 }, result: [-1, 1, 1] },
],
(testData) => {
expect(model.getSourceContributions(testData.location)).to.deep.equal(
testData.result
);
}
);
});
});

0 comments on commit b70be91

Please sign in to comment.