Skip to content

Commit

Permalink
test(astro-rss): Compare XML using chai-xml
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Dec 7, 2022
1 parent 081e0a9 commit ac799ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/astro-rss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"astro-scripts": "workspace:*",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"chai-xml": "^0.4.0",
"mocha": "^9.2.2"
},
"dependencies": {
Expand Down
8 changes: 5 additions & 3 deletions packages/astro-rss/test/rss.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import rss from '../dist/index.js';
import chai from 'chai';
import chaiPromises from 'chai-as-promised';
import chaiXml from 'chai-xml';

chai.use(chaiPromises);
chai.use(chaiXml);

const title = 'My RSS feed';
const description = 'This sure is a nice RSS feed';
Expand Down Expand Up @@ -49,7 +51,7 @@ describe('rss', () => {
site,
});

chai.expect(body).to.equal(validXmlResult);
chai.expect(body).xml.to.equal(validXmlResult);
});

it('should generate on valid RSSFeedItem array with HTML content included', async () => {
Expand All @@ -60,7 +62,7 @@ describe('rss', () => {
site,
});

chai.expect(body).to.equal(validXmlWithContentResult);
chai.expect(body).xml.to.equal(validXmlWithContentResult);
});

describe('glob result', () => {
Expand Down Expand Up @@ -97,7 +99,7 @@ describe('rss', () => {
site,
});

chai.expect(body).to.equal(validXmlResult);
chai.expect(body).xml.to.equal(validXmlResult);
});

it('should fail on missing "title" key', () => {
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac799ff

Please sign in to comment.