Skip to content

Commit

Permalink
fix(templates/show-link): render otherLinks without href as text (#2790)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Mar 12, 2020
1 parent 310da01 commit 482f0b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/w3c/templates/show-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function showLinkData(data) {
? html`
<a href="${data.href}">${data.value || data.href}</a>
`
: ""}
: data.value}
</dd>
`;
}
40 changes: 40 additions & 0 deletions tests/spec/w3c/headers-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,46 @@ describe("W3C — Headers", () => {
});
});

describe("otherLinks", () => {
it("renders otherLinks with value and href", async () => {
const otherLinks = [
{
class: "key-other-link",
key: "KEY",
data: [{ value: "VALUE", href: "HREF" }],
},
];
const ops = makeStandardOps({ otherLinks });
const doc = await makeRSDoc(ops);

const dt = doc.querySelector(".head dt.key-other-link");
expect(dt.textContent).toBe("KEY:");
const dd = dt.nextElementSibling;
expect(dd.localName).toBe("dd");
expect(dd.querySelector("a").textContent).toBe("VALUE");
expect(dd.querySelector("a").getAttribute("href")).toBe("HREF");
});

it("renders otherLinks without href", async () => {
const otherLinks = [
{
class: "key-other-link",
key: "KEY",
data: [{ value: "VALUE" }],
},
];
const ops = makeStandardOps({ otherLinks });
const doc = await makeRSDoc(ops);

const dt = doc.querySelector(".head dt.key-other-link");
expect(dt.textContent).toBe("KEY:");
const dd = dt.nextElementSibling;
expect(dd.localName).toBe("dd");
expect(dd.textContent.trim()).toBe("VALUE");
expect(dd.querySelector("a")).toBeNull();
});
});

describe("testSuiteURI", () => {
it("takes testSuiteURI into account", async () => {
const ops = makeStandardOps();
Expand Down

0 comments on commit 482f0b8

Please sign in to comment.