Files
smartfeed/test/test.integration.node+bun+deno.ts

75 lines
2.1 KiB
TypeScript

import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartfeed from '../ts/index.js';
/**
* Integration test - Quick smoke test for the entire module
* For detailed tests, see:
* - test.creation.node+bun+deno.ts
* - test.validation.node+bun+deno.ts
* - test.export.node+bun+deno.ts
* - test.parsing.node+bun+deno.ts
*/
tap.test('integration: should create, populate, export, and parse a feed', async () => {
// Create instance
const smartfeedInstance = new smartfeed.Smartfeed();
expect(smartfeedInstance).toBeInstanceOf(smartfeed.Smartfeed);
// Create feed
const feed = smartfeedInstance.createFeed({
domain: 'example.com',
title: 'Integration Test Feed',
category: 'Technology',
company: 'Test Inc',
companyDomain: 'https://example.com',
companyEmail: 'test@example.com',
description: 'Full integration test',
});
expect(feed).toBeInstanceOf(smartfeed.Feed);
// Add items
feed.addItem({
title: 'Test Article 1',
authorName: 'Author',
imageUrl: 'https://example.com/image1.jpg',
timestamp: Date.now(),
url: 'https://example.com/article1',
content: 'Content 1',
});
feed.addItem({
title: 'Test Article 2',
authorName: 'Author',
imageUrl: 'https://example.com/image2.jpg',
timestamp: Date.now(),
url: 'https://example.com/article2',
content: 'Content 2',
});
expect(feed.items.length).toEqual(2);
// Export RSS
const rssString = feed.exportRssFeedString();
expect(rssString).toInclude('Integration Test Feed');
expect(rssString).toInclude('Test Article 1');
expect(rssString).toInclude('Test Article 2');
// Export Atom
const atomString = feed.exportAtomFeed();
expect(atomString).toInclude('Integration Test Feed');
// Export JSON
const jsonString = feed.exportJsonFeed();
const jsonFeed = JSON.parse(jsonString);
expect(jsonFeed.title).toEqual('Integration Test Feed');
expect(jsonFeed.items.length).toEqual(2);
// Parse back
const parsed = await smartfeedInstance.parseFeedFromString(rssString);
expect(parsed.title).toEqual('Integration Test Feed');
expect(parsed.items.length).toEqual(2);
});
export default tap.start();