Skip to content

Commit

Permalink
fix: Tests
Browse files Browse the repository at this point in the history
...do not compare colors, as they can have different formats, especially when interpolated with d3
  • Loading branch information
bprusinowski committed Jul 1, 2023
1 parent 08bf6b4 commit 62e4bc6
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions src/components/Text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe("Text", () => {
type: "title",
anchor: "middle",
dims: dims.resolve(),
svgBackgroundColor: "white",
});
const enterInts = Text.ints({
getters: [enterGetter],
Expand Down Expand Up @@ -62,14 +63,17 @@ describe("Text", () => {

describe("resolve", () => {
test("0", () => {
const { key, ...r } = Text.resolve({ ints: enterInts, t: 0 })[0];
const g = enterGetter.g({ s: (enter) => enter });
const { key, color, ...r } = Text.resolve({ ints: enterInts, t: 0 })[0];
const { color: gColor, ...g } = enterGetter.g({ s: (enter) => enter });

expect(r).toEqual(g);
});

test("0.5", () => {
const { key, ...r } = Text.resolve({ ints: enterInts, t: 0.5 })[0];
const { key, color, ...r } = Text.resolve({
ints: enterInts,
t: 0.5,
})[0];

expect(r).toEqual({
x: 400,
Expand All @@ -81,8 +85,10 @@ describe("Text", () => {
});

test("1", () => {
const { key, ...r } = Text.resolve({ ints: enterInts, t: 1 })[0];
const g = enterGetter.g({ s: (enter, update) => update ?? enter });
const { key, color, ...r } = Text.resolve({ ints: enterInts, t: 1 })[0];
const { color: gColor, ...g } = enterGetter.g({
s: (enter, update) => update ?? enter,
});

expect(r).toEqual(g);
});
Expand All @@ -95,6 +101,7 @@ describe("Text", () => {
type: "datumLabel",
anchor: "start",
dims: dims.resolve(),
svgBackgroundColor: "white",
});
const updateInts = Text.ints({
getters: [updateGetter],
Expand Down Expand Up @@ -146,14 +153,22 @@ describe("Text", () => {

describe("resolve", () => {
test("0", () => {
const { key, ...r } = Text.resolve({ ints: updateInts, t: 0 })[0];
const g = enterGetter.g({ s: (enter, update) => update ?? enter });
const { key, color, ...r } = Text.resolve({
ints: updateInts,
t: 0,
})[0];
const { color: gColor, ...g } = enterGetter.g({
s: (enter, update) => update ?? enter,
});

expect(r).toEqual(g);
});

test("0.5", () => {
const { key, ...r } = Text.resolve({ ints: updateInts, t: 0.5 })[0];
const { key, color, ...r } = Text.resolve({
ints: updateInts,
t: 0.5,
})[0];

expect(r).toEqual({
x: 208,
Expand All @@ -168,8 +183,13 @@ describe("Text", () => {
});

test("1", () => {
const { key, ...r } = Text.resolve({ ints: updateInts, t: 1 })[0];
const g = updateGetter.g({ s: (enter, update) => update ?? enter });
const { key, color, ...r } = Text.resolve({
ints: updateInts,
t: 1,
})[0];
const { color: gColor, ...g } = updateGetter.g({
s: (enter, update) => update ?? enter,
});

expect(r).toEqual(g);
});
Expand All @@ -193,14 +213,19 @@ describe("Text", () => {

describe("resolve", () => {
test("0", () => {
const { key, ...r } = Text.resolve({ ints: exitInts, t: 0 })[0];
const g = updateGetter.g({ s: (enter, update) => update ?? enter });
const { key, color, ...r } = Text.resolve({ ints: exitInts, t: 0 })[0];
const { color: gColor, ...g } = updateGetter.g({
s: (enter, update) => update ?? enter,
});

expect(r).toEqual(g);
});

test("0.5", () => {
const { key, ...r } = Text.resolve({ ints: exitInts, t: 0.5 })[0];
const { key, color, ...r } = Text.resolve({
ints: exitInts,
t: 0.5,
})[0];

expect(r).toEqual({
x: 16,
Expand All @@ -212,8 +237,10 @@ describe("Text", () => {
});

test("1", () => {
const { key, ...r } = Text.resolve({ ints: exitInts, t: 1 })[0];
const g = updateGetter.g({ s: (enter, _, exit) => exit ?? enter });
const { key, color, ...r } = Text.resolve({ ints: exitInts, t: 1 })[0];
const { color: gColor, ...g } = updateGetter.g({
s: (enter, _, exit) => exit ?? enter,
});

expect(r).toEqual(g);
});
Expand Down

0 comments on commit 62e4bc6

Please sign in to comment.