diff --git a/tests/FeedReader.spec.ts b/tests/FeedReader.spec.ts index 9b2de2fb..19313035 100644 --- a/tests/FeedReader.spec.ts +++ b/tests/FeedReader.spec.ts @@ -250,4 +250,34 @@ describe("FeedReader", () => { feedReader.stop(); expect(events).to.have.lengthOf(1); }); + it("should handle feed entries without a title", async () => { + const { mq, feedReader, httpServer } = await constructFeedReader(() => ({ + headers: {}, data: ` + + + Example Feed + + http://example.org/123456 + http://example.org/123456 + Sun, 04 Feb 2024 20:10:08 +0000 + Some text. + + + + ` + })); + after(() => httpServer.close()); + const event: MessageQueueMessage = await new Promise((resolve) => { + mq.on('pushed', (data) => { resolve(data); feedReader.stop() }); + }); + + expect(event.eventName).to.equal('feed.entry'); + expect(event.data.feed.title).to.equal('Example Feed'); + expect(event.data.title).to.be.null; + expect(event.data.author).to.be.null; + expect(event.data.summary).to.equal('Some text.'); + expect(event.data.link).to.equal('http://example.org/123456'); + expect(event.data.pubdate).to.equal('Sun, 04 Feb 2024 20:10:08 +0000'); + console.log(event.data); + }); }); diff --git a/tests/connections/FeedTest.spec.ts b/tests/connections/FeedTest.spec.ts index 6bb26841..ac2c7975 100644 --- a/tests/connections/FeedTest.spec.ts +++ b/tests/connections/FeedTest.spec.ts @@ -82,6 +82,23 @@ describe("FeedConnection", () => { expect(matrixEvt.roomId).to.equal(ROOM_ID); expect(matrixEvt.content.body).to.equal("New post in Test feed: Foo"); }); + // https://github.com/matrix-org/matrix-hookshot/issues/888 + it("will handle a mastodon-style rss feed ", async () => { + const [connection, intent] = createFeed(); + await connection.handleFeedEntry({ + feed: { title: 'Example Feed', url: 'http://127.0.0.1:35339/' }, + title: null, + pubdate: 'Sun, 04 Feb 2024 20:10:08 +0000', + summary: 'Some text.', + author: null, + link: 'http://example.org/123456', + fetchKey: randomUUID(), + }); + const matrixEvt =intent.sentEvents[0]; + expect(matrixEvt).to.not.be.undefined; + expect(matrixEvt.roomId).to.equal(ROOM_ID); + expect(matrixEvt.content.body).to.equal("New post in Example Feed: [http://example.org/123456](http://example.org/123456)"); + }); it("will handle simple feed message with all the template options possible ", async () => { const [connection, intent] = createFeed({ template: `$FEEDNAME $FEEDURL $FEEDTITLE $TITLE $LINK $AUTHOR $DATE $SUMMARY`