Skip to content

Commit

Permalink
Updates bluesky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Nov 25, 2024
1 parent 1129086 commit 97c063f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/build/plugins/bluesky/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,44 @@ describe("bluesky plugin", function () {
const replaceURLsWithEmbeds = require("./index.js").render;
const cheerio = require("cheerio");

it("works", function () {
it("works", function (done) {
// html bare link to a post on bluesky
const html =
'<a href="https://bsky.app/profile/logicallyjc.bsky.social/post/3lbretguxqk2b">https://bsky.app/profile/logicallyjc.bsky.social/post/3lbretguxqk2b</a>';

const $ = cheerio.load(html);

replaceURLsWithEmbeds($, function () {
expect($("a").length).toBe(0);

console.log('html:', $.html());
expect($("a[href='https://bsky.app/profile/logicallyjc.bsky.social/post/3lbretguxqk2b']").length).toBe(0);
expect($("blockquote").length).toBe(1);
done();
});
});

it("does not error when there are no links", function () {
it("does not error when there are no links", function (done) {
const html = "<p>hello</p>";

const $ = cheerio.load(html);

replaceURLsWithEmbeds($, function () {
expect($("a").length).toBe(0);
expect($("blockquote").length).toBe(0);
done();
});
});

// if the bluesky link is invalid or poorly formatted, it should not be replaced
it("does not error when the link is invalid", function () {
it("does not error when the link is invalid", function (done) {
const html = '<a href="https://bsky.app">https://bsky.app</a>';

const $ = cheerio.load(html);

replaceURLsWithEmbeds($, function () {
expect($("a").length).toBe(1);
expect($("blockquote").length).toBe(0);
done();
});
});
});

0 comments on commit 97c063f

Please sign in to comment.