Skip to content
Snippets Groups Projects
Commit dc12ebee authored by Tom Robinson's avatar Tom Robinson
Browse files

Fix misc unit tests

parent ffa0b0a0
No related merge requests found
......@@ -64,9 +64,12 @@ function applyChartTooltips(
{
key: getFriendlyName(cols[1]),
value: isNormalized
? `${formatValue(d.data.value) * 100}%`
? formatValue(d.data.value, {
number_style: "percent",
column: cols[1],
})
: d.data.value,
col: cols[1],
col: { ...cols[1] },
},
];
......
......@@ -75,7 +75,11 @@ describe("formatting", () => {
it("should return a component for links in jsx + rich mode", () => {
expect(
isElementOfType(
formatValue("http://metabase.com/", { jsx: true, rich: true }),
formatValue("http://metabase.com/", {
jsx: true,
rich: true,
view_as: "link",
}),
ExternalLink,
),
).toEqual(true);
......@@ -83,7 +87,11 @@ describe("formatting", () => {
it("should return a component for email addresses in jsx + rich mode", () => {
expect(
isElementOfType(
formatValue("tom@metabase.com", { jsx: true, rich: true }),
formatValue("tom@metabase.com", {
jsx: true,
rich: true,
view_as: "email_link",
}),
ExternalLink,
),
).toEqual(true);
......@@ -97,19 +105,31 @@ describe("formatting", () => {
it("should return a component for http:, https:, and mailto: links in jsx mode", () => {
expect(
isElementOfType(
formatUrl("http://metabase.com/", { jsx: true, rich: true }),
formatUrl("http://metabase.com/", {
jsx: true,
rich: true,
view_as: "link",
}),
ExternalLink,
),
).toEqual(true);
expect(
isElementOfType(
formatUrl("https://metabase.com/", { jsx: true, rich: true }),
formatUrl("https://metabase.com/", {
jsx: true,
rich: true,
view_as: "link",
}),
ExternalLink,
),
).toEqual(true);
expect(
isElementOfType(
formatUrl("mailto:tom@metabase.com", { jsx: true, rich: true }),
formatUrl("mailto:tom@metabase.com", {
jsx: true,
rich: true,
view_as: "link",
}),
ExternalLink,
),
).toEqual(true);
......@@ -117,25 +137,34 @@ describe("formatting", () => {
it("should not return a link component for unrecognized links in jsx mode", () => {
expect(
isElementOfType(
formatUrl("nonexistent://metabase.com/", { jsx: true, rich: true }),
formatUrl("nonexistent://metabase.com/", {
jsx: true,
rich: true,
view_as: "link",
}),
ExternalLink,
),
).toEqual(false);
expect(
isElementOfType(
formatUrl("metabase.com", { jsx: true, rich: true }),
formatUrl("metabase.com", { jsx: true, rich: true, view_as: "link" }),
ExternalLink,
),
).toEqual(false);
});
it("should return a string for javascript:, data:, and other links in jsx mode", () => {
expect(
formatUrl("javascript:alert('pwnd')", { jsx: true, rich: true }),
formatUrl("javascript:alert('pwnd')", {
jsx: true,
rich: true,
view_as: "link",
}),
).toEqual("javascript:alert('pwnd')");
expect(
formatUrl("data:text/plain;charset=utf-8,hello%20world", {
jsx: true,
rich: true,
view_as: "link",
}),
).toEqual("data:text/plain;charset=utf-8,hello%20world");
});
......
......@@ -99,7 +99,7 @@ describe("LineAreaBarRenderer-bar", () => {
normalizedDisplay = [
{ key: "Category", value: "A" },
{ key: "% Sum", value: "33%" },
{ key: "% Sum", value: "33.33%" },
];
expect(data).toEqual(
......@@ -116,7 +116,7 @@ describe("LineAreaBarRenderer-bar", () => {
normalizedDisplay = [
{ key: "Category", value: "A" },
{ key: "% Count", value: "67%" },
{ key: "% Count", value: "66.67%" },
];
expect(data).toEqual(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment